Skip to content

Commit 8933038

Browse files
committed
Separate tests
1 parent 3ed7e7c commit 8933038

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

src/test/java/com/github/dockerjava/core/command/CreateNetworkCmdImplTest.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
import com.github.dockerjava.api.model.Network;
66
import com.github.dockerjava.client.AbstractDockerClientTest;
77
import org.testng.ITestResult;
8-
import org.testng.annotations.AfterMethod;
9-
import org.testng.annotations.AfterTest;
10-
import org.testng.annotations.BeforeMethod;
11-
import org.testng.annotations.BeforeTest;
12-
import org.testng.annotations.Test;
8+
import org.testng.annotations.*;
139

1410
import java.lang.reflect.Method;
1511

@@ -39,6 +35,20 @@ public void afterMethod(ITestResult result) {
3935
@Test
4036
public void createNetwork() throws DockerException {
4137

38+
String networkName = "testNetwork";
39+
40+
CreateNetworkResponse createNetworkResponse = dockerClient.createNetworkCmd().withName(networkName).exec();
41+
42+
assertNotNull(createNetworkResponse.getId());
43+
44+
Network network = dockerClient.inspectNetworkCmd().withNetworkId(createNetworkResponse.getId()).exec();
45+
assertEquals(network.getName(), networkName);
46+
assertEquals(network.getDriver(), "bridge");
47+
}
48+
49+
@Test
50+
public void createNetworkWithCustomConfig() throws DockerException {
51+
4252
String networkName = "testNetwork";
4353
Network.Ipam.Config config = new Network.Ipam.Config();
4454
config.setSubnet("10.67.79.0/24");
@@ -49,5 +59,6 @@ public void createNetwork() throws DockerException {
4959
Network network = dockerClient.inspectNetworkCmd().withNetworkId(createNetworkResponse.getId()).exec();
5060
assertEquals(network.getName(), networkName);
5161
assertEquals(network.getDriver(), "bridge");
62+
assertEquals("10.67.79.0/24", network.getIpam().getConfig().iterator().next().getSubnet());
5263
}
5364
}

src/test/java/com/github/dockerjava/netty/exec/CreateNetworkCmdExecTest.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
import com.github.dockerjava.api.model.Network;
66
import com.github.dockerjava.netty.AbstractNettyDockerClientTest;
77
import org.testng.ITestResult;
8-
import org.testng.annotations.AfterMethod;
9-
import org.testng.annotations.AfterTest;
10-
import org.testng.annotations.BeforeMethod;
11-
import org.testng.annotations.BeforeTest;
12-
import org.testng.annotations.Test;
8+
import org.testng.annotations.*;
139

1410
import java.lang.reflect.Method;
1511

@@ -39,6 +35,20 @@ public void afterMethod(ITestResult result) {
3935
@Test
4036
public void createNetwork() throws DockerException {
4137

38+
String networkName = "testNetwork";
39+
40+
CreateNetworkResponse createNetworkResponse = dockerClient.createNetworkCmd().withName(networkName).exec();
41+
42+
assertNotNull(createNetworkResponse.getId());
43+
44+
Network network = dockerClient.inspectNetworkCmd().withNetworkId(createNetworkResponse.getId()).exec();
45+
assertEquals(network.getName(), networkName);
46+
assertEquals(network.getDriver(), "bridge");
47+
}
48+
49+
@Test
50+
public void createNetworkWithCustomConfig() throws DockerException {
51+
4252
String networkName = "testNetwork";
4353
Network.Ipam.Config config = new Network.Ipam.Config();
4454
config.setSubnet("10.67.79.0/24");
@@ -49,5 +59,6 @@ public void createNetwork() throws DockerException {
4959
Network network = dockerClient.inspectNetworkCmd().withNetworkId(createNetworkResponse.getId()).exec();
5060
assertEquals(network.getName(), networkName);
5161
assertEquals(network.getDriver(), "bridge");
62+
assertEquals("10.67.79.0/24", network.getIpam().getConfig().iterator().next().getSubnet());
5263
}
5364
}

0 commit comments

Comments
 (0)