Search in sources :

Example 1 with StringMessageConverter

use of org.springframework.messaging.converter.StringMessageConverter in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method brokerMessageConverter.

@Bean
public CompositeMessageConverter brokerMessageConverter() {
    List<MessageConverter> converters = new ArrayList<>();
    boolean registerDefaults = configureMessageConverters(converters);
    if (registerDefaults) {
        converters.add(new StringMessageConverter());
        converters.add(new ByteArrayMessageConverter());
        if (jackson2Present) {
            converters.add(createJacksonConverter());
        }
    }
    return new CompositeMessageConverter(converters);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) ArrayList(java.util.ArrayList) CompositeMessageConverter(org.springframework.messaging.converter.CompositeMessageConverter) MessageConverter(org.springframework.messaging.converter.MessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) CompositeMessageConverter(org.springframework.messaging.converter.CompositeMessageConverter) Bean(org.springframework.context.annotation.Bean)

Example 2 with StringMessageConverter

use of org.springframework.messaging.converter.StringMessageConverter in project spring-framework by spring-projects.

the class DefaultStompSessionTests method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    this.sessionHandler = mock(StompSessionHandler.class);
    this.connectHeaders = new StompHeaders();
    this.session = new DefaultStompSession(this.sessionHandler, this.connectHeaders);
    this.session.setMessageConverter(new StringMessageConverter());
    SettableListenableFuture<Void> future = new SettableListenableFuture<>();
    future.set(null);
    when(this.connection.send(this.messageCaptor.capture())).thenReturn(future);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) SettableListenableFuture(org.springframework.util.concurrent.SettableListenableFuture) Before(org.junit.Before)

Example 3 with StringMessageConverter

use of org.springframework.messaging.converter.StringMessageConverter in project spring-framework by spring-projects.

the class WebSocketStompClientIntegrationTests method setUp.

@Before
public void setUp() throws Exception {
    logger.debug("Setting up before '" + this.testName.getMethodName() + "'");
    this.wac = new AnnotationConfigWebApplicationContext();
    this.wac.register(TestConfig.class);
    this.wac.refresh();
    this.server = new TomcatWebSocketTestServer();
    this.server.setup();
    this.server.deployConfig(this.wac);
    this.server.start();
    WebSocketClient webSocketClient = new StandardWebSocketClient();
    this.stompClient = new WebSocketStompClient(webSocketClient);
    this.stompClient.setMessageConverter(new StringMessageConverter());
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) TomcatWebSocketTestServer(org.springframework.web.socket.TomcatWebSocketTestServer) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) WebSocketClient(org.springframework.web.socket.client.WebSocketClient) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Before(org.junit.Before)

Example 4 with StringMessageConverter

use of org.springframework.messaging.converter.StringMessageConverter in project spring-framework by spring-projects.

the class ReactorNettyTcpStompClientTests method setUp.

@Before
public void setUp() throws Exception {
    logger.debug("Setting up before '" + this.testName.getMethodName() + "'");
    int port = SocketUtils.findAvailableTcpPort(61613);
    this.activeMQBroker = new BrokerService();
    this.activeMQBroker.addConnector("stomp://127.0.0.1:" + port);
    this.activeMQBroker.setStartAsync(false);
    this.activeMQBroker.setPersistent(false);
    this.activeMQBroker.setUseJmx(false);
    this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5);
    this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5);
    this.activeMQBroker.start();
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.afterPropertiesSet();
    this.client = new ReactorNettyTcpStompClient("127.0.0.1", port);
    this.client.setMessageConverter(new StringMessageConverter());
    this.client.setTaskScheduler(taskScheduler);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) BrokerService(org.apache.activemq.broker.BrokerService) ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Before(org.junit.Before)

Example 5 with StringMessageConverter

use of org.springframework.messaging.converter.StringMessageConverter 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)

Aggregations

StringMessageConverter (org.springframework.messaging.converter.StringMessageConverter)9 Before (org.junit.Before)6 Method (java.lang.reflect.Method)3 MappingJackson2MessageConverter (org.springframework.messaging.converter.MappingJackson2MessageConverter)3 Test (org.junit.Test)2 SynthesizingMethodParameter (org.springframework.core.annotation.SynthesizingMethodParameter)2 SimpMessagingTemplate (org.springframework.messaging.simp.SimpMessagingTemplate)2 ArrayList (java.util.ArrayList)1 BrokerService (org.apache.activemq.broker.BrokerService)1 Bean (org.springframework.context.annotation.Bean)1 LocalVariableTableParameterNameDiscoverer (org.springframework.core.LocalVariableTableParameterNameDiscoverer)1 MethodParameter (org.springframework.core.MethodParameter)1 MessageHeaders (org.springframework.messaging.MessageHeaders)1 ByteArrayMessageConverter (org.springframework.messaging.converter.ByteArrayMessageConverter)1 CompositeMessageConverter (org.springframework.messaging.converter.CompositeMessageConverter)1 MessageConverter (org.springframework.messaging.converter.MessageConverter)1 MessageHeaderAccessor (org.springframework.messaging.support.MessageHeaderAccessor)1 ThreadPoolTaskScheduler (org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)1 MimeType (org.springframework.util.MimeType)1 SettableListenableFuture (org.springframework.util.concurrent.SettableListenableFuture)1