Java Code Examples for reactor.core.publisher.MonoProcessor#onComplete()

The following examples show how to use reactor.core.publisher.MonoProcessor#onComplete() . 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: ReactorNettyTcpClient.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private <T> Consumer<T> updateConnectMono(MonoProcessor<Void> connectMono) {
	return o -> {
		if (!connectMono.isTerminated()) {
			if (o instanceof Throwable) {
				connectMono.onError((Throwable) o);
			}
			else {
				connectMono.onComplete();
			}
		}
	};
}
 
Example 2
Source File: RSocketPayloadReturnValueHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected Mono<Void> handleEncodedContent(
		Flux<DataBuffer> encodedContent, MethodParameter returnType, Message<?> message) {

	MonoProcessor<Flux<Payload>> replyMono = getReplyMono(message);
	Assert.notNull(replyMono, "Missing '" + RESPONSE_HEADER + "'");
	replyMono.onNext(encodedContent.map(PayloadUtils::createPayload));
	replyMono.onComplete();
	return Mono.empty();
}
 
Example 3
Source File: RSocketPayloadReturnValueHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected Mono<Void> handleNoContent(MethodParameter returnType, Message<?> message) {
	MonoProcessor<Flux<Payload>> replyMono = getReplyMono(message);
	if (replyMono != null) {
		replyMono.onComplete();
	}
	return Mono.empty();
}
 
Example 4
Source File: StatusAssertionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private StatusAssertions statusAssertions(HttpStatus status) {
	MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/"));
	MockClientHttpResponse response = new MockClientHttpResponse(status);

	MonoProcessor<byte[]> emptyContent = MonoProcessor.create();
	emptyContent.onComplete();

	ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null);
	return new StatusAssertions(result, mock(WebTestClient.ResponseSpec.class));
}
 
Example 5
Source File: HeaderAssertionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) {
	MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/"));
	MockClientHttpResponse response = new MockClientHttpResponse(HttpStatus.OK);
	response.getHeaders().putAll(responseHeaders);

	MonoProcessor<byte[]> emptyContent = MonoProcessor.create();
	emptyContent.onComplete();

	ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null);
	return new HeaderAssertions(result, mock(WebTestClient.ResponseSpec.class));
}
 
Example 6
Source File: ReactorNettyTcpClient.java    From java-technology-stack with MIT License 5 votes vote down vote up
private <T> Consumer<T> updateConnectMono(MonoProcessor<Void> connectMono) {
	return o -> {
		if (!connectMono.isTerminated()) {
			if (o instanceof Throwable) {
				connectMono.onError((Throwable) o);
			}
			else {
				connectMono.onComplete();
			}
		}
	};
}
 
Example 7
Source File: StatusAssertionTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private StatusAssertions statusAssertions(HttpStatus status) {
	MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/"));
	MockClientHttpResponse response = new MockClientHttpResponse(status);

	MonoProcessor<byte[]> emptyContent = MonoProcessor.create();
	emptyContent.onComplete();

	ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null);
	return new StatusAssertions(result, mock(WebTestClient.ResponseSpec.class));
}
 
Example 8
Source File: HeaderAssertionTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) {
	MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/"));
	MockClientHttpResponse response = new MockClientHttpResponse(HttpStatus.OK);
	response.getHeaders().putAll(responseHeaders);

	MonoProcessor<byte[]> emptyContent = MonoProcessor.create();
	emptyContent.onComplete();

	ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null);
	return new HeaderAssertions(result, mock(WebTestClient.ResponseSpec.class));
}
 
Example 9
Source File: RSocketRequesterTest.java    From rsocket-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testCorrectFrameOrder() {
  MonoProcessor<Object> delayer = MonoProcessor.create();
  BaseSubscriber<Payload> subscriber =
      new BaseSubscriber<Payload>() {
        @Override
        protected void hookOnSubscribe(Subscription subscription) {}
      };
  rule.socket
      .requestChannel(
          Flux.concat(Flux.just(0).delayUntil(i -> delayer), Flux.range(1, 999))
              .map(i -> DefaultPayload.create(i + "")))
      .subscribe(subscriber);

  subscriber.request(1);
  subscriber.request(Long.MAX_VALUE);
  delayer.onComplete();

  Iterator<ByteBuf> iterator = rule.connection.getSent().iterator();

  ByteBuf initialFrame = iterator.next();

  Assertions.assertThat(FrameHeaderCodec.frameType(initialFrame)).isEqualTo(REQUEST_CHANNEL);
  Assertions.assertThat(RequestChannelFrameCodec.initialRequestN(initialFrame))
      .isEqualTo(Long.MAX_VALUE);
  Assertions.assertThat(RequestChannelFrameCodec.data(initialFrame).toString(CharsetUtil.UTF_8))
      .isEqualTo("0");
  Assertions.assertThat(initialFrame.release()).isTrue();

  Assertions.assertThat(iterator.hasNext()).isFalse();
  rule.assertHasNoLeaks();
}