use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class FluxPeekTest method syncFusionAvailable.
@Test
public void syncFusionAvailable() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Flux.range(1, 2).doOnNext(v -> {
}).subscribe(ts);
Subscription s = ts.upstream();
Assert.assertTrue("Non-fuseable upstream: " + s, s instanceof Fuseable.QueueSubscription);
}
use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class FluxPeekTest method asyncFusionAvailable.
@Test
public void asyncFusionAvailable() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
UnicastProcessor.create(Queues.<Integer>get(2).get()).doOnNext(v -> {
}).subscribe(ts);
Subscription s = ts.upstream();
Assert.assertTrue("Non-fuseable upstream" + s, s instanceof Fuseable.QueueSubscription);
}
use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class FluxPublishOnTest method rejectedExecutionExceptionOnErrorSignalExecutor.
@Test
// Fix or deprecate fromExecutor, this test might randomly hang on CI
@Ignore
public void rejectedExecutionExceptionOnErrorSignalExecutor() throws InterruptedException {
Exception exception = new IllegalStateException();
final AtomicReference<Throwable> throwableInOnOperatorError = new AtomicReference<>();
final AtomicReference<Object> dataInOnOperatorError = new AtomicReference<>();
try {
CountDownLatch hookLatch = new CountDownLatch(2);
Hooks.onOperatorError((t, d) -> {
throwableInOnOperatorError.set(t);
dataInOnOperatorError.set(d);
hookLatch.countDown();
return t;
});
ExecutorService executor = newCachedThreadPool();
CountDownLatch latch = new CountDownLatch(1);
AssertSubscriber<Integer> assertSubscriber = new AssertSubscriber<>();
Flux.range(0, 5).publishOn(fromExecutorService(executor)).doOnNext(s -> {
try {
latch.await();
} catch (InterruptedException e) {
throw Exceptions.propagate(exception);
}
}).publishOn(fromExecutor(executor)).subscribe(assertSubscriber);
executor.shutdownNow();
assertSubscriber.assertNoValues().assertNoError().assertNotComplete();
hookLatch.await();
Assert.assertThat(throwableInOnOperatorError.get(), CoreMatchers.instanceOf(RejectedExecutionException.class));
Assert.assertSame(throwableInOnOperatorError.get().getSuppressed()[0], exception);
} finally {
Hooks.resetOnOperatorError();
}
}
use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class FluxGroupByTest method twoGroupsLongAsyncMerge.
@Test
public void twoGroupsLongAsyncMerge() {
ForkJoinPool forkJoinPool = new ForkJoinPool();
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Flux.range(1, 1_000_000).groupBy(v -> (v & 1)).flatMap(g -> g).publishOn(Schedulers.fromExecutorService(forkJoinPool)).subscribe(ts);
ts.await(Duration.ofSeconds(5));
ts.assertValueCount(1_000_000).assertNoError().assertComplete();
}
use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class FluxGroupByTest method twoGroupsFullAsync.
@Test
@Ignore("temporarily disabled, see gh-1028")
public void twoGroupsFullAsync() {
ForkJoinPool forkJoinPool = new ForkJoinPool();
AssertSubscriber<Integer> ts1 = AssertSubscriber.create();
AssertSubscriber<Integer> ts2 = AssertSubscriber.create();
AssertSubscriber<Integer> ts3 = AssertSubscriber.create();
ts3.onSubscribe(Operators.emptySubscription());
Flux.range(0, 1_000_000).publishOn(Schedulers.fromExecutorService(forkJoinPool), 512).groupBy(v -> v & 1).subscribe(new CoreSubscriber<GroupedFlux<Integer, Integer>>() {
@Override
public void onSubscribe(Subscription s) {
s.request(Long.MAX_VALUE);
}
@Override
public void onNext(GroupedFlux<Integer, Integer> t) {
if (t.key() == 0) {
t.publishOn(Schedulers.fromExecutorService(forkJoinPool)).subscribe(ts1);
} else {
t.publishOn(Schedulers.fromExecutorService(forkJoinPool)).subscribe(ts2);
}
}
@Override
public void onError(Throwable t) {
ts3.onError(t);
}
@Override
public void onComplete() {
ts3.onComplete();
}
});
ts1.await(Duration.ofSeconds(5));
ts2.await(Duration.ofSeconds(5));
ts3.await(Duration.ofSeconds(5));
ts1.assertValueCount(500_000).assertNoError().assertComplete();
ts2.assertValueCount(500_000).assertNoError().assertComplete();
ts3.assertNoValues().assertNoError().assertComplete();
}
Aggregations