use of reactor.core.publisher.DirectProcessor in project reactor-core by reactor.
the class StepVerifierTests method assertNextWithSubscribeOnDirectProcessor.
// see https://github.com/reactor/reactor-core/issues/959
@Test
public void assertNextWithSubscribeOnDirectProcessor() {
Scheduler scheduler = Schedulers.newElastic("test");
DirectProcessor<Integer> processor = DirectProcessor.create();
Mono<Integer> doAction = Mono.fromSupplier(() -> 22).doOnNext(processor::onNext).subscribeOn(scheduler);
assertThatExceptionOfType(AssertionError.class).isThrownBy(StepVerifier.create(processor).then(doAction::subscribe).assertNext(v -> assertThat(v).isEqualTo(23)).thenCancel()::verify);
}
use of reactor.core.publisher.DirectProcessor in project reactor-netty by reactor.
the class HttpClientTest method prematureCancel.
@Test
public void prematureCancel() throws Exception {
DirectProcessor<Void> signal = DirectProcessor.create();
NettyContext x = TcpServer.create("localhost", 0).newHandler((in, out) -> {
signal.onComplete();
return out.context(c -> c.addHandlerFirst(new HttpResponseEncoder())).sendObject(Mono.delay(Duration.ofSeconds(2)).map(t -> new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.PROCESSING))).neverComplete();
}).block(Duration.ofSeconds(30));
StepVerifier.create(createHttpClientForContext(x).get("/").timeout(signal)).verifyError(TimeoutException.class);
// Thread.sleep(1000000);
}
use of reactor.core.publisher.DirectProcessor in project reactor-core by reactor.
the class SchedulersTest method assertRejectingScheduler.
public void assertRejectingScheduler(Scheduler scheduler) {
try {
DirectProcessor<String> p = DirectProcessor.create();
AtomicReference<String> r = new AtomicReference<>();
CountDownLatch l = new CountDownLatch(1);
p.publishOn(scheduler).log().subscribe(r::set, null, l::countDown);
scheduler.dispose();
p.onNext("reject me");
l.await(3, TimeUnit.SECONDS);
} catch (Exception ree) {
ree.printStackTrace();
Throwable throwable = Exceptions.unwrap(ree);
if (throwable instanceof RejectedExecutionException) {
return;
}
fail(throwable + " is not a RejectedExecutionException");
} finally {
scheduler.dispose();
}
}
Aggregations