Skip to content
Open
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
4 changes: 4 additions & 0 deletions docker-proxy-rule-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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));
}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions docker-proxy-rule-junit4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
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;

@SuppressWarnings("for-rollout:JUnit5RuleUsage")
public class DockerProxyRuleTest {
@ClassRule
public static final DockerComposeRule DOCKER_COMPOSE_RULE = DockerComposeRule.builder()
Expand Down Expand Up @@ -125,9 +127,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();
});
}
}
12 changes: 7 additions & 5 deletions versions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -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