@Test(dependsOnMethods = "testAssociateWithOptions") public void testAssociate() { associationId = routeTableApi.associateRouteTable(TEST_REGION, routeTable.id(), subnet.getSubnetId()); assertNotNull(associationId, "Failed to obtain association id for " + routeTable.id() + " and " + subnet.getSubnetId()); routeTable = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList().get(0); assertEquals(routeTable.associationSet().size(), 1, "Could not find expected association in routeTable " + routeTable.id()); }
@Test(dependsOnMethods = "testDescribe") public void testCreateWithOptions() { try { routeTableApi.createRouteTable(TEST_REGION, vpc.id(), dryRun()); Assert.fail("Expected 'DryRunOperation' exception was not thrown"); } catch (AWSResponseException e) { assertDryRun(e); } }
@Test(dependsOnMethods = "testDeleteRouteTableWithOptions") public void testDeleteRouteTable() { final ImmutableList<RouteTable> before = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList(); assertEquals(before.size(), 1, "Unexpected response to describe of " + routeTable.id() + ": " + before); assertEquals(before.get(0).id(), routeTable.id(), "Wrong table returned for " + routeTable.id() + ": " + before); final boolean deleted = routeTableApi.deleteRouteTable(TEST_REGION, routeTable.id()); assertTrue(deleted, "Failed to delete route table " + routeTable.id()); final ImmutableList<RouteTable> after = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList(); assertEquals(after.size(), 0, "Unexpected response to describe after deleting " + routeTable.id() + ": " + after); }
@Test(dependsOnMethods = "testDisassociateWithOptions") public void testDisassociate() { final boolean result = routeTableApi.disassociateRouteTable(TEST_REGION, associationId); assertTrue(result, "Failed to disassociate " + associationId + " from " + routeTable.id()); routeTable = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList().get(0); assertEquals(routeTable.associationSet().size(), 0, "Found associations where none should exist in " + routeTable.id() + ": " + routeTable.associationSet()); subnetApi.deleteSubnetInRegion(TEST_REGION, subnet.getSubnetId()); }
@Test(dependsOnMethods = "testCreate") public void testCreateRoute() { // If you attach an Internet Gateway, Network Interface, or Virtual Private Gateway to the VPC // you can then add a route through it to the route table. Issue a CreateRoute request specifying // the gateway (or network interface id etc.) to route through, and supplying the CIDR range that should // be routed through it. This can be any CIDR. gateway = gwApi.createInternetGateway(TEST_REGION, InternetGatewayOptions.NONE); assertNotNull(gateway, "Gateway was not successfully created"); final Boolean attached = gwApi.attachInternetGateway(TEST_REGION, gateway.id(), vpc.id()); assertTrue(attached, "Gateway " + gateway.id() + " failed to attach to VPC " + vpc.id()); final boolean created = routeTableApi.createRoute(TEST_REGION, routeTable.id(), gatewayId(gateway.id()) .destinationCidrBlock(TEST_DESTINATION_CIDR)); assertTrue(created, "Failed to add route to table " + routeTable.id()); final ImmutableList<RouteTable> routeTables = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList(); assertEquals(routeTables.size(), 1, "Could not find existing route table " + routeTable.id()); Optional<Route> optRoute = Iterables.tryFind(routeTables.get(0).routeSet(), new Predicate<Route>() { @Override public boolean apply(Route route) { return route.gatewayId().equals(gateway.id()); } }); assertTrue(optRoute.isPresent(), "Could not find route added to gateway " + gateway.id()); Route route = optRoute.get(); assertEquals(route.destinationCidrBlock(), TEST_DESTINATION_CIDR, "CIDR routed through " + gateway.id() + " does not match specification " + TEST_DESTINATION_CIDR); }
@Test(dependsOnMethods = "testCreate") public void testAssociateWithOptions() { subnet = subnetApi.createSubnetInRegion(TEST_REGION, vpc.id(), VPC_SUBNET); assertNotNull(subnet, "Failed to create subnet in " + vpc.id()); try { routeTableApi.associateRouteTable(TEST_REGION, routeTable.id(), subnet.getSubnetId(), dryRun()); Assert.fail("Expected 'DryRunOperation' exception was not thrown"); } catch (AWSResponseException e) { assertDryRun(e); } }
public void describeRouteTablesWithInvalidStateValue() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/describe_route_tables_invalid.xml"); final ImmutableList<RouteTable> routeTables = routeTableApi().describeRouteTables(DEFAULT_REGION).toList(); assertNotNull(routeTables, "Failed to create route table description object"); assertEquals(routeTables.size(), 1, "Failed to return expected entry from test data, returned: " + routeTables); assertEquals(routeTables.get(0).routeSet().get(0).state(), Route.RouteState.UNRECOGNIZED); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DescribeRouteTables"); }
@Test(dependsOnMethods = "testDeleteRoute") public void testDeleteRouteTableWithOptions() { try { routeTableApi.deleteRouteTable(TEST_REGION, routeTable.id(), dryRun()); Assert.fail("Expected 'DryRunOperation' exception was not thrown"); } catch (AWSResponseException e) { assertDryRun(e); } }
@Test(dependsOnMethods = "testAssociate") public void testDisassociateWithOptions() { try { routeTableApi.disassociateRouteTable(TEST_REGION, associationId, dryRun()); Assert.fail("Expected 'DryRunOperation' exception was not thrown"); } catch (AWSResponseException e) { assertDryRun(e); } }
@Test(dependsOnMethods = "testCreateRoute") public void testDeleteRoute() { final boolean deleted = routeTableApi.deleteRoute(TEST_REGION, routeTable.id(), destinationCidrBlock(TEST_DESTINATION_CIDR)); assertTrue(deleted, "Failed to delete " + TEST_DESTINATION_CIDR + " route from route table " + routeTable.id()); // clean up the test gateway final Boolean cleaned = gwApi.detachInternetGateway(TEST_REGION, gateway.id(), vpc.id()); assertTrue(cleaned, "Failed to delete gateway " + gateway.id()); final boolean gatewayDeleted = gwApi.deleteInternetGateway(TEST_REGION, gateway.id()); assertTrue(gatewayDeleted, "Failed to delete test gateway " + gateway.id()); }
public void createRouteNotFound() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/create_route.xml"); final boolean created = routeTableApi().createRoute(DEFAULT_REGION, "rtb-a77f2ac0", gatewayId("igw-97e68af3").destinationCidrBlock("172.18.19.0/24")); assertTrue(created, "Failed to match 'true' in test data response"); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=CreateRoute&RouteTableId=rtb-a77f2ac0&GatewayId=igw-97e68af3&DestinationCidrBlock=172.18.19.0/24"); }
public void replaceRouteNotFound() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/replace_route.xml"); final boolean created = routeTableApi().replaceRoute(DEFAULT_REGION, "rtb-a77f2ac0", gatewayId("vgw-1d00376e").destinationCidrBlock("172.18.19.0/24")); assertTrue(created, "Failed to match 'true' in test data response"); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=ReplaceRoute&RouteTableId=rtb-a77f2ac0&GatewayId=vgw-1d00376e&DestinationCidrBlock=172.18.19.0/24"); }
public void associateRouteTable() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/associate_route_table.xml"); final String associationId = routeTableApi().associateRouteTable(DEFAULT_REGION, "rtb-8c95c0eb", "subnet-6986410e"); assertEquals(associationId, "rtbassoc-fb7fed9d", "Failed to associate route"); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=AssociateRouteTable&RouteTableId=rtb-8c95c0eb&SubnetId=subnet-6986410e"); }
public void describeRouteTables() throws Exception { enqueueRegions(DEFAULT_REGION); enqueue(DEFAULT_REGION, new MockResponse().setResponseCode(404)); final ImmutableList<RouteTable> routeTables = routeTableApi().describeRouteTables(DEFAULT_REGION).toList(); assertTrue(routeTables.isEmpty(), "Returned " + routeTables.size() + " results for 404 response: " + routeTables); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DescribeRouteTables"); }
public void deleteRouteTable() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/delete_route_table.xml"); final boolean deleted = routeTableApi().deleteRouteTable(DEFAULT_REGION, "rtb-8bda6cef"); assertTrue(deleted, "Failed to match 'true' data in test response"); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DeleteRouteTable&RouteTableId=rtb-8bda6cef"); }
public void disassociateRouteTable() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/disassociate_route_table.xml"); final boolean result = routeTableApi().disassociateRouteTable(DEFAULT_REGION, "rtbassoc-fb7fed9d"); assertTrue(result, "Failed to disassociate route"); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DisassociateRouteTable&AssociationId=rtbassoc-fb7fed9d"); }
public void deleteRoute() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/delete_route.xml"); final boolean deleted = routeTableApi().deleteRoute(DEFAULT_REGION, "rtb-a77f2ac0", destinationCidrBlock("172.18.19.0/24")); assertTrue(deleted, "Failed to match 'true' in test data response"); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DeleteRoute&RouteTableId=rtb-a77f2ac0&DestinationCidrBlock=172.18.19.0/24"); }
public void createRoute() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/create_route.xml"); final boolean created = routeTableApi().createRoute(DEFAULT_REGION, "rtb-a77f2ac0", gatewayId("igw-97e68af3").destinationCidrBlock("172.18.19.0/24")); assertTrue(created, "Failed to match 'true' in test data response"); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=CreateRoute&RouteTableId=rtb-a77f2ac0&GatewayId=igw-97e68af3&DestinationCidrBlock=172.18.19.0/24"); }
public void replaceRoute() throws Exception { enqueueRegions(DEFAULT_REGION); enqueue(DEFAULT_REGION, new MockResponse().setResponseCode(404)); final boolean created = routeTableApi().replaceRoute(DEFAULT_REGION, "rtb-a77f2ac0", gatewayId("vgw-1d00376e").destinationCidrBlock("172.18.19.0/24")); assertFalse(created, "Reported successful replace of route in non-existent route table"); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=ReplaceRoute&RouteTableId=rtb-a77f2ac0&GatewayId=vgw-1d00376e&DestinationCidrBlock=172.18.19.0/24"); }
public void associateRouteTableNotFound() throws Exception { enqueueRegions(DEFAULT_REGION); enqueue(DEFAULT_REGION, new MockResponse().setResponseCode(404)); final String associationId = routeTableApi().associateRouteTable(DEFAULT_REGION, "rtb-8c95c0eb", "subnet-6986410e"); assertNull(associationId, "Returned id for non-existent route table: " + associationId); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=AssociateRouteTable&RouteTableId=rtb-8c95c0eb&SubnetId=subnet-6986410e"); }