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());
}
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);
}
Aggregations