Search in sources :

Example 1 with PayloadDecoder

use of io.rsocket.frame.decoder.PayloadDecoder 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);
}
Also used : Sinks(reactor.core.publisher.Sinks) BeforeEach(org.junit.jupiter.api.BeforeEach) StepVerifier(reactor.test.StepVerifier) RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CloseableChannel(io.rsocket.transport.netty.server.CloseableChannel) Controller(org.springframework.stereotype.Controller) Disabled(org.junit.jupiter.api.Disabled) PayloadDecoder(io.rsocket.frame.decoder.PayloadDecoder) RSocketServer(io.rsocket.core.RSocketServer) AfterAll(org.junit.jupiter.api.AfterAll) ApplicationErrorException(io.rsocket.exceptions.ApplicationErrorException) TestInstance(org.junit.jupiter.api.TestInstance) RSocket(io.rsocket.RSocket) BeforeAll(org.junit.jupiter.api.BeforeAll) Duration(java.time.Duration) Resource(org.springframework.core.io.Resource) Publisher(org.reactivestreams.Publisher) Mono(reactor.core.publisher.Mono) Instant(java.time.Instant) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) SocketAcceptor(io.rsocket.SocketAcceptor) Lifecycle(org.junit.jupiter.api.TestInstance.Lifecycle) ReferenceCounted(io.netty.util.ReferenceCounted) MessageMapping(org.springframework.messaging.handler.annotation.MessageMapping) RSocketInterceptor(io.rsocket.plugins.RSocketInterceptor) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.jupiter.api.Test) Configuration(org.springframework.context.annotation.Configuration) Flux(reactor.core.publisher.Flux) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) MessageExceptionHandler(org.springframework.messaging.handler.annotation.MessageExceptionHandler) Payload(org.springframework.messaging.handler.annotation.Payload) TcpServerTransport(io.rsocket.transport.netty.server.TcpServerTransport) Bean(org.springframework.context.annotation.Bean) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SocketAcceptor(io.rsocket.SocketAcceptor) RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with PayloadDecoder

use of io.rsocket.frame.decoder.PayloadDecoder in project spring-framework by spring-projects.

the class DefaultRSocketRequesterBuilderTests method testPayloadDecoder.

private void testPayloadDecoder(DataBufferFactory bufferFactory, PayloadDecoder payloadDecoder) throws NoSuchFieldException {
    RSocketStrategies strategies = RSocketStrategies.builder().dataBufferFactory(bufferFactory).build();
    RSocketRequester.builder().rsocketStrategies(strategies).rsocketConnector(this.connectorConfigurer).transport(this.transport);
    RSocketConnector connector = this.connectorConfigurer.connector();
    assertThat(connector).isNotNull();
    Field field = RSocketConnector.class.getDeclaredField("payloadDecoder");
    ReflectionUtils.makeAccessible(field);
    PayloadDecoder decoder = (PayloadDecoder) ReflectionUtils.getField(field, connector);
    assertThat(decoder).isSameAs(payloadDecoder);
}
Also used : Field(java.lang.reflect.Field) RSocketConnector(io.rsocket.core.RSocketConnector) PayloadDecoder(io.rsocket.frame.decoder.PayloadDecoder)

Aggregations

PayloadDecoder (io.rsocket.frame.decoder.PayloadDecoder)2 PooledByteBufAllocator (io.netty.buffer.PooledByteBufAllocator)1 ReferenceCounted (io.netty.util.ReferenceCounted)1 RSocket (io.rsocket.RSocket)1 SocketAcceptor (io.rsocket.SocketAcceptor)1 RSocketConnector (io.rsocket.core.RSocketConnector)1 RSocketServer (io.rsocket.core.RSocketServer)1 ApplicationErrorException (io.rsocket.exceptions.ApplicationErrorException)1 RSocketInterceptor (io.rsocket.plugins.RSocketInterceptor)1 CloseableChannel (io.rsocket.transport.netty.server.CloseableChannel)1 TcpServerTransport (io.rsocket.transport.netty.server.TcpServerTransport)1 Field (java.lang.reflect.Field)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 AfterAll (org.junit.jupiter.api.AfterAll)1 AfterEach (org.junit.jupiter.api.AfterEach)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1