use of org.springframework.messaging.handler.invocation.reactive.TestEncoderMethodReturnValueHandler in project spring-framework by spring-projects.
the class MessageMappingMessageHandlerTests method initMesssageHandler.
private MessageMappingMessageHandler initMesssageHandler() {
List<Decoder<?>> decoders = Collections.singletonList(StringDecoder.allMimeTypes());
List<Encoder<?>> encoders = Collections.singletonList(CharSequenceEncoder.allMimeTypes());
ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance();
this.returnValueHandler = new TestEncoderMethodReturnValueHandler(encoders, registry);
PropertySource<?> source = new MapPropertySource("test", Collections.singletonMap("path", "path123"));
StaticApplicationContext context = new StaticApplicationContext();
context.getEnvironment().getPropertySources().addFirst(source);
context.registerSingleton("testController", TestController.class);
context.refresh();
MessageMappingMessageHandler messageHandler = new MessageMappingMessageHandler();
messageHandler.getReturnValueHandlerConfigurer().addCustomHandler(this.returnValueHandler);
messageHandler.setApplicationContext(context);
messageHandler.setEmbeddedValueResolver(new EmbeddedValueResolver(context.getBeanFactory()));
messageHandler.setDecoders(decoders);
messageHandler.afterPropertiesSet();
return messageHandler;
}
Aggregations