@Test(dependsOnMethods = "testCreateNetwork") public void testGetNetwork() { network = api().inspectNetwork(network.id()); assertNotNull(network); }
@Test(dependsOnMethods = "testDisconnectContainerFromNetwork") public void testRemoveNetwork() { api().removeNetwork(network.id()); assertNull(api().inspectNetwork(network.id())); network = null; }
public void testGetNetwork() throws Exception { MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/network.json"))); NetworkApi api = api(DockerApi.class, server.getUrl("/").toString(), new DockerParserModule()).getNetworkApi(); String networkId = "b03d4cd15b76f8876110615cdeed15eadf77c9beb408d62f1687dcc69192cd6d"; try { assertEquals(api.inspectNetwork(networkId), new NetworkParseTest().expected()); assertSent(server, "GET", "/networks/" + networkId); } finally { server.shutdown(); } }
@AfterClass(alwaysRun = true) protected void tearDown() { if (guest != null) { adapter.destroyNode(guest.getNode().id() + ""); } if (api.getImageApi().inspectImage(CHUANWEN_COWSAY) != null) { api.getImageApi().deleteImage(CHUANWEN_COWSAY); } if (api.getNetworkApi().inspectNetwork("network1") != null) { api.getNetworkApi().removeNetwork("network1"); } if (api.getNetworkApi().inspectNetwork("network2") != null) { api.getNetworkApi().removeNetwork("network2"); } super.tearDown(); }
/** * Creates network (driver="bridge") with given name and then inspects it to * fully populate the returned {@link Network} object. * * @param networkName */ private Network createAndInspectNetwork(final String networkName) { final NetworkApi networkApi = api.getNetworkApi(); Network network = networkApi.createNetwork(Network.builder().name(networkName).driver("bridge").build()); return networkApi.inspectNetwork(network.id()); } }