Java Code Examples for reactor.core.publisher.Mono#never()

The following examples show how to use reactor.core.publisher.Mono#never() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChannelSendOperatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test // gh-22720
public void errorFromWriteSourceWhileItemCached() {

	// 1. First item received
	// 2. writeFunction applied and writeCompletionBarrier subscribed to it
	// 3. Write Publisher fails right after that and before request(n) from server

	LeakAwareDataBufferFactory bufferFactory = new LeakAwareDataBufferFactory();
	ZeroDemandSubscriber writeSubscriber = new ZeroDemandSubscriber();

	ChannelSendOperator<DataBuffer> operator = new ChannelSendOperator<>(
			Flux.create(sink -> {
				DataBuffer dataBuffer = bufferFactory.allocateBuffer();
				dataBuffer.write("foo", StandardCharsets.UTF_8);
				sink.next(dataBuffer);
				sink.error(new IllegalStateException("err"));
			}),
			publisher -> {
				publisher.subscribe(writeSubscriber);
				return Mono.never();
			});


	operator.subscribe(new BaseSubscriber<Void>() {});
	try {
		writeSubscriber.signalDemand(1);  // Let cached signals ("foo" and error) be published..
	}
	catch (Throwable ex) {
		assertNotNull(ex.getCause());
		assertEquals("err", ex.getCause().getMessage());
	}

	bufferFactory.checkForLeaks();
}
 
Example 2
Source File: BlockingConnectionTest.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimeoutOnStart() {
	TestClientTransport neverStart = new TestClientTransport(Mono.never());

	assertThatExceptionOfType(IllegalStateException.class)
			.isThrownBy(() -> neverStart.connectNow(Duration.ofMillis(100)))
			.withMessage("TestClientTransport couldn't be started within 100ms");
}
 
Example 3
Source File: StepVerifierTests.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void expectTimeoutSmokeTest() {
	Mono<String> neverMono = Mono.never();
	Mono<String> completingMono = Mono.empty();

	StepVerifier.create(neverMono, StepVerifierOptions.create().scenarioName("neverMono should pass"))
			.expectTimeout(Duration.ofSeconds(1))
			.verify();

	StepVerifier shouldFail = StepVerifier.create(completingMono).expectTimeout(Duration.ofSeconds(1));

	assertThatExceptionOfType(AssertionError.class)
			.isThrownBy(shouldFail::verify)
			.withMessage("expectation \"expectTimeout\" failed (expected: timeout(1s); actual: onComplete())");
}
 
Example 4
Source File: StepVerifierTests.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyTimeoutSmokeTest() {
	Mono<String> neverMono = Mono.never();
	Mono<String> completingMono = Mono.empty();

	StepVerifier.create(neverMono, StepVerifierOptions.create().scenarioName("neverMono should pass"))
			.verifyTimeout(Duration.ofSeconds(1));

	assertThatExceptionOfType(AssertionError.class)
			.isThrownBy(() -> StepVerifier.create(completingMono).verifyTimeout(Duration.ofSeconds(1)))
			.withMessage("expectation \"expectTimeout\" failed (expected: timeout(1s); actual: onComplete())");
}
 
Example 5
Source File: FutureTest.java    From cyclops with Apache License 2.0 5 votes vote down vote up
@Test
public void nonblocking(){
    Mono<String> mono = Mono.never();
    Future<String> future = Future.fromPublisher(mono);
    Future.fromPublisher(Maybe.maybe());
    Future.fromPublisher(LazyEither.either());
    Future.fromPublisher(LazyEither3.either3());
    Future.fromPublisher(LazyEither4.either4());
    Future.fromPublisher(LazyEither5.either5());
    Future.fromPublisher(Eval.eval());


}
 
Example 6
Source File: ZeroDemandResponse.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
	body.subscribe(this.writeSubscriber);
	return Mono.never();
}
 
Example 7
Source File: JobExecutionPlanRunner.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
private Mono<Void> doAwaitCompletion() {
    return Mono.never();
}
 
Example 8
Source File: NeverJobValidator.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public Mono<Set<ValidationError>> validate(JobDescriptor entity) {
    return Mono.never();
}
 
Example 9
Source File: NeverJobValidator.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public Mono<UnaryOperator<JobDescriptor>> sanitize(JobDescriptor entity) {
    return Mono.never();
}
 
Example 10
Source File: TcpResourcesTest.java    From reactor-netty with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
	loopDisposed = new AtomicBoolean();
	poolDisposed = new AtomicBoolean();

	LoopResources loopResources = new LoopResources() {
		@Override
		public EventLoopGroup onServer(boolean useNative) {
			throw new UnsupportedOperationException();
		}

		@Override
		public Mono<Void> disposeLater(Duration quietPeriod, Duration timeout) {
			return Mono.<Void>empty().doOnSuccess(c -> loopDisposed.set(true));
		}

		@Override
		public boolean isDisposed() {
			return loopDisposed.get();
		}
	};

	ConnectionProvider poolResources = new ConnectionProvider() {

		@Override
		public Mono<? extends Connection> acquire(TransportConfig config,
				ConnectionObserver observer,
				Supplier<? extends SocketAddress> remoteAddress,
				AddressResolverGroup<?> resolverGroup) {
			return Mono.never();
		}

		@Override
		public Mono<Void> disposeLater() {
			return Mono.<Void>empty().doOnSuccess(c -> poolDisposed.set(true));
		}

		@Override
		public boolean isDisposed() {
			return poolDisposed.get();
		}
	};

	tcpResources = new TcpResources(loopResources, poolResources);
}
 
Example 11
Source File: BlockingConnectionTest.java    From reactor-netty with Apache License 2.0 4 votes vote down vote up
@Override
public Mono<Void> onDispose() {
	return Mono.never();
}
 
Example 12
Source File: BlockingConnectionTest.java    From reactor-netty with Apache License 2.0 4 votes vote down vote up
@Override
public Mono<Void> onDispose() {
	return Mono.never();
}
 
Example 13
Source File: HttpResourcesTest.java    From reactor-netty with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
	loopDisposed = new AtomicBoolean();
	poolDisposed = new AtomicBoolean();

	LoopResources loopResources = new LoopResources() {
		@Override
		public EventLoopGroup onServer(boolean useNative) {
			throw new UnsupportedOperationException();
		}

		@Override
		public Mono<Void> disposeLater(Duration quietPeriod, Duration timeout) {
			return Mono.<Void>empty().doOnSuccess(c -> loopDisposed.set(true));
		}

		@Override
		public boolean isDisposed() {
			return loopDisposed.get();
		}
	};

	ConnectionProvider poolResources = new ConnectionProvider() {

		@Override
		public Mono<? extends Connection> acquire(TransportConfig config,
				ConnectionObserver observer,
				Supplier<? extends SocketAddress> remoteAddress,
				AddressResolverGroup<?> resolverGroup) {
			return Mono.never();
		}

		@Override
		public Mono<Void> disposeLater() {
			return Mono.<Void>empty().doOnSuccess(c -> poolDisposed.set(true));
		}

		@Override
		public boolean isDisposed() {
			return poolDisposed.get();
		}
	};

	testResources = new HttpResources(loopResources, poolResources);
}
 
Example 14
Source File: RSocket.java    From rsocket-java with Apache License 2.0 4 votes vote down vote up
@Override
default Mono<Void> onClose() {
  return Mono.never();
}