Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to junit5 #2616

Merged
merged 4 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-2616.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Migrate to junit5
links:
- https://github.com/palantir/conjure-java-runtime/pull/2616
5 changes: 4 additions & 1 deletion client-config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies {
implementation 'com.google.guava:guava'
implementation project(":keystores")

testImplementation "junit:junit"
testImplementation 'com.google.guava:guava'
testImplementation "org.assertj:assertj-core"
testImplementation "org.mockito:mockito-core"
Expand All @@ -20,4 +19,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'
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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'
}
}
5 changes: 4 additions & 1 deletion conjure-java-jackson-serialization/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ dependencies {
implementation "com.palantir.safe-logging:logger"
implementation 'com.palantir.tritium:tritium-registry'

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'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import java.util.OptionalInt;
import java.util.OptionalLong;
import java.util.UUID;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class ObjectMappersTest {
private static final JsonMapper MAPPER = ObjectMappers.newClientJsonMapper();
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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'
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
5 changes: 4 additions & 1 deletion extras/refresh-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ dependencies {
api "com.google.code.findbugs:jsr305"
api "com.google.guava:guava"

testImplementation "junit:junit"
testImplementation "org.assertj:assertj-core"
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'
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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'
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import static org.assertj.core.api.Assertions.assertThat;

import com.google.common.collect.Iterables;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public final class HostMetricsRegistryTest {

private HostMetricsRegistry hostRegistry;

@Before
@BeforeEach
public void before() {
hostRegistry = new HostMetricsRegistry();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
import com.codahale.metrics.Timer;
import java.time.Clock;
import java.time.Instant;
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 HostMetricsTest {

private static final String SERVICE_NAME = "serviceName";
Expand All @@ -43,7 +46,7 @@ public final class HostMetricsTest {
@Mock
private Clock clock;

@Before
@BeforeEach
public void before() {
when(clock.millis()).thenReturn(firstInstant, secondInstant);
hostMetrics = new DefaultHostMetrics(SERVICE_NAME, HOSTNAME, PORT, clock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
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 InstrumentedInterceptorTest {

private static final int PORT = 8080;
Expand All @@ -57,7 +60,7 @@ public final class InstrumentedInterceptorTest {
private InstrumentedInterceptor interceptor;
private HostMetricsRegistry hostMetrics;

@Before
@BeforeEach
public void before() {
registry = new DefaultTaggedMetricRegistry();
hostMetrics = new HostMetricsRegistry();
Expand Down
Loading