Simplified RoutingFunction configuration

If routing-expression is provided there is no need to explicitely set function.definition to 'functionRouter'
This commit is contained in:
Oleg Zhurakousky
2021-02-18 15:35:26 +01:00
parent 81d6998635
commit 7c216847b2
3 changed files with 38 additions and 9 deletions

View File

@@ -58,7 +58,7 @@ public class RSocketAutoConfigurationRoutingTests {
applicationContext.getBean(RSocketRequester.Builder.class);
rsocketRequesterBuilder.tcp("localhost", port)
.route(RoutingFunction.FUNCTION_NAME)
.route("")
.metadata("{\"func_name\":\"echo\"}", MimeTypeUtils.APPLICATION_JSON)
.data("hello")
.retrieveMono(String.class)
@@ -68,14 +68,14 @@ public class RSocketAutoConfigurationRoutingTests {
.verify();
rsocketRequesterBuilder.tcp("localhost", port)
.route(RoutingFunction.FUNCTION_NAME)
.metadata("{\"func_name\":\"uppercase\"}", MimeTypeUtils.APPLICATION_JSON)
.data("hello")
.retrieveMono(String.class)
.as(StepVerifier::create)
.expectNext("HELLO")
.expectComplete()
.verify();
.route(RoutingFunction.FUNCTION_NAME)
.metadata("{\"func_name\":\"uppercase\"}", MimeTypeUtils.APPLICATION_JSON)
.data("hello")
.retrieveMono(String.class)
.as(StepVerifier::create)
.expectNext("HELLO")
.expectComplete()
.verify();
}
}

View File

@@ -122,6 +122,31 @@ public class RSocketAutoConfigurationTests {
}
}
@Test
public void testWithRouteAndDefinition() {
int port = SocketUtils.findAvailableTcpPort();
try (
ConfigurableApplicationContext applicationContext =
new SpringApplicationBuilder(SampleFunctionConfiguration.class)
.web(WebApplicationType.NONE)
.run("--logging.level.org.springframework.cloud.function=DEBUG",
"--spring.cloud.function.definition=echo",
"--spring.rsocket.server.port=" + port);
) {
RSocketRequester.Builder rsocketRequesterBuilder =
applicationContext.getBean(RSocketRequester.Builder.class);
rsocketRequesterBuilder.tcp("localhost", port)
.route("uppercase")
.data("hello")
.retrieveMono(String.class)
.as(StepVerifier::create)
.expectNext("HELLO")
.expectComplete()
.verify();
}
}
@Test
public void testImperativeFunctionAsRequestReplyWithComposition() {
int port = SocketUtils.findAvailableTcpPort();