use of reactor.test.StepVerifier in project reactor-core by reactor.
the class SchedulersTest method handleErrorWithJvmFatalForwardsToUncaughtHandlerSyncInnerCallable.
@Test
public void handleErrorWithJvmFatalForwardsToUncaughtHandlerSyncInnerCallable() {
AtomicBoolean handlerCaught = new AtomicBoolean();
Scheduler scheduler = Schedulers.fromExecutorService(Executors.newSingleThreadExecutor(r -> {
Thread thread = new Thread(r);
thread.setUncaughtExceptionHandler((t, ex) -> {
handlerCaught.set(true);
System.err.println("from uncaught handler: " + ex.toString());
});
return thread;
}));
final StepVerifier stepVerifier = StepVerifier.create(Flux.just("hi").flatMap(item -> Mono.<String>fromCallable(() -> {
throw new StackOverflowError("boom");
}).hide().subscribeOn(scheduler))).expectNoFusionSupport().expectErrorMessage(// ignored
"boom");
// the exception is still fatal, so the StepVerifier should time out.
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> stepVerifier.verify(Duration.ofMillis(100))).withMessageStartingWith("VerifySubscriber timed out on ");
// nonetheless, the uncaught exception handler should have been invoked
assertThat(handlerCaught).as("uncaughtExceptionHandler used").isTrue();
}
use of reactor.test.StepVerifier in project reactor-core by reactor.
the class SchedulersTest method handleErrorWithJvmFatalForwardsToUncaughtHandlerFusedCallable.
@Test
public void handleErrorWithJvmFatalForwardsToUncaughtHandlerFusedCallable() {
AtomicBoolean handlerCaught = new AtomicBoolean();
Scheduler scheduler = Schedulers.fromExecutorService(Executors.newSingleThreadExecutor(r -> {
Thread thread = new Thread(r);
thread.setUncaughtExceptionHandler((t, ex) -> {
handlerCaught.set(true);
System.err.println("from uncaught handler: " + ex.toString());
});
return thread;
}));
final StepVerifier stepVerifier = StepVerifier.create(Mono.<String>fromCallable(() -> {
throw new StackOverflowError("boom");
}).subscribeOn(scheduler)).expectFusion().expectErrorMessage("boom");
// the exception is still fatal, so the StepVerifier should time out.
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> stepVerifier.verify(Duration.ofMillis(100))).withMessageStartingWith("VerifySubscriber timed out on ");
// nonetheless, the uncaught exception handler should have been invoked
assertThat(handlerCaught).as("uncaughtExceptionHandler used").isTrue();
}
use of reactor.test.StepVerifier in project reactor-core by reactor.
the class FluxPublishTest method prematureOnComplete.
@Test
public void prematureOnComplete() {
EmitterProcessor<Flux<String>> incomingProcessor = EmitterProcessor.create(false);
Flux.just("ALPHA", "BRAVO", "CHARLIE", "DELTA", "ALPHA", "BRAVO", "CHARLIE", "DELTA", "ALPHA", "BRAVO", "CHARLIE", "DELTA").log("stream.incoming").windowWhile(s -> !"DELTA".equals(s), 1).subscribe(incomingProcessor);
AtomicInteger windowIndex = new AtomicInteger(0);
AtomicInteger nextIndex = new AtomicInteger(0);
System.out.println("ZERO");
incomingProcessor.next().flatMapMany(flux -> flux.takeWhile(s -> !"CHARLIE".equals(s)).log(String.format("stream.window.%d", windowIndex.getAndIncrement()))).log(String.format("stream.next.%d", nextIndex.getAndIncrement())).as(StepVerifier::create).expectNextCount(2).verifyComplete();
System.out.println("ONE");
incomingProcessor.next().flatMapMany(flux -> flux.takeWhile(s -> !"CHARLIE".equals(s)).log(String.format("stream.window.%d", windowIndex.getAndIncrement()))).log(String.format("stream.next.%d", nextIndex.getAndIncrement())).as(StepVerifier::create).expectNextCount(2).verifyComplete();
System.out.println("TWO");
incomingProcessor.next().flatMapMany(flux -> flux.takeWhile(s -> !"CHARLIE".equals(s)).log(String.format("stream.window.%d", windowIndex.getAndIncrement()))).log(String.format("stream.next.%d", nextIndex.getAndIncrement())).as(StepVerifier::create).expectNextCount(2).verifyComplete();
}
use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.
the class DefaultApplicationsTest method pushNoDomainPrivate.
@Test
public void pushNoDomainPrivate() throws IOException {
Path testApplication = new ClassPathResource("test-application.zip").getFile().toPath();
requestApplicationsEmpty(this.cloudFoundryClient, "test-name", TEST_SPACE_ID);
requestCreateApplication(this.cloudFoundryClient, ApplicationManifest.builder().path(testApplication).name("test-name").build(), TEST_SPACE_ID, null, "test-application-id");
requestSpace(this.cloudFoundryClient, TEST_SPACE_ID, TEST_ORGANIZATION_ID);
requestPrivateDomains(this.cloudFoundryClient, TEST_ORGANIZATION_ID, "test-private-domain-id");
requestSharedDomainsEmpty(this.cloudFoundryClient);
requestListMatchingResources(this.cloudFoundryClient, Arrays.asList(new ResourceMatchingUtils.ArtifactMetadata("da39a3ee5e6b4b0d3255bfef95601890afd80709", "Staticfile", "100644", 0), new ResourceMatchingUtils.ArtifactMetadata("45044a6ddbfe11415a8f8a6219de68a2c66b496b", "index.html", "100644", 178)));
requestApplicationRoutesEmpty(this.cloudFoundryClient, "test-application-id");
this.applications.push(PushApplicationRequest.builder().path(testApplication).name("test-name").build()).as(StepVerifier::create).consumeErrorWith(t -> assertThat(t).isInstanceOf(IllegalArgumentException.class).hasMessage("No default domain found")).verify(Duration.ofSeconds(5));
}
use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.
the class RoutesTest method unmap.
@Test
public void unmap() throws IOException {
String applicationName = this.nameFactory.getApplicationName();
String domainName = this.nameFactory.getDomainName();
String hostName = this.nameFactory.getHostName();
String path = this.nameFactory.getPath();
Mono.when(createDomainAndRoute(this.cloudFoundryOperations, this.organizationName, this.spaceName, domainName, hostName, path), requestCreateApplication(this.cloudFoundryOperations, new ClassPathResource("test-application.zip").getFile().toPath(), applicationName, true)).then(requestMapRoute(this.cloudFoundryOperations, applicationName, domainName, hostName, path)).then(this.cloudFoundryOperations.routes().unmap(UnmapRouteRequest.builder().applicationName(applicationName).domain(domainName).host(hostName).path(path).build())).thenMany(requestListRoutes(this.cloudFoundryOperations)).filter(filterRoutes(domainName, hostName, path, applicationName)).as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}
Aggregations