use of org.springframework.messaging.converter.StringMessageConverter in project spring-framework by spring-projects.
the class SubscriptionMethodReturnValueHandlerTests method setup.
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
messagingTemplate.setMessageConverter(new StringMessageConverter());
this.handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);
SimpMessagingTemplate jsonMessagingTemplate = new SimpMessagingTemplate(this.messageChannel);
jsonMessagingTemplate.setMessageConverter(new MappingJackson2MessageConverter());
this.jsonHandler = new SubscriptionMethodReturnValueHandler(jsonMessagingTemplate);
Method method = this.getClass().getDeclaredMethod("getData");
this.subscribeEventReturnType = new MethodParameter(method, -1);
method = this.getClass().getDeclaredMethod("getDataAndSendTo");
this.subscribeEventSendToReturnType = new MethodParameter(method, -1);
method = this.getClass().getDeclaredMethod("handle");
this.messageMappingReturnType = new MethodParameter(method, -1);
method = this.getClass().getDeclaredMethod("getJsonView");
this.subscribeEventJsonViewReturnType = new MethodParameter(method, -1);
}
use of org.springframework.messaging.converter.StringMessageConverter in project spring-framework by spring-projects.
the class TestMessagePostProcessor method convertAndSendPayloadAndMutableHeadersToDestination.
@Test
public void convertAndSendPayloadAndMutableHeadersToDestination() {
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
accessor.setHeader("foo", "bar");
accessor.setLeaveMutable(true);
MessageHeaders messageHeaders = accessor.getMessageHeaders();
this.template.setMessageConverter(new StringMessageConverter());
this.template.convertAndSend("somewhere", "payload", messageHeaders);
MessageHeaders actual = this.template.message.getHeaders();
assertSame(messageHeaders, actual);
assertEquals(new MimeType("text", "plain", StandardCharsets.UTF_8), actual.get(MessageHeaders.CONTENT_TYPE));
assertEquals("bar", actual.get("foo"));
}
use of org.springframework.messaging.converter.StringMessageConverter in project spring-framework by spring-projects.
the class PayloadArgumentResolverTests method supportsParameter.
@Test
public void supportsParameter() throws Exception {
assertTrue(this.resolver.supportsParameter(this.paramAnnotated));
assertTrue(this.resolver.supportsParameter(this.paramNotAnnotated));
PayloadArgumentResolver strictResolver = new PayloadArgumentResolver(new StringMessageConverter(), testValidator(), false);
assertTrue(strictResolver.supportsParameter(this.paramAnnotated));
assertFalse(strictResolver.supportsParameter(this.paramNotAnnotated));
}
use of org.springframework.messaging.converter.StringMessageConverter in project spring-framework by spring-projects.
the class PayloadArgumentResolverTests method setup.
@Before
public void setup() throws Exception {
this.resolver = new PayloadArgumentResolver(new StringMessageConverter(), testValidator());
Method payloadMethod = PayloadArgumentResolverTests.class.getDeclaredMethod("handleMessage", String.class, String.class, Locale.class, String.class, String.class, String.class, String.class);
this.paramAnnotated = new SynthesizingMethodParameter(payloadMethod, 0);
this.paramAnnotatedNotRequired = new SynthesizingMethodParameter(payloadMethod, 1);
this.paramAnnotatedRequired = new SynthesizingMethodParameter(payloadMethod, 2);
this.paramWithSpelExpression = new SynthesizingMethodParameter(payloadMethod, 3);
this.paramValidated = new SynthesizingMethodParameter(payloadMethod, 4);
this.paramValidated.initParameterNameDiscovery(new LocalVariableTableParameterNameDiscoverer());
this.paramValidatedNotAnnotated = new SynthesizingMethodParameter(payloadMethod, 5);
this.paramNotAnnotated = new SynthesizingMethodParameter(payloadMethod, 6);
}
Aggregations