use of com.amazonaws.services.ec2.model.Instance in project camel by apache.
the class EC2ComponentSpringTest method createAndRunInstances.
@Test
public void createAndRunInstances() {
Exchange exchange = template.request("direct:createAndRun", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(EC2Constants.OPERATION, EC2Operations.createAndRunInstances);
exchange.getIn().setHeader(EC2Constants.IMAGE_ID, "test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MIN_COUNT, 1);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MAX_COUNT, 1);
}
});
RunInstancesResult resultGet = (RunInstancesResult) exchange.getOut().getBody();
assertEquals(resultGet.getReservation().getInstances().get(0).getImageId(), "test-1");
assertEquals(resultGet.getReservation().getInstances().get(0).getInstanceType(), InstanceType.T2Micro.toString());
assertEquals(resultGet.getReservation().getInstances().get(0).getInstanceId(), "instance-1");
}
use of com.amazonaws.services.ec2.model.Instance in project camel by apache.
the class EC2ComponentSpringTest method ec2DescribeSpecificInstancesTest.
@Test
public void ec2DescribeSpecificInstancesTest() throws Exception {
Exchange exchange = template.request("direct:describe", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Collection l = new ArrayList();
l.add("instance-1");
exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
}
});
DescribeInstancesResult resultGet = (DescribeInstancesResult) exchange.getOut().getBody();
assertEquals(resultGet.getReservations().size(), 1);
assertEquals(resultGet.getReservations().get(0).getInstances().size(), 1);
}
use of com.amazonaws.services.ec2.model.Instance in project camel by apache.
the class EC2ProducerTest method ec2CreateAndRunTest.
@Test
public void ec2CreateAndRunTest() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:createAndRun", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(EC2Constants.OPERATION, EC2Operations.createAndRunInstances);
exchange.getIn().setHeader(EC2Constants.IMAGE_ID, "test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MIN_COUNT, 1);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MAX_COUNT, 1);
}
});
assertMockEndpointsSatisfied();
RunInstancesResult resultGet = (RunInstancesResult) exchange.getIn().getBody();
assertEquals(resultGet.getReservation().getInstances().get(0).getImageId(), "test-1");
assertEquals(resultGet.getReservation().getInstances().get(0).getInstanceType(), InstanceType.T2Micro.toString());
assertEquals(resultGet.getReservation().getInstances().get(0).getInstanceId(), "instance-1");
}
use of com.amazonaws.services.ec2.model.Instance in project camel by apache.
the class EC2ProducerTest method ec2CreateAndRunTestWithKeyPair.
@Test
public void ec2CreateAndRunTestWithKeyPair() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:createAndRun", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(EC2Constants.OPERATION, EC2Operations.createAndRunInstances);
exchange.getIn().setHeader(EC2Constants.IMAGE_ID, "test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MIN_COUNT, 1);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MAX_COUNT, 1);
exchange.getIn().setHeader(EC2Constants.INSTANCES_KEY_PAIR, "keypair-1");
}
});
assertMockEndpointsSatisfied();
RunInstancesResult resultGet = (RunInstancesResult) exchange.getIn().getBody();
assertEquals(resultGet.getReservation().getInstances().get(0).getImageId(), "test-1");
assertEquals(resultGet.getReservation().getInstances().get(0).getInstanceType(), InstanceType.T2Micro.toString());
assertEquals(resultGet.getReservation().getInstances().get(0).getInstanceId(), "instance-1");
assertEquals(resultGet.getReservation().getInstances().get(0).getSecurityGroups().size(), 2);
assertEquals(resultGet.getReservation().getInstances().get(0).getSecurityGroups().get(0).getGroupId(), "id-3");
assertEquals(resultGet.getReservation().getInstances().get(0).getSecurityGroups().get(1).getGroupId(), "id-4");
}
use of com.amazonaws.services.ec2.model.Instance in project camel by apache.
the class EC2ProducerTest method ec2CreateAndRunTestWithSecurityGroups.
@Test
public void ec2CreateAndRunTestWithSecurityGroups() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:createAndRun", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(EC2Constants.OPERATION, EC2Operations.createAndRunInstances);
exchange.getIn().setHeader(EC2Constants.IMAGE_ID, "test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MIN_COUNT, 1);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MAX_COUNT, 1);
Collection<String> secGroups = new ArrayList<String>();
secGroups.add("secgroup-1");
secGroups.add("secgroup-2");
exchange.getIn().setHeader(EC2Constants.INSTANCE_SECURITY_GROUPS, secGroups);
}
});
assertMockEndpointsSatisfied();
RunInstancesResult resultGet = (RunInstancesResult) exchange.getIn().getBody();
assertEquals(resultGet.getReservation().getInstances().get(0).getImageId(), "test-1");
assertEquals(resultGet.getReservation().getInstances().get(0).getInstanceType(), InstanceType.T2Micro.toString());
assertEquals(resultGet.getReservation().getInstances().get(0).getInstanceId(), "instance-1");
assertEquals(resultGet.getReservation().getInstances().get(0).getSecurityGroups().size(), 2);
assertEquals(resultGet.getReservation().getInstances().get(0).getSecurityGroups().get(0).getGroupId(), "id-1");
assertEquals(resultGet.getReservation().getInstances().get(0).getSecurityGroups().get(1).getGroupId(), "id-2");
}
Aggregations