Search in sources :

Example 86 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class EC2ComponentSpringTest method startInstances.

@Test
public void startInstances() {
    Exchange exchange = template.request("direct:start", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Collection l = new ArrayList();
            l.add("test-1");
            exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
        }
    });
    StartInstancesResult resultGet = (StartInstancesResult) exchange.getOut().getBody();
    assertEquals(resultGet.getStartingInstances().get(0).getInstanceId(), "test-1");
    assertEquals(resultGet.getStartingInstances().get(0).getPreviousState().getName(), InstanceStateName.Stopped.toString());
    assertEquals(resultGet.getStartingInstances().get(0).getCurrentState().getName(), InstanceStateName.Running.toString());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) StartInstancesResult(com.amazonaws.services.ec2.model.StartInstancesResult) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Test(org.junit.Test)

Example 87 with ArrayList

use of java.util.ArrayList 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);
}
Also used : Exchange(org.apache.camel.Exchange) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) Processor(org.apache.camel.Processor) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Test(org.junit.Test)

Example 88 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class EC2ProducerTest method ec2TerminateTest.

@Test
public void ec2TerminateTest() throws Exception {
    mock.expectedMessageCount(1);
    Exchange exchange = template.request("direct:terminate", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Collection l = new ArrayList();
            l.add("test-1");
            exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
        }
    });
    assertMockEndpointsSatisfied();
    TerminateInstancesResult resultGet = (TerminateInstancesResult) exchange.getIn().getBody();
    assertEquals(resultGet.getTerminatingInstances().get(0).getInstanceId(), "test-1");
    assertEquals(resultGet.getTerminatingInstances().get(0).getPreviousState().getName(), InstanceStateName.Running.toString());
    assertEquals(resultGet.getTerminatingInstances().get(0).getCurrentState().getName(), InstanceStateName.Terminated.toString());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) ArrayList(java.util.ArrayList) Collection(java.util.Collection) TerminateInstancesResult(com.amazonaws.services.ec2.model.TerminateInstancesResult) Test(org.junit.Test)

Example 89 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class EC2ProducerTest method ec2RebootInstancesTest.

@Test
public void ec2RebootInstancesTest() throws Exception {
    mock.expectedMessageCount(1);
    Exchange exchange = template.request("direct:reboot", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Collection l = new ArrayList();
            l.add("test-1");
            exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
        }
    });
    assertMockEndpointsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Test(org.junit.Test)

Example 90 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class EC2ProducerTest method ec2MonitorInstancesTest.

@Test
public void ec2MonitorInstancesTest() throws Exception {
    mock.expectedMessageCount(1);
    Exchange exchange = template.request("direct:monitor", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Collection l = new ArrayList();
            l.add("test-1");
            exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
        }
    });
    assertMockEndpointsSatisfied();
    MonitorInstancesResult resultGet = (MonitorInstancesResult) exchange.getIn().getBody();
    assertEquals(resultGet.getInstanceMonitorings().size(), 1);
    assertEquals(resultGet.getInstanceMonitorings().get(0).getInstanceId(), "test-1");
    assertEquals(resultGet.getInstanceMonitorings().get(0).getMonitoring().getState(), MonitoringState.Enabled.toString());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) ArrayList(java.util.ArrayList) Collection(java.util.Collection) MonitorInstancesResult(com.amazonaws.services.ec2.model.MonitorInstancesResult) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)55702 Test (org.junit.Test)8169 List (java.util.List)6815 HashMap (java.util.HashMap)5856 IOException (java.io.IOException)3899 Map (java.util.Map)3195 File (java.io.File)3090 HashSet (java.util.HashSet)2245 Iterator (java.util.Iterator)1591 Test (org.testng.annotations.Test)1074 SQLException (java.sql.SQLException)1046 ResultSet (java.sql.ResultSet)1017 Date (java.util.Date)997 Set (java.util.Set)917 LinkedHashMap (java.util.LinkedHashMap)886 PreparedStatement (java.sql.PreparedStatement)882 Collection (java.util.Collection)751 LinkedList (java.util.LinkedList)677 BufferedReader (java.io.BufferedReader)663 Path (org.apache.hadoop.fs.Path)611