Search in sources :

Example 6 with CamelReactiveStreamsService

use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.

the class CamelReactiveStreamsTest method testSameServiceReturnedFromRegistry.

@Test
public void testSameServiceReturnedFromRegistry() {
    CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context);
    CamelReactiveStreamsService service2 = CamelReactiveStreams.get(context);
    assertEquals(service1, service2);
    assertTrue(service1 instanceof ReactiveStreamsTestService);
    assertEquals("from-registry", ((ReactiveStreamsTestService) service1).getName());
}
Also used : ReactiveStreamsTestService(org.apache.camel.component.reactive.streams.support.ReactiveStreamsTestService) CamelReactiveStreamsService(org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService) Test(org.junit.Test)

Example 7 with CamelReactiveStreamsService

use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.

the class CamelReactiveStreamsTest method testNamedServiceResolvedUsingFactory.

@Test
public void testNamedServiceResolvedUsingFactory() {
    CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context, "test-service");
    assertTrue(service1 instanceof ReactiveStreamsTestService);
    assertNull(((ReactiveStreamsTestService) service1).getName());
}
Also used : ReactiveStreamsTestService(org.apache.camel.component.reactive.streams.support.ReactiveStreamsTestService) CamelReactiveStreamsService(org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService) Test(org.junit.Test)

Example 8 with CamelReactiveStreamsService

use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.

the class CamelReactiveStreamsTest method testSameNamedServiceReturnedFromRegistry.

@Test
public void testSameNamedServiceReturnedFromRegistry() {
    CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context, "dummy");
    CamelReactiveStreamsService service2 = CamelReactiveStreams.get(context, "dummy");
    assertEquals(service1, service2);
    assertTrue(service1 instanceof ReactiveStreamsTestService);
    assertEquals("from-registry", ((ReactiveStreamsTestService) service1).getName());
}
Also used : ReactiveStreamsTestService(org.apache.camel.component.reactive.streams.support.ReactiveStreamsTestService) CamelReactiveStreamsService(org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService) Test(org.junit.Test)

Example 9 with CamelReactiveStreamsService

use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.

the class CamelReactiveStreamsTest method testSameDefaultServiceReturned.

@Test
public void testSameDefaultServiceReturned() {
    CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context, "default-service");
    CamelReactiveStreamsService service2 = CamelReactiveStreams.get(context, "default-service");
    assertTrue(service1 instanceof CamelReactiveStreamsServiceImpl);
    assertEquals(service1, service2);
}
Also used : CamelReactiveStreamsService(org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService) CamelReactiveStreamsServiceImpl(org.apache.camel.component.reactive.streams.engine.CamelReactiveStreamsServiceImpl) Test(org.junit.Test)

Example 10 with CamelReactiveStreamsService

use of org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService in project camel by apache.

the class AbstractPlatformTestSupport method testPublisher.

@Test
public void testPublisher() throws Exception {
    int num = 20;
    new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:endpoint").to("reactive-streams:integers");
        }
    }.addRoutesToCamelContext(context);
    CamelReactiveStreamsService camel = CamelReactiveStreams.get(context);
    List<Integer> elements = new LinkedList<>();
    CountDownLatch latch = new CountDownLatch(num);
    this.changeSign(camel.fromStream("integers", Integer.class), i -> {
        elements.add(i);
        latch.countDown();
    });
    context.start();
    for (int i = 1; i <= num; i++) {
        template.sendBody("direct:endpoint", i);
    }
    assertTrue(latch.await(5, TimeUnit.SECONDS));
    for (Integer number : elements) {
        assertTrue(number < 0);
    }
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) CamelReactiveStreamsService(org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService) CountDownLatch(java.util.concurrent.CountDownLatch) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

CamelReactiveStreamsService (org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService)10 Test (org.junit.Test)10 Exchange (org.apache.camel.Exchange)3 RouteBuilder (org.apache.camel.builder.RouteBuilder)3 ReactiveStreamsTestService (org.apache.camel.component.reactive.streams.support.ReactiveStreamsTestService)3 LinkedList (java.util.LinkedList)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 CamelReactiveStreamsServiceImpl (org.apache.camel.component.reactive.streams.engine.CamelReactiveStreamsServiceImpl)2 DefaultExchange (org.apache.camel.impl.DefaultExchange)2 Flowable (io.reactivex.Flowable)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 RoutesBuilder (org.apache.camel.RoutesBuilder)1 CamelReactiveStreams (org.apache.camel.component.reactive.streams.api.CamelReactiveStreams)1 CamelTestSupport (org.apache.camel.test.junit4.CamelTestSupport)1 Publisher (org.reactivestreams.Publisher)1