Search in sources :

Example 6 with ByteArrayEncoder

use of org.springframework.core.codec.ByteArrayEncoder in project spring-framework by spring-projects.

the class RSocketMessageHandlerTests method setRSocketStrategies.

@Test
public void setRSocketStrategies() {
    RSocketStrategies strategies = RSocketStrategies.builder().encoder(new ByteArrayEncoder()).decoder(new ByteArrayDecoder()).routeMatcher(new SimpleRouteMatcher(new AntPathMatcher())).metadataExtractor(new DefaultMetadataExtractor()).reactiveAdapterStrategy(new ReactiveAdapterRegistry()).build();
    RSocketMessageHandler handler = new RSocketMessageHandler();
    handler.setRSocketStrategies(strategies);
    assertThat(handler.getEncoders()).isEqualTo(strategies.encoders());
    assertThat(handler.getDecoders()).isEqualTo(strategies.decoders());
    assertThat(handler.getRouteMatcher()).isSameAs(strategies.routeMatcher());
    assertThat(handler.getMetadataExtractor()).isSameAs(strategies.metadataExtractor());
    assertThat(handler.getReactiveAdapterRegistry()).isSameAs(strategies.reactiveAdapterRegistry());
}
Also used : ByteArrayEncoder(org.springframework.core.codec.ByteArrayEncoder) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) RSocketStrategies(org.springframework.messaging.rsocket.RSocketStrategies) DefaultMetadataExtractor(org.springframework.messaging.rsocket.DefaultMetadataExtractor) SimpleRouteMatcher(org.springframework.util.SimpleRouteMatcher) AntPathMatcher(org.springframework.util.AntPathMatcher) ByteArrayDecoder(org.springframework.core.codec.ByteArrayDecoder) Test(org.junit.jupiter.api.Test)

Example 7 with ByteArrayEncoder

use of org.springframework.core.codec.ByteArrayEncoder in project spring-framework by spring-projects.

the class DefaultRSocketStrategiesTests method explicitValues.

@Test
void explicitValues() {
    SimpleRouteMatcher matcher = new SimpleRouteMatcher(new AntPathMatcher());
    DefaultMetadataExtractor extractor = new DefaultMetadataExtractor();
    ReactiveAdapterRegistry registry = new ReactiveAdapterRegistry();
    RSocketStrategies strategies = RSocketStrategies.builder().encoders(encoders -> {
        encoders.clear();
        encoders.add(new ByteArrayEncoder());
    }).decoders(decoders -> {
        decoders.clear();
        decoders.add(new ByteArrayDecoder());
    }).routeMatcher(matcher).metadataExtractor(extractor).reactiveAdapterStrategy(registry).build();
    assertThat(strategies.encoders()).hasSize(1);
    assertThat(strategies.decoders()).hasSize(1);
    assertThat(strategies.routeMatcher()).isSameAs(matcher);
    assertThat(strategies.metadataExtractor()).isSameAs(extractor);
    assertThat(strategies.reactiveAdapterRegistry()).isSameAs(registry);
}
Also used : CharSequenceEncoder(org.springframework.core.codec.CharSequenceEncoder) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ByteBufferEncoder(org.springframework.core.codec.ByteBufferEncoder) StringDecoder(org.springframework.core.codec.StringDecoder) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mockito.times(org.mockito.Mockito.times) ByteArrayEncoder(org.springframework.core.codec.ByteArrayEncoder) ByteBufferDecoder(org.springframework.core.codec.ByteBufferDecoder) ByteArrayDecoder(org.springframework.core.codec.ByteArrayDecoder) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) DataBufferEncoder(org.springframework.core.codec.DataBufferEncoder) SimpleRouteMatcher(org.springframework.util.SimpleRouteMatcher) DataBufferDecoder(org.springframework.core.codec.DataBufferDecoder) AntPathMatcher(org.springframework.util.AntPathMatcher) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) Mockito.mock(org.mockito.Mockito.mock) ByteArrayEncoder(org.springframework.core.codec.ByteArrayEncoder) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) SimpleRouteMatcher(org.springframework.util.SimpleRouteMatcher) AntPathMatcher(org.springframework.util.AntPathMatcher) ByteArrayDecoder(org.springframework.core.codec.ByteArrayDecoder) Test(org.junit.jupiter.api.Test)

Aggregations

ByteArrayEncoder (org.springframework.core.codec.ByteArrayEncoder)7 Test (org.junit.jupiter.api.Test)4 ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)4 ByteArrayDecoder (org.springframework.core.codec.ByteArrayDecoder)4 ByteBufferEncoder (org.springframework.core.codec.ByteBufferEncoder)4 AntPathMatcher (org.springframework.util.AntPathMatcher)4 SimpleRouteMatcher (org.springframework.util.SimpleRouteMatcher)4 CharSequenceEncoder (org.springframework.core.codec.CharSequenceEncoder)3 DataBufferEncoder (org.springframework.core.codec.DataBufferEncoder)3 ResourceHttpMessageWriter (org.springframework.http.codec.ResourceHttpMessageWriter)3 DefaultMetadataExtractor (org.springframework.messaging.rsocket.DefaultMetadataExtractor)3 RSocketStrategies (org.springframework.messaging.rsocket.RSocketStrategies)3 ArrayList (java.util.ArrayList)2 FormHttpMessageWriter (org.springframework.http.codec.FormHttpMessageWriter)2 ServerSentEventHttpMessageWriter (org.springframework.http.codec.ServerSentEventHttpMessageWriter)2 Jackson2JsonEncoder (org.springframework.http.codec.json.Jackson2JsonEncoder)2 Jaxb2XmlEncoder (org.springframework.http.codec.xml.Jaxb2XmlEncoder)2 Consumer (java.util.function.Consumer)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1