@Test public void testReusability() throws Exception { try (Network network = Network.newNetwork()) { String firstId = network.getId(); assertNotNull( "Network exists", DockerClientFactory.instance().client().inspectNetworkCmd().withNetworkId(firstId).exec() ); network.close(); assertNotEquals( "New network created", firstId, DockerClientFactory.instance().client().inspectNetworkCmd().withNetworkId(network.getId()).exec().getId() ); } } }
@Test public void testBuilder() throws Exception { try ( Network network = Network.builder() .driver("macvlan") .build(); ) { String id = network.getId(); assertEquals( "Flag is set", "macvlan", DockerClientFactory.instance().client().inspectNetworkCmd().withNetworkId(id).exec().getDriver() ); } }
@Test public void testModifiers() throws Exception { try ( Network network = Network.builder() .createNetworkCmdModifier(cmd -> cmd.withDriver("macvlan")) .build(); ) { String id = network.getId(); assertEquals( "Flag is set", "macvlan", DockerClientFactory.instance().client().inspectNetworkCmd().withNetworkId(id).exec().getDriver() ); } }
@java.lang.SuppressWarnings("all") public com.github.dockerjava.api.command.InspectNetworkCmd inspectNetworkCmd() { return this.wrappedClient.inspectNetworkCmd(); }
@Override public InspectNetworkCmd inspectNetworkCmd() { return getDelegate().inspectNetworkCmd(); }
@Test public void network_should_be_start_with_driver_opts() { final Network app_net = dockerClient.inspectNetworkCmd().withNetworkId("app_net").exec(); assertThat(app_net.getOptions()).containsEntry("com.docker.network.enable_ipv6", "true"); }
@Test public void network_should_be_used_provided_ipam() { final Network app_net = dockerClient.inspectNetworkCmd().withNetworkId("app_net").exec(); assertThat(app_net.getIpam().getDriver()).isEqualTo("default"); assertThat(app_net.getIpam().getConfig()).extracting("subnet", "gateway") .contains(Tuple.tuple("172.16.238.0/24", "172.16.238.1"), Tuple.tuple("2001:3984:3989::/64", "2001:3984:3989::1")); }
@Test public void container_should_be_attached_to_back_network() { final InspectContainerResponse pingpong = dockerClient.inspectContainerCmd("pingpong").exec(); final Network front = dockerClient.inspectNetworkCmd().withNetworkId("back").exec(); assertThat(front.getContainers()).containsOnlyKeys(pingpong.getId()); }
@Test public void container_should_be_attached_to_front_network() { final InspectContainerResponse pingpong = dockerClient.inspectContainerCmd("pingpong").exec(); final Network front = dockerClient.inspectNetworkCmd().withNetworkId("front").exec(); assertThat(front.getContainers()).containsOnlyKeys(pingpong.getId()); }