Search in sources :

Example 76 with ArrayList

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

the class SimpleTest method testListRemoveByInstance.

public void testListRemoveByInstance() throws Exception {
    List<Object> data = new ArrayList<Object>();
    data.add("A");
    data.add("B");
    exchange.getIn().setBody(data);
    assertEquals(2, data.size());
    Expression expression = SimpleLanguage.simple("${body.remove('A')}");
    expression.evaluate(exchange, Object.class);
    assertEquals(1, data.size());
    assertEquals("B", data.get(0));
}
Also used : Expression(org.apache.camel.Expression) ArrayList(java.util.ArrayList)

Example 77 with ArrayList

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

the class RemoveRouteDefinitionTest method testStopRoute.

public void testStopRoute() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }
    MBeanServer mbeanServer = getMBeanServer();
    Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
    assertEquals(1, set.size());
    ObjectName on = set.iterator().next();
    boolean registered = mbeanServer.isRegistered(on);
    assertEquals("Should be registered", true, registered);
    RouteDefinition definition = context.getRouteDefinition("route1");
    List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
    routeDefinitions.add(definition);
    context.stopRoute("route1");
    // route is only stopped so its still in JMX
    set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
    assertEquals(1, set.size());
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition) ArrayList(java.util.ArrayList) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 78 with ArrayList

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

the class RemoveRouteDefinitionTest method testShutdownRoute.

@SuppressWarnings("deprecation")
public void testShutdownRoute() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }
    MBeanServer mbeanServer = getMBeanServer();
    Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
    assertEquals(1, set.size());
    ObjectName on = set.iterator().next();
    boolean registered = mbeanServer.isRegistered(on);
    assertEquals("Should be registered", true, registered);
    RouteDefinition definition = context.getRouteDefinition("route1");
    List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
    routeDefinitions.add(definition);
    context.shutdownRoute("route1");
    // route is shutdown (= also removed), so its not longer in JMX
    set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
    assertEquals(0, set.size());
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition) ArrayList(java.util.ArrayList) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 79 with ArrayList

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

the class RemoveRouteDefinitionTest method testStopAndRemoveRoute.

public void testStopAndRemoveRoute() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }
    MBeanServer mbeanServer = getMBeanServer();
    Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
    assertEquals(1, set.size());
    ObjectName on = set.iterator().next();
    boolean registered = mbeanServer.isRegistered(on);
    assertEquals("Should be registered", true, registered);
    RouteDefinition definition = context.getRouteDefinition("route1");
    List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
    routeDefinitions.add(definition);
    // must stop before we can remove
    context.stopRoute("route1");
    context.removeRoute("route1");
    // route is removed, so its not longer in JMX
    set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
    assertEquals(0, set.size());
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition) ArrayList(java.util.ArrayList) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 80 with ArrayList

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

the class AhcProducerTwoParametersWithSameKeyTest method testTwoHeadersWithSameKeyHeader.

@Test
public void testTwoHeadersWithSameKeyHeader() throws Exception {
    Exchange out = template.request("ahc:http://localhost:{{port}}/myapp", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody(null);
            exchange.getIn().setHeader("from", "me");
            List<String> list = new ArrayList<String>();
            list.add("foo");
            list.add("bar");
            exchange.getIn().setHeader("to", list);
        }
    });
    assertNotNull(out);
    assertFalse("Should not fail", out.isFailed());
    assertEquals("OK", out.getOut().getBody(String.class));
    assertEquals("yes", out.getOut().getHeader("bar"));
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) List(java.util.List) ArrayList(java.util.ArrayList) 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