use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.
the class ExchangeRequestTest method testMultipleInteractions.
@Test
public void testMultipleInteractions() throws Exception {
CamelReactiveStreamsService camel = CamelReactiveStreams.get(context);
Integer sum = Flowable.just(1, 2, 3).flatMap(e -> camel.toStream("plusOne", e, Integer.class)).reduce((i, j) -> i + j).blockingGet();
assertNotNull(sum);
assertEquals(9, sum.intValue());
}
use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.
the class ExchangeRequestTest method testStreamRequest.
@Test
public void testStreamRequest() throws Exception {
CamelReactiveStreamsService camel = CamelReactiveStreams.get(context);
Publisher<Exchange> string = camel.toStream("data", new DefaultExchange(context));
Exchange res = Flowable.fromPublisher(string).blockingFirst();
assertNotNull(res);
String content = res.getIn().getBody(String.class);
assertNotNull(content);
assertEquals("123", content);
}
use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.
the class ExchangeRequestTest method testInteraction.
@Test
public void testInteraction() throws Exception {
CamelReactiveStreamsService camel = CamelReactiveStreams.get(context);
Integer res = Flowable.fromPublisher(camel.toStream("plusOne", 1L, Integer.class)).blockingFirst();
assertNotNull(res);
assertEquals(2, res.intValue());
}
use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.
the class AbstractPlatformTestSupport method testSubscriber.
@Test
public void testSubscriber() throws Exception {
int num = 20;
new RouteBuilder() {
@Override
public void configure() throws Exception {
from("reactive-streams:integers").to("mock:endpoint");
}
}.addRoutesToCamelContext(context);
CamelReactiveStreamsService camel = CamelReactiveStreams.get(context);
List<Integer> elements = new LinkedList<>();
for (int i = 1; i <= num; i++) {
elements.add(i);
}
changeSign(elements, camel.streamSubscriber("integers", Integer.class));
context.start();
MockEndpoint mock = getMockEndpoint("mock:endpoint");
mock.expectedMessageCount(num);
mock.assertIsSatisfied();
for (Exchange ex : mock.getExchanges()) {
Integer number = ex.getIn().getBody(Integer.class);
assertNotNull(number);
assertTrue(number < 0);
}
}
use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.
the class CamelReactiveStreamsTest method testDefaultService.
@Test
public void testDefaultService() {
CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context, "default-service");
assertTrue(service1 instanceof CamelReactiveStreamsServiceImpl);
}
Aggregations