Search in sources :

Example 46 with ArrayList

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

the class EndpointHelperTest method testPollEndpointTimeout.

public void testPollEndpointTimeout() throws Exception {
    template.sendBody("seda:foo", "Hello World");
    template.sendBody("seda:foo", "Bye World");
    final List<String> bodies = new ArrayList<String>();
    EndpointHelper.pollEndpoint(context.getEndpoint("seda:foo"), new Processor() {

        public void process(Exchange exchange) throws Exception {
            bodies.add(exchange.getIn().getBody(String.class));
        }
    }, 2000);
    assertEquals(2, bodies.size());
    assertEquals("Hello World", bodies.get(0));
    assertEquals("Bye World", bodies.get(1));
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) ArrayList(java.util.ArrayList)

Example 47 with ArrayList

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

the class ExchangeHelperTest method testGetExchangeById.

public void testGetExchangeById() throws Exception {
    List<Exchange> list = new ArrayList<Exchange>();
    Exchange e1 = context.getEndpoint("mock:foo").createExchange();
    Exchange e2 = context.getEndpoint("mock:foo").createExchange();
    list.add(e1);
    list.add(e2);
    assertNull(ExchangeHelper.getExchangeById(list, "unknown"));
    assertEquals(e1, ExchangeHelper.getExchangeById(list, e1.getExchangeId()));
    assertEquals(e2, ExchangeHelper.getExchangeById(list, e2.getExchangeId()));
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) ArrayList(java.util.ArrayList)

Example 48 with ArrayList

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

the class ExpressionListComparatorTest method testExpressionListComparator.

public void testExpressionListComparator() {
    List<Expression> list = new ArrayList<Expression>();
    list.add(new MyFooExpression());
    list.add(new MyBarExpression());
    ExpressionListComparator comp = new ExpressionListComparator(list);
    Exchange e1 = new DefaultExchange(context);
    Exchange e2 = new DefaultExchange(context);
    int out = comp.compare(e1, e2);
    assertEquals(0, out);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Expression(org.apache.camel.Expression) ArrayList(java.util.ArrayList)

Example 49 with ArrayList

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

the class CwProducer method setDimension.

private void setDimension(MetricDatum metricDatum, Exchange exchange) {
    String name = exchange.getIn().getHeader(CwConstants.METRIC_DIMENSION_NAME, String.class);
    String value = exchange.getIn().getHeader(CwConstants.METRIC_DIMENSION_VALUE, String.class);
    if (name != null && value != null) {
        metricDatum.withDimensions(new Dimension().withName(name).withValue(value));
    } else {
        Map<String, String> dimensions = exchange.getIn().getHeader(CwConstants.METRIC_DIMENSIONS, Map.class);
        if (dimensions != null) {
            Collection<Dimension> dimensionCollection = new ArrayList<Dimension>();
            for (Map.Entry<String, String> dimensionEntry : dimensions.entrySet()) {
                Dimension dimension = new Dimension().withName(dimensionEntry.getKey()).withValue(dimensionEntry.getValue());
                dimensionCollection.add(dimension);
            }
            metricDatum.withDimensions(dimensionCollection);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Dimension(com.amazonaws.services.cloudwatch.model.Dimension) Map(java.util.Map)

Example 50 with ArrayList

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

the class BlueprintPropertiesParser method lookupPropertyPlaceholderIds.

/**
     * Lookup the ids of the Blueprint property placeholder services in the
     * Blueprint container.
     *
     * @return the ids, will be an empty array if none found.
     */
public String[] lookupPropertyPlaceholderIds() {
    List<String> ids = new ArrayList<String>();
    for (Object componentId : container.getComponentIds()) {
        String id = (String) componentId;
        ComponentMetadata meta = container.getComponentMetadata(id);
        if (meta instanceof ExtendedBeanMetadata) {
            Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
            if (clazz != null && AbstractPropertyPlaceholder.class.isAssignableFrom(clazz)) {
                ids.add(id);
            }
        }
    }
    return ids.toArray(new String[ids.size()]);
}
Also used : ExtendedBeanMetadata(org.apache.aries.blueprint.ExtendedBeanMetadata) ArrayList(java.util.ArrayList) AbstractPropertyPlaceholder(org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata)

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