Support @RSocketExchange for annotated responders

See gh-30936
This commit is contained in:
Olga MaciaszekSharma
2023-07-27 17:24:40 +02:00
committed by rstoyanchev
parent 376223c87d
commit 4cd9e2e9b0
3 changed files with 88 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@ import reactor.test.StepVerifier;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.messaging.rsocket.RSocketStrategies;
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
@@ -45,6 +44,7 @@ import org.springframework.util.MimeTypeUtils;
* Integration tests with RSocket Service client.
*
* @author Rossen Stoyanchev
* @author Olga Maciaszek-Sharma
*/
class RSocketServiceIntegrationTests {
@@ -57,7 +57,7 @@ class RSocketServiceIntegrationTests {
@BeforeAll
@SuppressWarnings("ConstantConditions")
static void setupOnce() throws Exception {
static void setupOnce() {
MimeType metadataMimeType = MimeTypeUtils.parseMimeType(
WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
@@ -112,28 +112,26 @@ class RSocketServiceIntegrationTests {
}
@Controller
@RSocketExchange("echo")
interface Service {
@RSocketExchange("echo-async")
@RSocketExchange("async")
Mono<String> echoAsync(String payload);
@RSocketExchange("echo-stream")
@RSocketExchange("stream")
Flux<String> echoStream(String payload);
}
@Controller
static class ServerController {
static class ServerController implements Service {
@MessageMapping("echo-async")
Mono<String> echoAsync(String payload) {
public Mono<String> echoAsync(String payload) {
return Mono.delay(Duration.ofMillis(10)).map(aLong -> payload + " async");
}
@MessageMapping("echo-stream")
Flux<String> echoStream(String payload) {
public Flux<String> echoStream(String payload) {
return Flux.interval(Duration.ofMillis(10)).map(aLong -> payload + " " + aLong);
}