Polishing RSocket module according SF changes

* Fix Checkstyle violations in the `MessageHistoryConfigurer`
This commit is contained in:
Artem Bilan
2019-06-24 16:39:30 -04:00
parent e833a44a38
commit 97aaf95ccb
10 changed files with 129 additions and 130 deletions

View File

@@ -26,7 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.codec.CharSequenceEncoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.core.io.buffer.NettyDataBufferFactory;
@@ -44,12 +43,10 @@ import io.netty.buffer.PooledByteBufAllocator;
import io.netty.util.NetUtil;
import io.rsocket.frame.decoder.PayloadDecoder;
import io.rsocket.transport.netty.client.TcpClientTransport;
import io.rsocket.transport.netty.server.TcpServerTransport;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.tcp.InetSocketAddressUtil;
import reactor.netty.tcp.TcpClient;
import reactor.netty.tcp.TcpServer;
/**
* @author Artem Bilan
@@ -73,8 +70,6 @@ public class RSocketDslTests {
@EnableIntegration
public static class TestConfiguration {
private volatile int port;
@Bean
public RSocketStrategies rsocketStrategies() {
return RSocketStrategies.builder()
@@ -86,12 +81,7 @@ public class RSocketDslTests {
@Bean
public ServerRSocketConnector serverRSocketConnector() {
TcpServer tcpServer =
TcpServer.create()
.port(0)
.doOnBound((server) -> this.port = server.port());
ServerRSocketConnector serverRSocketConnector =
new ServerRSocketConnector(TcpServerTransport.create(tcpServer));
ServerRSocketConnector serverRSocketConnector = new ServerRSocketConnector("localhost", 0);
serverRSocketConnector.setRSocketStrategies(rsocketStrategies());
serverRSocketConnector.setFactoryConfigurer((factory) -> factory.frameDecoder(PayloadDecoder.ZERO_COPY));
return serverRSocketConnector;
@@ -99,15 +89,15 @@ public class RSocketDslTests {
@Bean
@DependsOn("serverRSocketConnector")
public ClientRSocketConnector clientRSocketConnector() {
public ClientRSocketConnector clientRSocketConnector(ServerRSocketConnector serverRSocketConnector) {
ClientRSocketConnector clientRSocketConnector =
new ClientRSocketConnector(
TcpClientTransport.create(
TcpClient.create()
.addressSupplier(() ->
InetSocketAddressUtil.createUnresolved(
NetUtil.LOCALHOST.getHostAddress(), this.port))
NetUtil.LOCALHOST.getHostAddress(),
serverRSocketConnector.getBoundPort().block()))
));
clientRSocketConnector.setFactoryConfigurer((factory) -> factory.frameDecoder(PayloadDecoder.ZERO_COPY));
clientRSocketConnector.setRSocketStrategies(rsocketStrategies());
@@ -116,13 +106,13 @@ public class RSocketDslTests {
}
@Bean
public IntegrationFlow rsocketUpperCaseRequestFlow() {
public IntegrationFlow rsocketUpperCaseRequestFlow(ClientRSocketConnector clientRSocketConnector) {
return IntegrationFlows
.from(Function.class)
.handle(RSockets.outboundGateway("/uppercase")
.command((message) -> RSocketOutboundGateway.Command.requestResponse)
.expectedResponseType("T(java.lang.String)")
.clientRSocketConnector(clientRSocketConnector()))
.clientRSocketConnector(clientRSocketConnector))
.get();
}

View File

@@ -51,11 +51,9 @@ import org.springframework.util.MimeType;
import io.netty.buffer.PooledByteBufAllocator;
import io.rsocket.frame.decoder.PayloadDecoder;
import io.rsocket.transport.netty.server.TcpServerTransport;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoProcessor;
import reactor.netty.tcp.TcpServer;
import reactor.test.StepVerifier;
/**
@@ -69,8 +67,6 @@ public class RSocketInboundGatewayIntegrationTests {
private static AnnotationConfigApplicationContext serverContext;
private static int port;
private static ServerConfig serverConfig;
private static PollableChannel serverFireAndForgetChannelChannel;
@@ -213,11 +209,7 @@ public class RSocketInboundGatewayIntegrationTests {
@Bean
public ServerRSocketConnector serverRSocketConnector() {
TcpServer tcpServer =
TcpServer.create().port(0)
.doOnBound(server -> port = server.port());
ServerRSocketConnector serverRSocketConnector =
new ServerRSocketConnector(TcpServerTransport.create(tcpServer));
ServerRSocketConnector serverRSocketConnector = new ServerRSocketConnector("localhost", 0);
serverRSocketConnector.setRSocketStrategies(rsocketStrategies());
serverRSocketConnector.setMetadataMimeType(new MimeType("message", "x.rsocket.routing.v0"));
serverRSocketConnector.setFactoryConfigurer((factory) -> factory.frameDecoder(PayloadDecoder.ZERO_COPY));
@@ -232,7 +224,9 @@ public class RSocketInboundGatewayIntegrationTests {
@Bean
public ClientRSocketConnector clientRSocketConnector() {
ClientRSocketConnector clientRSocketConnector = new ClientRSocketConnector("localhost", port);
ClientRSocketConnector clientRSocketConnector =
new ClientRSocketConnector("localhost",
serverConfig.serverRSocketConnector().getBoundPort().block());
clientRSocketConnector.setMetadataMimeType(new MimeType("message", "x.rsocket.routing.v0"));
clientRSocketConnector.setFactoryConfigurer((factory) -> factory.frameDecoder(PayloadDecoder.ZERO_COPY));
clientRSocketConnector.setRSocketStrategies(rsocketStrategies());

View File

@@ -72,7 +72,6 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoProcessor;
import reactor.core.publisher.ReplayProcessor;
import reactor.netty.tcp.TcpServer;
import reactor.test.StepVerifier;
/**
@@ -90,8 +89,6 @@ public class RSocketOutboundGatewayIntegrationTests {
private static AnnotationConfigApplicationContext serverContext;
private static int port;
private static CloseableChannel server;
private static FluxMessageChannel serverInputChannel;
@@ -119,13 +116,10 @@ public class RSocketOutboundGatewayIntegrationTests {
@BeforeAll
static void setup() {
serverContext = new AnnotationConfigApplicationContext(ServerConfig.class);
TcpServer tcpServer =
TcpServer.create().port(0)
.doOnBound(server -> port = server.port());
server = RSocketFactory.receive()
.frameDecoder(PayloadDecoder.ZERO_COPY)
.acceptor(serverContext.getBean(RSocketMessageHandler.class).serverAcceptor())
.transport(TcpServerTransport.create(tcpServer))
.transport(TcpServerTransport.create("localhost", 0))
.start()
.block();
@@ -537,14 +531,15 @@ public class RSocketOutboundGatewayIntegrationTests {
.metadataMimeType("message/x.rsocket.routing.v0")
.frameDecoder(PayloadDecoder.ZERO_COPY)
.acceptor(messageHandler().clientAcceptor())
.transport(TcpClientTransport.create("localhost", port))
.transport(TcpClientTransport.create("localhost", server.address().getPort()))
.start()
.block();
}
@Bean
public ClientRSocketConnector clientRSocketConnector() {
ClientRSocketConnector clientRSocketConnector = new ClientRSocketConnector("localhost", port);
ClientRSocketConnector clientRSocketConnector =
new ClientRSocketConnector("localhost", server.address().getPort());
clientRSocketConnector.setFactoryConfigurer((factory) -> factory.frameDecoder(PayloadDecoder.ZERO_COPY));
clientRSocketConnector.setRSocketStrategies(rsocketStrategies());
return clientRSocketConnector;