Search in sources :

Example 6 with SimpMessagingTemplate

use of org.springframework.messaging.simp.SimpMessagingTemplate in project spring-framework by spring-projects.

the class SendToMethodReturnValueHandlerTests method setup.

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
    messagingTemplate.setMessageConverter(new StringMessageConverter());
    this.handler = new SendToMethodReturnValueHandler(messagingTemplate, true);
    this.handlerAnnotationNotRequired = new SendToMethodReturnValueHandler(messagingTemplate, false);
    SimpMessagingTemplate jsonMessagingTemplate = new SimpMessagingTemplate(this.messageChannel);
    jsonMessagingTemplate.setMessageConverter(new MappingJackson2MessageConverter());
    this.jsonHandler = new SendToMethodReturnValueHandler(jsonMessagingTemplate, true);
    Method method = getClass().getDeclaredMethod("handleNoAnnotations");
    this.noAnnotationsReturnType = new SynthesizingMethodParameter(method, -1);
    method = getClass().getDeclaredMethod("handleAndSendToDefaultDestination");
    this.sendToDefaultDestReturnType = new SynthesizingMethodParameter(method, -1);
    method = getClass().getDeclaredMethod("handleAndSendTo");
    this.sendToReturnType = new SynthesizingMethodParameter(method, -1);
    method = getClass().getDeclaredMethod("handleAndSendToWithPlaceholders");
    this.sendToWithPlaceholdersReturnType = new SynthesizingMethodParameter(method, -1);
    method = getClass().getDeclaredMethod("handleAndSendToUser");
    this.sendToUserReturnType = new SynthesizingMethodParameter(method, -1);
    method = getClass().getDeclaredMethod("handleAndSendToUserSingleSession");
    this.sendToUserSingleSessionReturnType = new SynthesizingMethodParameter(method, -1);
    method = getClass().getDeclaredMethod("handleAndSendToUserDefaultDestination");
    this.sendToUserDefaultDestReturnType = new SynthesizingMethodParameter(method, -1);
    method = getClass().getDeclaredMethod("handleAndSendToUserDefaultDestinationSingleSession");
    this.sendToUserSingleSessionDefaultDestReturnType = new SynthesizingMethodParameter(method, -1);
    method = getClass().getDeclaredMethod("handleAndSendToJsonView");
    this.jsonViewReturnType = new SynthesizingMethodParameter(method, -1);
    method = SendToTestBean.class.getDeclaredMethod("handleNoAnnotation");
    this.defaultNoAnnotation = new SynthesizingMethodParameter(method, -1);
    method = SendToTestBean.class.getDeclaredMethod("handleAndSendToDefaultDestination");
    this.defaultEmptyAnnotation = new SynthesizingMethodParameter(method, -1);
    method = SendToTestBean.class.getDeclaredMethod("handleAndSendToOverride");
    this.defaultOverrideAnnotation = new SynthesizingMethodParameter(method, -1);
    method = SendToUserTestBean.class.getDeclaredMethod("handleNoAnnotation");
    this.userDefaultNoAnnotation = new SynthesizingMethodParameter(method, -1);
    method = SendToUserTestBean.class.getDeclaredMethod("handleAndSendToDefaultDestination");
    this.userDefaultEmptyAnnotation = new SynthesizingMethodParameter(method, -1);
    method = SendToUserTestBean.class.getDeclaredMethod("handleAndSendToOverride");
    this.userDefaultOverrideAnnotation = new SynthesizingMethodParameter(method, -1);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) SimpMessagingTemplate(org.springframework.messaging.simp.SimpMessagingTemplate) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) Method(java.lang.reflect.Method) Before(org.junit.Before)

Example 7 with SimpMessagingTemplate

use of org.springframework.messaging.simp.SimpMessagingTemplate 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);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) SimpMessagingTemplate(org.springframework.messaging.simp.SimpMessagingTemplate) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) Method(java.lang.reflect.Method) MethodParameter(org.springframework.core.MethodParameter) Before(org.junit.Before)

Aggregations

SimpMessagingTemplate (org.springframework.messaging.simp.SimpMessagingTemplate)7 Before (org.junit.Before)5 MappingJackson2MessageConverter (org.springframework.messaging.converter.MappingJackson2MessageConverter)4 StringMessageConverter (org.springframework.messaging.converter.StringMessageConverter)3 Method (java.lang.reflect.Method)2 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)2 Test (org.junit.Test)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 Bean (org.springframework.context.annotation.Bean)1 MethodParameter (org.springframework.core.MethodParameter)1 SynthesizingMethodParameter (org.springframework.core.annotation.SynthesizingMethodParameter)1 SubscribableChannel (org.springframework.messaging.SubscribableChannel)1 ByteArrayMessageConverter (org.springframework.messaging.converter.ByteArrayMessageConverter)1 CompositeMessageConverter (org.springframework.messaging.converter.CompositeMessageConverter)1 ContentTypeResolver (org.springframework.messaging.converter.ContentTypeResolver)1 DefaultContentTypeResolver (org.springframework.messaging.converter.DefaultContentTypeResolver)1 MessageConverter (org.springframework.messaging.converter.MessageConverter)1 SimpMessageSendingOperations (org.springframework.messaging.simp.SimpMessageSendingOperations)1 SimpAnnotationMethodMessageHandler (org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler)1