From 3e9a7ffa059fccab9447223984ffed69d2cff235 Mon Sep 17 00:00:00 2001 From: svc-excavator-bot Date: Tue, 26 May 2026 09:48:13 +0000 Subject: [PATCH 1/2] Excavator: Switch to JUnit 5 to parallelize tests and speed up CI --- docker-proxy-rule-core/build.gradle | 4 +++ .../proxy/DockerContainerInfoUtilsTest.java | 2 +- .../docker/proxy/DockerNameServiceTest.java | 19 ++++++++------ .../docker/proxy/DockerProxySelectorTest.java | 25 ++++++++++++------- docker-proxy-rule-junit4/build.gradle | 5 ++++ .../docker/proxy/DockerProxyRuleTest.java | 11 +++++--- versions.lock | 12 +++++---- versions.props | 2 +- 8 files changed, 53 insertions(+), 27 deletions(-) diff --git a/docker-proxy-rule-core/build.gradle b/docker-proxy-rule-core/build.gradle index 5c4985ac1..d44332378 100644 --- a/docker-proxy-rule-core/build.gradle +++ b/docker-proxy-rule-core/build.gradle @@ -10,6 +10,10 @@ dependencies { testImplementation group: 'org.assertj', name: 'assertj-core' testImplementation group: 'org.mockito', name: 'mockito-core' testRuntimeOnly group: 'org.mockito', name: 'mockito-inline' + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', { + because 'allows JUnit 3 and JUnit 4 tests to run' + } } moduleJvmArgs { diff --git a/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerContainerInfoUtilsTest.java b/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerContainerInfoUtilsTest.java index 86165593f..7022f50fb 100644 --- a/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerContainerInfoUtilsTest.java +++ b/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerContainerInfoUtilsTest.java @@ -30,7 +30,7 @@ import java.nio.charset.StandardCharsets; import java.util.Optional; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DockerContainerInfoUtilsTest { private static final String CONTAINER_ID = "container-id"; diff --git a/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerNameServiceTest.java b/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerNameServiceTest.java index e797db11a..7b440ca73 100644 --- a/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerNameServiceTest.java +++ b/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerNameServiceTest.java @@ -25,7 +25,8 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class DockerNameServiceTest { private static final String HOST_NAME = "host"; @@ -63,11 +64,13 @@ public void shouldGetIpOfHostFromSupplierEveryTime() throws UnknownHostException verify(containerInfo, times(2)).getIpForHost(HOST_NAME); } - @Test(expected = UnknownHostException.class) + @Test public void shouldThrowUnknownHostExceptionWhenNoIpForHost() throws UnknownHostException { - when(containerInfo.getIpForHost(HOST_NAME)).thenReturn(Optional.empty()); + Assertions.assertThrows(UnknownHostException.class, () -> { + when(containerInfo.getIpForHost(HOST_NAME)).thenReturn(Optional.empty()); - dockerNameService.lookupAllHostAddr(HOST_NAME); + dockerNameService.lookupAllHostAddr(HOST_NAME); + }); } @Test @@ -98,10 +101,12 @@ public void shouldGetHostOfIpFromSupplierEveryTime() throws UnknownHostException verify(containerInfo, times(2)).getHostForIp(HOST_IP); } - @Test(expected = UnknownHostException.class) + @Test public void shouldThrowUnknownHostExceptionWhenNoHostForIp() throws UnknownHostException { - when(containerInfo.getHostForIp(HOST_IP)).thenReturn(Optional.empty()); + Assertions.assertThrows(UnknownHostException.class, () -> { + when(containerInfo.getHostForIp(HOST_IP)).thenReturn(Optional.empty()); - dockerNameService.getHostByAddr(HOST_IP_INET.getAddress()); + dockerNameService.getHostByAddr(HOST_IP_INET.getAddress()); + }); } } diff --git a/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerProxySelectorTest.java b/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerProxySelectorTest.java index ebd1ff624..5328331de 100644 --- a/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerProxySelectorTest.java +++ b/docker-proxy-rule-core/src/test/java/com/palantir/docker/proxy/DockerProxySelectorTest.java @@ -38,8 +38,9 @@ import java.net.URISyntaxException; import java.util.List; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class DockerProxySelectorTest { private static final String CLUSTER_IP = "172.17.0.1"; @@ -57,7 +58,7 @@ public class DockerProxySelectorTest { private final ProxySelector dockerProxySelector = new DockerProxySelector(setupProxyContainer(), containerInfo, originalProxySelector); - @Before + @BeforeEach public void originalProxySelectorIsNoProxy() { when(originalProxySelector.select(any())).thenReturn(ImmutableList.of(Proxy.NO_PROXY)); } @@ -92,19 +93,25 @@ public void dockerIpsShouldGoThroughAProxy() { assertThat(selectedProxy).containsExactly(new Proxy(Proxy.Type.SOCKS, PROXY_ADDRESS)); } - @Test(expected = IllegalArgumentException.class) + @Test public void connectionFailedShouldThrowOnNullUri() { - dockerProxySelector.connectFailed(null, PROXY_ADDRESS, new IOException()); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + dockerProxySelector.connectFailed(null, PROXY_ADDRESS, new IOException()); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void connectionFailedShouldThrowOnNullAddress() { - dockerProxySelector.connectFailed(TEST_HOSTNAME_URI, null, new IOException()); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + dockerProxySelector.connectFailed(TEST_HOSTNAME_URI, null, new IOException()); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void connectionFailedShouldThrowOnNullException() { - dockerProxySelector.connectFailed(TEST_HOSTNAME_URI, PROXY_ADDRESS, null); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + dockerProxySelector.connectFailed(TEST_HOSTNAME_URI, PROXY_ADDRESS, null); + }); } @Test diff --git a/docker-proxy-rule-junit4/build.gradle b/docker-proxy-rule-junit4/build.gradle index ce5a88cb2..9b8ad24c7 100644 --- a/docker-proxy-rule-junit4/build.gradle +++ b/docker-proxy-rule-junit4/build.gradle @@ -14,4 +14,9 @@ dependencies { testImplementation group: 'org.assertj', name: 'assertj-core' testImplementation group: 'org.mockito', name: 'mockito-core' + integrationTestImplementation 'org.junit.jupiter:junit-jupiter' + integrationTestRuntimeOnly 'org.junit.vintage:junit-vintage-engine', { + because 'allows JUnit 3 and JUnit 4 tests to run' + } + testImplementation 'org.junit.jupiter:junit-jupiter' } diff --git a/docker-proxy-rule-junit4/src/integrationTest/java/com/palantir/docker/proxy/DockerProxyRuleTest.java b/docker-proxy-rule-junit4/src/integrationTest/java/com/palantir/docker/proxy/DockerProxyRuleTest.java index a4184407b..d68916b73 100644 --- a/docker-proxy-rule-junit4/src/integrationTest/java/com/palantir/docker/proxy/DockerProxyRuleTest.java +++ b/docker-proxy-rule-junit4/src/integrationTest/java/com/palantir/docker/proxy/DockerProxyRuleTest.java @@ -22,7 +22,8 @@ import java.net.URL; import java.net.URLConnection; import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class DockerProxyRuleTest { @ClassRule @@ -125,9 +126,11 @@ public void otherHostnamesStillResolve() throws IOException, InterruptedExceptio } } - @Test(expected = IllegalStateException.class) + @Test public void runningProxyRuleBeforeDockerComposeRuleFails() throws IOException, InterruptedException { - DockerProxyRule.fromNetworkName("doesnotexist", DockerProxyRuleTest.class) - .before(); + Assertions.assertThrows(IllegalStateException.class, () -> { + DockerProxyRule.fromNetworkName("doesnotexist", DockerProxyRuleTest.class) + .before(); + }); } } diff --git a/versions.lock b/versions.lock index a8d0ecb00..28d65bde6 100644 --- a/versions.lock +++ b/versions.lock @@ -64,13 +64,13 @@ javax.ws.rs:javax.ws.rs-api:2.1.1 (1 constraints: f10f7399) joda-time:joda-time:2.12.7 (2 constraints: 232ce739) -junit:junit:4.13.2 (2 constraints: 841bfe6b) +junit:junit:4.13.2 (2 constraints: f82604db) one.util:streamex:0.8.4 (2 constraints: d01afa3c) org.apache.commons:commons-lang3:3.7 (1 constraints: 661571a7) -org.apiguardian:apiguardian-api:1.1.2 (5 constraints: 105480ac) +org.apiguardian:apiguardian-api:1.1.2 (6 constraints: 896455cc) org.awaitility:awaitility:4.0.2 (1 constraints: c015bbd2) @@ -84,9 +84,9 @@ org.hamcrest:hamcrest-core:3.0 (1 constraints: cc05fe3f) org.junit.jupiter:junit-jupiter-api:5.8.2 (4 constraints: 0547af6b) -org.junit.platform:junit-platform-commons:1.8.2 (2 constraints: dd200b4b) +org.junit.platform:junit-platform-commons:1.11.4 (2 constraints: 0921016c) -org.opentest4j:opentest4j:1.2.0 (2 constraints: cd205b49) +org.opentest4j:opentest4j:1.3.0 (2 constraints: ce205e49) org.slf4j:slf4j-api:1.7.36 (2 constraints: 042493b3) @@ -108,7 +108,9 @@ org.junit.jupiter:junit-jupiter-engine:5.8.2 (1 constraints: 0c0edf3b) org.junit.jupiter:junit-jupiter-params:5.8.2 (1 constraints: 0c0edf3b) -org.junit.platform:junit-platform-engine:1.8.2 (1 constraints: ab1027b4) +org.junit.platform:junit-platform-engine:1.11.4 (2 constraints: 57211695) + +org.junit.vintage:junit-vintage-engine:5.11.4 (1 constraints: 3d05483b) org.mockito:mockito-core:4.4.0 (2 constraints: f11021d5) diff --git a/versions.props b/versions.props index f962b6729..ed5255298 100644 --- a/versions.props +++ b/versions.props @@ -2,10 +2,10 @@ com.fasterxml.jackson.*:* = 2.21.1 com.fasterxml.jackson.core:jackson-annotations = 2.21 com.google.auto.service:* = 1.1.1 com.palantir.docker.compose:* = 2.3.0 -junit:junit = 4.13.2 one.util:streamex = 0.8.4 org.assertj:assertj-core = 3.27.7 org.junit.jupiter:* = 5.8.2 +org.junit.vintage:* = 5.11.4 org.mockito:* = 4.4.0 org.hamcrest:* = 3.0 net.bytebuddy:* = 1.18.8 From 86d06067fcf4bc5e229b588f133163681c2ee005 Mon Sep 17 00:00:00 2001 From: svc-nit Date: Tue, 26 May 2026 09:51:22 +0000 Subject: [PATCH 2/2] Resolve nit error-prone-apply-suppress --- .../java/com/palantir/docker/proxy/DockerProxyRuleTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-proxy-rule-junit4/src/integrationTest/java/com/palantir/docker/proxy/DockerProxyRuleTest.java b/docker-proxy-rule-junit4/src/integrationTest/java/com/palantir/docker/proxy/DockerProxyRuleTest.java index d68916b73..2d644b8c9 100644 --- a/docker-proxy-rule-junit4/src/integrationTest/java/com/palantir/docker/proxy/DockerProxyRuleTest.java +++ b/docker-proxy-rule-junit4/src/integrationTest/java/com/palantir/docker/proxy/DockerProxyRuleTest.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +@SuppressWarnings("for-rollout:JUnit5RuleUsage") public class DockerProxyRuleTest { @ClassRule public static final DockerComposeRule DOCKER_COMPOSE_RULE = DockerComposeRule.builder()