use of org.apache.camel.component.reactive.streams.util.UnwrapStreamProcessor in project camel by apache.
the class BeanCallTest method beanCallStdReturnTypeTest.
@Test
public void beanCallStdReturnTypeTest() throws Exception {
new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(Throwable.class).to("direct:handle").handled(true);
from("direct:num").bean(BeanCallTest.this, "processBodyStd").process(// Can be removed?
new UnwrapStreamProcessor()).to("mock:endpoint");
from("direct:handle").setBody().constant("ERR").to("mock:endpoint");
}
}.addRoutesToCamelContext(context);
MockEndpoint mock = getMockEndpoint("mock:endpoint");
mock.expectedMessageCount(1);
context.start();
template.sendBody("direct:num", 1);
mock.assertIsSatisfied();
Exchange exchange = mock.getExchanges().get(0);
Object body = exchange.getIn().getBody();
assertEquals("Hello", body);
}
use of org.apache.camel.component.reactive.streams.util.UnwrapStreamProcessor in project camel by apache.
the class BeanCallTest method beanCallTwoElementsTest.
@Test
public void beanCallTwoElementsTest() throws Exception {
new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(Throwable.class).to("direct:handle").handled(true);
from("direct:num").bean(BeanCallTest.this, "processBodyTwoItems").process(// Can be removed?
new UnwrapStreamProcessor()).to("mock:endpoint");
from("direct:handle").setBody().constant("ERR").to("mock:endpoint");
}
}.addRoutesToCamelContext(context);
MockEndpoint mock = getMockEndpoint("mock:endpoint");
mock.expectedMessageCount(1);
context.start();
template.sendBody("direct:num", 1);
mock.assertIsSatisfied();
Exchange exchange = mock.getExchanges().get(0);
Object body = exchange.getIn().getBody();
assertTrue(body instanceof Collection);
@SuppressWarnings("unchecked") List<String> data = new LinkedList<>((Collection<String>) body);
assertListSize(data, 2);
assertEquals("HelloBody 1", data.get(0));
assertEquals("HelloBody 1", data.get(1));
}
Aggregations