MessagingAcceptor/RSocket refinements + upgrade to 0.11.17

See gh-21987
This commit is contained in:
Rossen Stoyanchev
2019-02-25 12:56:32 -05:00
parent 8bdd709683
commit d6f4ec8c33
10 changed files with 108 additions and 119 deletions

View File

@@ -199,7 +199,7 @@ public class DefaultRSocketRequesterTests {
}
private Payload toPayload(String value) {
return PayloadUtils.asPayload(bufferFactory.wrap(value.getBytes(StandardCharsets.UTF_8)));
return PayloadUtils.createPayload(bufferFactory.wrap(value.getBytes(StandardCharsets.UTF_8)));
}

View File

@@ -35,6 +35,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.codec.CharSequenceEncoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.ReactiveMessageChannel;
import org.springframework.messaging.ReactiveSubscribableChannel;
import org.springframework.messaging.handler.annotation.MessageMapping;
@@ -169,6 +170,12 @@ public class RSocketClientToServerIntegrationTests {
.verifyComplete();
}
@Test
public void noMatchingRoute() {
Mono<String> result = requester.route("invalid").data("anything").retrieveMono(String.class);
StepVerifier.create(result).verifyErrorMessage("RSocket request not handled");
}
@Controller
static class ServerController {

View File

@@ -20,7 +20,6 @@ import java.util.Collections;
import java.util.List;
import io.rsocket.Closeable;
import io.rsocket.Payload;
import io.rsocket.RSocket;
import io.rsocket.RSocketFactory;
import io.rsocket.transport.netty.client.TcpClientTransport;
@@ -140,13 +139,22 @@ public class RSocketServerToClientIntegrationTests {
volatile MonoProcessor<Void> result;
public void reset() {
this.result = MonoProcessor.create();
}
public void await(Duration duration) {
this.result.block(duration);
}
@MessageMapping("connect.echo")
void echo(RSocketRequester requester) {
runTest(() -> {
Flux<String> result = Flux.range(1, 3).concatMap(i ->
Flux<String> flux = Flux.range(1, 3).concatMap(i ->
requester.route("echo").data("Hello " + i).retrieveMono(String.class));
StepVerifier.create(result)
StepVerifier.create(flux)
.expectNext("Hello 1")
.expectNext("Hello 2")
.expectNext("Hello 3")
@@ -157,10 +165,10 @@ public class RSocketServerToClientIntegrationTests {
@MessageMapping("connect.echo-async")
void echoAsync(RSocketRequester requester) {
runTest(() -> {
Flux<String> result = Flux.range(1, 3).concatMap(i ->
Flux<String> flux = Flux.range(1, 3).concatMap(i ->
requester.route("echo-async").data("Hello " + i).retrieveMono(String.class));
StepVerifier.create(result)
StepVerifier.create(flux)
.expectNext("Hello 1 async")
.expectNext("Hello 2 async")
.expectNext("Hello 3 async")
@@ -171,9 +179,9 @@ public class RSocketServerToClientIntegrationTests {
@MessageMapping("connect.echo-stream")
void echoStream(RSocketRequester requester) {
runTest(() -> {
Flux<String> result = requester.route("echo-stream").data("Hello").retrieveFlux(String.class);
Flux<String> flux = requester.route("echo-stream").data("Hello").retrieveFlux(String.class);
StepVerifier.create(result)
StepVerifier.create(flux)
.expectNext("Hello 0")
.expectNextCount(5)
.expectNext("Hello 6")
@@ -186,11 +194,11 @@ public class RSocketServerToClientIntegrationTests {
@MessageMapping("connect.echo-channel")
void echoChannel(RSocketRequester requester) {
runTest(() -> {
Flux<String> result = requester.route("echo-channel")
Flux<String> flux = requester.route("echo-channel")
.data(Flux.range(1, 10).map(i -> "Hello " + i), String.class)
.retrieveFlux(String.class);
StepVerifier.create(result)
StepVerifier.create(flux)
.expectNext("Hello 1 async")
.expectNextCount(7)
.expectNext("Hello 9 async")
@@ -207,19 +215,6 @@ public class RSocketServerToClientIntegrationTests {
.subscribeOn(Schedulers.elastic())
.subscribe();
}
private static Payload payload(String destination, String data) {
return DefaultPayload.create(data, destination);
}
public void reset() {
this.result = MonoProcessor.create();
}
public void await(Duration duration) {
this.result.block(duration);
}
}