use of io.rsocket.SocketAcceptor in project spring-framework by spring-projects.
the class RSocketServerToClientIntegrationTests method setupOnce.
@BeforeAll
@SuppressWarnings("ConstantConditions")
static void setupOnce() {
context = new AnnotationConfigApplicationContext(RSocketConfig.class);
RSocketMessageHandler messageHandler = context.getBean(RSocketMessageHandler.class);
SocketAcceptor responder = messageHandler.responder();
server = RSocketServer.create(responder).payloadDecoder(PayloadDecoder.ZERO_COPY).bind(TcpServerTransport.create("localhost", 0)).block();
}
use of io.rsocket.SocketAcceptor in project spring-framework by spring-projects.
the class RSocketBufferLeakTests method setupOnce.
@BeforeAll
void setupOnce() {
context = new AnnotationConfigApplicationContext(ServerConfig.class);
RSocketMessageHandler messageHandler = context.getBean(RSocketMessageHandler.class);
SocketAcceptor responder = messageHandler.responder();
server = RSocketServer.create(responder).payloadDecoder(PayloadDecoder.ZERO_COPY).interceptors(// intercept responding
registry -> registry.forResponder(payloadInterceptor)).bind(TcpServerTransport.create("localhost", 7000)).block();
requester = RSocketRequester.builder().rsocketConnector(conn -> conn.interceptors(registry -> registry.forRequester(payloadInterceptor))).rsocketStrategies(context.getBean(RSocketStrategies.class)).tcp("localhost", 7000);
}
use of io.rsocket.SocketAcceptor in project spring-security by spring-projects.
the class PayloadSocketAcceptorInterceptorTests method captureExchange.
private PayloadExchange captureExchange() {
given(this.socketAcceptor.accept(any(), any())).willReturn(Mono.just(this.rSocket));
given(this.interceptor.intercept(any(), any())).willReturn(Mono.empty());
SocketAcceptor wrappedAcceptor = this.acceptorInterceptor.apply(this.socketAcceptor);
RSocket result = wrappedAcceptor.accept(this.setupPayload, this.rSocket).block();
assertThat(result).isInstanceOf(PayloadInterceptorRSocket.class);
given(this.rSocket.fireAndForget(any())).willReturn(Mono.empty());
result.fireAndForget(this.payload).block();
ArgumentCaptor<PayloadExchange> exchangeArg = ArgumentCaptor.forClass(PayloadExchange.class);
verify(this.interceptor, times(2)).intercept(exchangeArg.capture(), any());
return exchangeArg.getValue();
}
use of io.rsocket.SocketAcceptor in project spring-framework by spring-projects.
the class RSocketClientToServerIntegrationTests method setupOnce.
@BeforeAll
@SuppressWarnings("ConstantConditions")
public static void setupOnce() {
MimeType metadataMimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
context = new AnnotationConfigApplicationContext(ServerConfig.class);
RSocketMessageHandler messageHandler = context.getBean(RSocketMessageHandler.class);
SocketAcceptor responder = messageHandler.responder();
server = RSocketServer.create(responder).interceptors(registry -> registry.forResponder(interceptor)).payloadDecoder(PayloadDecoder.ZERO_COPY).bind(TcpServerTransport.create("localhost", 7000)).block();
requester = RSocketRequester.builder().metadataMimeType(metadataMimeType).rsocketStrategies(context.getBean(RSocketStrategies.class)).tcp("localhost", 7000);
}
use of io.rsocket.SocketAcceptor in project spring-framework by spring-projects.
the class RSocketServerToClientIntegrationTests method connectAndRunTest.
private static void connectAndRunTest(String connectionRoute) {
context.getBean(ServerController.class).reset();
RSocketStrategies strategies = context.getBean(RSocketStrategies.class);
SocketAcceptor responder = RSocketMessageHandler.responder(strategies, new ClientHandler());
RSocketRequester requester = null;
try {
requester = RSocketRequester.builder().setupRoute(connectionRoute).rsocketStrategies(strategies).rsocketConnector(connector -> connector.acceptor(responder)).tcp("localhost", server.address().getPort());
// Trigger connection establishment.
requester.rsocketClient().source().block();
context.getBean(ServerController.class).await(Duration.ofSeconds(5));
} finally {
if (requester != null) {
requester.rsocketClient().dispose();
}
}
}
Aggregations