use of org.apache.camel.component.reactive.streams.engine.DelayedMonoPublisher in project camel by apache.
the class DelayedMonoPublisherTest method testAvailableLater.
@Test
public void testAvailableLater() throws Exception {
DelayedMonoPublisher<Integer> pub = new DelayedMonoPublisher<>(service);
LinkedList<Integer> data = new LinkedList<>();
CountDownLatch latch = new CountDownLatch(1);
Flowable.fromPublisher(pub).doOnNext(data::add).doOnComplete(latch::countDown).subscribe();
Thread.sleep(200);
pub.setData(5);
assertTrue(latch.await(1, TimeUnit.SECONDS));
assertEquals(1, data.size());
assertEquals(5, data.get(0).intValue());
}
use of org.apache.camel.component.reactive.streams.engine.DelayedMonoPublisher in project camel by apache.
the class DelayedMonoPublisherTest method testMultipleSubscribersMixedArrival.
@Test
public void testMultipleSubscribersMixedArrival() throws Exception {
DelayedMonoPublisher<Integer> pub = new DelayedMonoPublisher<>(service);
ConcurrentLinkedDeque<Integer> data = new ConcurrentLinkedDeque<>();
CountDownLatch latch = new CountDownLatch(2);
Flowable.fromPublisher(pub).doOnNext(data::add).doOnComplete(latch::countDown).subscribe();
Thread.sleep(200);
pub.setData(5);
Flowable.fromPublisher(pub).doOnNext(data::add).doOnComplete(latch::countDown).subscribe();
assertTrue(latch.await(1, TimeUnit.SECONDS));
assertEquals(2, data.size());
for (Integer n : data) {
assertEquals(5, n.intValue());
}
}
Aggregations