Skip to content

Commit 16aecea

Browse files
committed
Polish
1 parent c7df0c3 commit 16aecea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/src/test/java/org/testcontainers/containers/ExposedHostTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public class ExposedHostTest {
2525

2626
private static HttpServer server;
2727

28-
private static Network network;
29-
3028
@BeforeClass
3129
public static void setUpClass() throws Exception {
3230
server = HttpServer.create(new InetSocketAddress(0), 0);
@@ -42,13 +40,11 @@ public static void setUpClass() throws Exception {
4240
}
4341
);
4442
server.start();
45-
network = createReusableNetwork(UUID.randomUUID());
4643
}
4744

4845
@AfterClass
4946
public static void tearDownClass() {
5047
server.stop(0);
51-
DockerClientFactory.instance().client().removeNetworkCmd(network.getId()).exec();
5248
}
5349

5450
@After
@@ -93,6 +89,7 @@ public void testExposedHostPortOnFixedInternalPorts() {
9389

9490
@Test
9591
public void testExposedHostWithReusableContainerAndFixedNetworkName() throws IOException, InterruptedException {
92+
Network network = createReusableNetwork(UUID.randomUUID());
9693
Testcontainers.exposeHostPorts(server.getAddress().getPort());
9794

9895
GenericContainer<?> container = new GenericContainer<>(tinyContainerDef()).withReuse(true).withNetwork(network);
@@ -113,11 +110,13 @@ public void testExposedHostWithReusableContainerAndFixedNetworkName() throws IOE
113110

114111
container.stop();
115112
reusedContainer.stop();
113+
DockerClientFactory.lazyClient().removeNetworkCmd(network.getId()).exec();
116114
}
117115

118116
@Test
119117
public void testExposedHostOnFixedInternalPortsWithReusableContainerAndFixedNetworkName()
120118
throws IOException, InterruptedException {
119+
Network network = createReusableNetwork(UUID.randomUUID());
121120
Testcontainers.exposeHostPorts(ImmutableMap.of(server.getAddress().getPort(), 1234));
122121

123122
GenericContainer<?> container = new GenericContainer<>(tinyContainerDef()).withReuse(true).withNetwork(network);
@@ -138,6 +137,7 @@ public void testExposedHostOnFixedInternalPortsWithReusableContainerAndFixedNetw
138137

139138
container.stop();
140139
reusedContainer.stop();
140+
DockerClientFactory.lazyClient().removeNetworkCmd(network.getId()).exec();
141141
}
142142

143143
@SneakyThrows

0 commit comments

Comments
 (0)