<commit_before>/*
 * Copyright 2022 The gRPC Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.grpc;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import org.junit.Test;

public class GlobalInterceptorsTest {

  private final StaticTestingClassLoader classLoader =
      new StaticTestingClassLoader(
          getClass().getClassLoader(), Pattern.compile("io\\.grpc\\.[^.]+"));

  @Test
  public void setInterceptorsTracers() throws Exception {
    Class<?> runnable = classLoader.loadClass(StaticTestingClassLoaderSet.class.getName());
    ((Runnable) runnable.getDeclaredConstructor().newInstance()).run();
  }

  @Test
  public void setGlobalInterceptorsTracers_twice() throws Exception {
    Class<?> runnable = classLoader.loadClass(StaticTestingClassLoaderSetTwice.class.getName());
    ((Runnable) runnable.getDeclaredConstructor().newInstance()).run();
  }

  @Test
  public void getBeforeSet_clientInterceptors() throws Exception {
    Class<?> runnable =
        classLoader.loadClass(
            StaticTestingClassLoaderGetBeforeSetClientInterceptor.class.getName());
    ((Runnable) runnable.getDeclaredConstructor().newInstance()).run();
  }

  @Test
  public void getBeforeSet_serverInterceptors() throws Exception {
    Class<?> runnable =
        classLoader.loadClass(
            StaticTestingClassLoaderGetBeforeSetServerInterceptor.class.getName());<commit_msg>api: Add missing RunWith annotation to GlobalInterceptorsTest (#9258)<commit_after>/*
 * Copyright 2022 The gRPC Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.grpc;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class GlobalInterceptorsTest {

  private final StaticTestingClassLoader classLoader =
      new StaticTestingClassLoader(
          getClass().getClassLoader(), Pattern.compile("io\\.grpc\\.[^.]+"));

  @Test
  public void setInterceptorsTracers() throws Exception {
    Class<?> runnable = classLoader.loadClass(StaticTestingClassLoaderSet.class.getName());
    ((Runnable) runnable.getDeclaredConstructor().newInstance()).run();
  }

  @Test
  public void setGlobalInterceptorsTracers_twice() throws Exception {
    Class<?> runnable = classLoader.loadClass(StaticTestingClassLoaderSetTwice.class.getName());
    ((Runnable) runnable.getDeclaredConstructor().newInstance()).run();
  }

  @Test
  public void getBeforeSet_clientInterceptors() throws Exception {
    Class<?> runnable =
        classLoader.loadClass(
            StaticTestingClassLoaderGetBeforeSetClientInterceptor.class.getName());
    ((Runnable) runnable.getDeclaredConstructor().newInstance()).run();
  }

  @Test
  public void getBeforeSet_serverInterceptors() throws Exception {
    Class<?> runnable =
        classLoader.loadClass(
            StaticTestingClassLoaderGetBeforeSetServerInterceptor.class.getName());
{'fraction_non_alphanumeric': 0.10072277920261133, 'fraction_numerical': 0.005129400792725577, 'mean_word_length': 4.471938775510204, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3309903', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1149, 'n_words': 325}