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));
}
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()));
}
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);
}
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);
}
}
}
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()]);
}
Aggregations