Search in sources :

Example 11 with MessageConverter

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

the class MessageBrokerConfigurationTests method configureMessageConvertersCustomAndDefault.

@Test
public void configureMessageConvertersCustomAndDefault() {
    final MessageConverter testConverter = mock(MessageConverter.class);
    AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {

        @Override
        protected boolean configureMessageConverters(List<MessageConverter> messageConverters) {
            messageConverters.add(testConverter);
            return true;
        }
    };
    CompositeMessageConverter compositeConverter = config.brokerMessageConverter();
    assertThat(compositeConverter.getConverters().size(), Matchers.is(4));
    Iterator<MessageConverter> iterator = compositeConverter.getConverters().iterator();
    assertThat(iterator.next(), Matchers.is(testConverter));
    assertThat(iterator.next(), Matchers.instanceOf(StringMessageConverter.class));
    assertThat(iterator.next(), Matchers.instanceOf(ByteArrayMessageConverter.class));
    assertThat(iterator.next(), Matchers.instanceOf(MappingJackson2MessageConverter.class));
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) List(java.util.List) ArrayList(java.util.ArrayList) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) CompositeMessageConverter(org.springframework.messaging.converter.CompositeMessageConverter) MessageConverter(org.springframework.messaging.converter.MessageConverter) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) CompositeMessageConverter(org.springframework.messaging.converter.CompositeMessageConverter) Test(org.junit.Test)

Aggregations

MessageConverter (org.springframework.messaging.converter.MessageConverter)11 CompositeMessageConverter (org.springframework.messaging.converter.CompositeMessageConverter)7 Test (org.junit.Test)6 ByteArrayMessageConverter (org.springframework.messaging.converter.ByteArrayMessageConverter)6 MappingJackson2MessageConverter (org.springframework.messaging.converter.MappingJackson2MessageConverter)6 StringMessageConverter (org.springframework.messaging.converter.StringMessageConverter)6 ArrayList (java.util.ArrayList)4 List (java.util.List)2 MessageHeaders (org.springframework.messaging.MessageHeaders)2 ContentTypeResolver (org.springframework.messaging.converter.ContentTypeResolver)2 DefaultContentTypeResolver (org.springframework.messaging.converter.DefaultContentTypeResolver)2 MessageConversionException (org.springframework.messaging.converter.MessageConversionException)2 SimpleMessageConverter (org.springframework.messaging.converter.SimpleMessageConverter)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 Bean (org.springframework.context.annotation.Bean)1 SmartMessageConverter (org.springframework.messaging.converter.SmartMessageConverter)1 InvocableHandlerMethod (org.springframework.messaging.handler.invocation.InvocableHandlerMethod)1 SimpMessagingTemplate (org.springframework.messaging.simp.SimpMessagingTemplate)1 SimpAnnotationMethodMessageHandler (org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler)1