use of java.util.List in project camel by apache.
the class CassandraComponentConsumerTest method testConsumeAll.
@Test
public void testConsumeAll() throws Exception {
if (!canTest()) {
return;
}
MockEndpoint mock = getMockEndpoint("mock:resultAll");
mock.expectedMinimumMessageCount(1);
mock.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Object body = exchange.getIn().getBody();
assertTrue(body instanceof List);
}
});
mock.await(1, TimeUnit.SECONDS);
assertMockEndpointsSatisfied();
}
use of java.util.List in project camel by apache.
the class CxfClientCallback method handleException.
public void handleException(Map<String, Object> ctx, Throwable ex) {
try {
super.handleException(ctx, ex);
// need to call the conduitSelector complete method to enable the fail over feature
ConduitSelector conduitSelector = cxfExchange.get(ConduitSelector.class);
if (conduitSelector != null) {
conduitSelector.complete(cxfExchange);
ex = cxfExchange.getOutMessage().getContent(Exception.class);
if (ex == null && cxfExchange.getInMessage() != null) {
ex = cxfExchange.getInMessage().getContent(Exception.class);
}
if (ex != null) {
camelExchange.setException(ex);
}
} else {
camelExchange.setException(ex);
}
} finally {
// add cookies to the cookie store
if (endpoint.getCookieHandler() != null) {
try {
Map<String, List<String>> cxfHeaders = CastUtils.cast((Map<?, ?>) cxfExchange.getInMessage().get(Message.PROTOCOL_HEADERS));
endpoint.getCookieHandler().storeCookies(camelExchange, endpoint.getRequestUri(camelExchange), cxfHeaders);
} catch (IOException e) {
LOG.error("Cannot store cookies", e);
}
}
// process method of org.apache.camel.component.cxf.CxfProducer
if (!boi.getOperationInfo().isOneWay()) {
endpoint.getCxfBinding().populateExchangeFromCxfResponse(camelExchange, cxfExchange, ctx);
camelAsyncCallback.done(false);
}
if (LOG.isDebugEnabled()) {
LOG.debug("{} calling handleException", Thread.currentThread().getName());
}
}
}
use of java.util.List in project camel by apache.
the class CxfHeaderHelperTest method testPropagateCamelToCxf.
@Test
public void testPropagateCamelToCxf() {
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setHeader("soapAction", "urn:hello:world");
exchange.getIn().setHeader("MyFruitHeader", "peach");
exchange.getIn().setHeader("MyBrewHeader", Arrays.asList("cappuccino", "espresso"));
exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "text/xml");
exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, "200");
exchange.getIn().setHeader(Exchange.HTTP_URI, "/hello/cxf");
exchange.getIn().setHeader(Exchange.HTTP_METHOD, "GET");
exchange.getIn().setHeader(Exchange.HTTP_PATH, "/hello/cxf");
Map<String, Object> requestContext = Collections.singletonMap("request", "true");
Map<String, Object> responseContext = Collections.singletonMap("response", "true");
exchange.getIn().setHeader(Client.REQUEST_CONTEXT, requestContext);
exchange.getIn().setHeader(Client.RESPONSE_CONTEXT, responseContext);
org.apache.cxf.message.Message cxfMessage = new org.apache.cxf.message.MessageImpl();
CxfHeaderHelper.propagateCamelToCxf(new DefaultHeaderFilterStrategy(), exchange.getIn().getHeaders(), cxfMessage, exchange);
assertEquals("text/xml", cxfMessage.get(Message.CONTENT_TYPE));
assertEquals("200", cxfMessage.get(Message.RESPONSE_CODE));
assertEquals(requestContext, cxfMessage.get(Client.REQUEST_CONTEXT));
assertEquals(responseContext, cxfMessage.get(Client.RESPONSE_CONTEXT));
assertNull(cxfMessage.get(Exchange.HTTP_RESPONSE_CODE));
// check the protocol headers
Map<String, List<String>> cxfHeaders = CastUtils.cast((Map<?, ?>) cxfMessage.get(org.apache.cxf.message.Message.PROTOCOL_HEADERS));
assertNotNull(cxfHeaders);
assertTrue(cxfHeaders.size() == 7);
verifyHeader(cxfHeaders, "soapaction", "urn:hello:world");
verifyHeader(cxfHeaders, "SoapAction", "urn:hello:world");
verifyHeader(cxfHeaders, "SOAPAction", "urn:hello:world");
verifyHeader(cxfHeaders, "myfruitheader", "peach");
verifyHeader(cxfHeaders, "myFruitHeader", "peach");
verifyHeader(cxfHeaders, "MYFRUITHEADER", "peach");
verifyHeader(cxfHeaders, "MyBrewHeader", Arrays.asList("cappuccino", "espresso"));
verifyHeader(cxfHeaders, Message.CONTENT_TYPE, "text/xml");
verifyHeader(cxfHeaders, Message.REQUEST_URI, "/hello/cxf");
verifyHeader(cxfHeaders, Message.HTTP_REQUEST_METHOD, "GET");
verifyHeader(cxfHeaders, Message.PATH_INFO, "/hello/cxf");
assertNull(cxfHeaders.get(Exchange.HTTP_RESPONSE_CODE));
assertNull(cxfHeaders.get(Exchange.HTTP_URI));
assertNull(cxfHeaders.get(Exchange.HTTP_METHOD));
assertNull(cxfHeaders.get(Exchange.HTTP_PATH));
}
use of java.util.List in project camel by apache.
the class CsvRouteTest method testUnMarshal.
@SuppressWarnings("unchecked")
@Test
public void testUnMarshal() throws Exception {
MockEndpoint endpoint = getMockEndpoint("mock:daltons");
endpoint.expectedMessageCount(1);
endpoint.assertIsSatisfied();
Exchange exchange = endpoint.getExchanges().get(0);
// START SNIPPET : unmarshalResult
List<List<String>> data = (List<List<String>>) exchange.getIn().getBody();
for (List<String> line : data) {
LOG.debug(String.format("%s has an IQ of %s and is currently %s", line.get(0), line.get(1), line.get(2)));
}
// END SNIPPET : unmarshalResult
}
use of java.util.List in project camel by apache.
the class CsvUnmarshalStreamSpringTest method testCsvUnMarshal.
@Test
public void testCsvUnMarshal() throws Exception {
line.expectedMessageCount(3);
template.sendBody("direct:start", CSV_SAMPLE);
assertMockEndpointsSatisfied();
List body1 = line.getExchanges().get(0).getIn().getBody(List.class);
List body2 = line.getExchanges().get(1).getIn().getBody(List.class);
List body3 = line.getExchanges().get(2).getIn().getBody(List.class);
assertEquals(Arrays.asList("A", "B", "C"), body1);
assertEquals(Arrays.asList("1", "2", "3"), body2);
assertEquals(Arrays.asList("one", "two", "three"), body3);
}
Aggregations