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"); }
@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); }
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"); }