Skip to content

Commit

Permalink
Excavator: Switch to JUnit 5 to parallelize tests and speed up CI
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot committed Mar 9, 2023
1 parent 5e9b036 commit dcaaf8c
Show file tree
Hide file tree
Showing 43 changed files with 173 additions and 108 deletions.
4 changes: 4 additions & 0 deletions client-config/build.gradle
Expand Up @@ -20,4 +20,8 @@ dependencies {
annotationProcessor "org.immutables:value"
compileOnly 'org.immutables:value::annotations'
implementation 'com.palantir.safe-logging:logger'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', {
because 'allows JUnit 3 and JUnit 4 tests to run'
}
}
Expand Up @@ -37,7 +37,7 @@
import java.util.List;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class ClientConfigurationsTest {

Expand Down
Expand Up @@ -30,7 +30,7 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ConjureClientsTest {

Expand Down
4 changes: 4 additions & 0 deletions conjure-java-client-verifier/build.gradle
Expand Up @@ -15,4 +15,8 @@ dependencies {
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
testImplementation 'org.apache.commons:commons-lang3'
testImplementation 'com.palantir.safe-logging:logger'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', {
because 'allows JUnit 3 and JUnit 4 tests to run'
}
}
4 changes: 4 additions & 0 deletions conjure-java-jackson-serialization/build.gradle
Expand Up @@ -14,4 +14,8 @@ dependencies {

testImplementation "junit:junit"
testImplementation "org.assertj:assertj-core"
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', {
because 'allows JUnit 3 and JUnit 4 tests to run'
}
}
Expand Up @@ -44,7 +44,7 @@
import java.util.Optional;
import java.util.OptionalInt;
import java.util.OptionalLong;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class ObjectMappersTest {
private static final JsonMapper MAPPER = ObjectMappers.newClientJsonMapper();
Expand Down
Expand Up @@ -22,7 +22,7 @@
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class ShimJdk7ModuleTest {

Expand Down
5 changes: 5 additions & 0 deletions conjure-java-retrofit2-client/build.gradle
Expand Up @@ -28,4 +28,9 @@ dependencies {

annotationProcessor "org.immutables:value"
compileOnly 'org.immutables:value::annotations'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', {
because 'allows JUnit 3 and JUnit 4 tests to run'
}
testImplementation 'org.mockito:mockito-junit-jupiter'
}
Expand Up @@ -22,18 +22,21 @@
import com.palantir.conjure.java.client.retrofit2.AsyncSerializableErrorCallAdapterFactory.CompletableFutureBodyCallAdapter;
import com.palantir.conjure.java.client.retrofit2.AsyncSerializableErrorCallAdapterFactory.ListenableFutureBodyCallAdapter;
import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class AsyncSerializableErrorCallAdapterFactoryTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Response<String> response;
Expand Down
Expand Up @@ -34,7 +34,7 @@
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query;
Expand Down
Expand Up @@ -34,8 +34,8 @@
import okhttp3.Protocol;
import okhttp3.ResponseBody;
import okio.BufferedSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.stubbing.Answer;
import retrofit2.Call;
Expand Down Expand Up @@ -74,7 +74,7 @@ public BufferedSource source() {
private final CallAdapter.Factory factory = new QosExceptionThrowingCallAdapterFactory(delegateFactory);
private Retrofit retrofit;

@Before
@BeforeEach
public void before() {
retrofit = new Retrofit.Builder()
.baseUrl(url)
Expand Down
Expand Up @@ -54,10 +54,10 @@
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import okio.Buffer;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import retrofit2.Call;
import retrofit2.Response;

Expand All @@ -73,7 +73,7 @@ public final class Retrofit2ClientApiTest extends TestBase {
private HttpUrl url;
private TestService service;

@Before
@BeforeEach
public void before() {
url = server.url("/");
service = Retrofit2Client.create(
Expand Down
Expand Up @@ -28,7 +28,7 @@
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public final class Retrofit2ClientBuilderTest extends TestBase {
Expand Down
Expand Up @@ -24,7 +24,7 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class Retrofit2ClientConfigRefreshTest extends TestBase {

Expand Down
Expand Up @@ -33,7 +33,7 @@
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class Retrofit2ClientProxyTest extends TestBase {

Expand Down
Expand Up @@ -25,9 +25,9 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
Expand All @@ -39,7 +39,7 @@ public final class Retrofit2ClientQueryParamHandlingTest extends TestBase {

private Service proxy;

@Before
@BeforeEach
public void before() {
HttpUrl url = server.url("/");
proxy = Retrofit2Client.create(
Expand Down
Expand Up @@ -28,9 +28,9 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public final class TracerTest extends TestBase {

Expand All @@ -42,7 +42,7 @@ public final class TracerTest extends TestBase {

private TestService service;

@Before
@BeforeEach
public void before() {
String uri = "http://localhost:" + server.getPort();
service = Retrofit2Client.create(TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(uri));
Expand Down
4 changes: 4 additions & 0 deletions extras/refresh-utils/build.gradle
Expand Up @@ -10,4 +10,8 @@ dependencies {
testImplementation "org.jmock:jmock"
testImplementation "org.mockito:mockito-core"
testImplementation 'io.reactivex.rxjava2:rxjava'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', {
because 'allows JUnit 3 and JUnit 4 tests to run'
}
}
Expand Up @@ -25,8 +25,8 @@

import com.google.common.reflect.Reflection;
import java.util.function.Function;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
Expand All @@ -46,7 +46,7 @@ interface Callable {
@Mock
private Callable delegate2;

@Before
@BeforeEach
public void before() {
MockitoAnnotations.initMocks(this);
}
Expand Down
Expand Up @@ -24,7 +24,7 @@
import io.reactivex.schedulers.Schedulers;
import java.util.concurrent.TimeUnit;
import org.jmock.lib.concurrent.DeterministicScheduler;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class RefreshableTest {

Expand Down
5 changes: 5 additions & 0 deletions okhttp-clients/build.gradle
Expand Up @@ -32,4 +32,9 @@ dependencies {

annotationProcessor "org.immutables:value"
compileOnly 'org.immutables:value::annotations'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', {
because 'allows JUnit 3 and JUnit 4 tests to run'
}
testImplementation 'org.mockito:mockito-junit-jupiter'
}
Expand Up @@ -21,13 +21,16 @@

import java.io.IOException;
import okhttp3.Interceptor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public final class CatchThrowableInterceptorTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Interceptor.Chain chain;
Expand Down
Expand Up @@ -21,7 +21,7 @@
import static org.mockito.Mockito.verifyNoMoreInteractions;

import com.netflix.concurrency.limits.Limiter;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ConcurrencyLimitersTest {

Expand Down
Expand Up @@ -32,13 +32,16 @@
import okhttp3.Response;
import okhttp3.ResponseBody;
import okio.BufferedSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public final class ConcurrencyLimitingInterceptorTest {
private static final ConcurrencyLimitingInterceptor interceptor = new ConcurrencyLimitingInterceptor();

Expand All @@ -54,7 +57,7 @@ public final class ConcurrencyLimitingInterceptorTest {
private Request request;
private Response response;

@Before
@BeforeEach
public void before() {
request = new Request.Builder()
.url("https://localhost:1234/call")
Expand Down
Expand Up @@ -33,7 +33,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class DefaultConcurrencyLimitersTest {
private static final ConcurrencyLimiters.Key KEY =
Expand Down
Expand Up @@ -20,11 +20,14 @@

import com.google.common.util.concurrent.AtomicDouble;
import java.time.Duration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;

@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public final class ExponentialBackoffTest {
private static final Duration ONE_SECOND = Duration.ofSeconds(1);

Expand Down
Expand Up @@ -39,9 +39,9 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -67,12 +67,12 @@ public final class FlowControlTest {
FlowControlTest.class,
true);

@BeforeClass
@BeforeAll
public static void beforeClass() {
executorService = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
}

@AfterClass
@AfterAll
public static void afterClass() {
executorService.shutdown();
}
Expand Down

0 comments on commit dcaaf8c

Please sign in to comment.