for (String zone : api.getConfiguredZones()) {
RouterApi routerApi = api.getRouterExtensionForZone(zone).get();
NetworkApi networkApi = api.getNetworkApiForZone(zone);
SubnetApi subnetApi = api.getSubnetApiForZone(zone);
Network network = networkApi.create(CreateNetworkOptions.builder().name("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
assertNotNull(network);
Subnet subnet = subnetApi.create(network.getId(), 4, "192.168.0.0/16");
assertNotNull(subnet);
Router ref = routerApi.create(CreateRouterOptions.builder().name("jclouds-router-test")
.externalGatewayInfo(ExternalGatewayInfo.builder().networkId(network.getId()).build()).build());
assertNotNull(ref);
Router router = routerApi.get(ref.getId());
assertEquals(router.getId(), ref.getId());
assertEquals(router.getName(), "jclouds-router-test");
assertEquals(router.getExternalGatewayInfo().getNetworkId(), network.getId());
assertTrue(routerApi.update(router.getId(), UpdateRouterOptions.builder().name("jclouds-router-test-rename").build()));
router = routerApi.get(ref.getId());
assertEquals(router.getId(), ref.getId());
assertEquals(router.getName(), "jclouds-router-test-rename");
ReferenceWithName ref2 = routerApi.create(CreateRouterOptions.builder().name("jclouds-router-test2")
.externalGatewayInfo(ExternalGatewayInfo.builder().networkId(network.getId()).build()).build());
assertNotNull(ref2);
assertTrue(routerApi.delete(ref.getId()));
assertTrue(routerApi.delete(ref2.getId()));
assertTrue(subnetApi.delete(subnet.getId()));
assertTrue(networkApi.delete(network.getId()));
}
}