Search in sources :

Example 6 with CompositeMessageConverterFactory

use of org.springframework.cloud.stream.converter.CompositeMessageConverterFactory in project spring-cloud-stream by spring-cloud.

the class MessageConverterConfigurerTests method testConfigureOutputChannelWithBadContentType.

// @Test
public void testConfigureOutputChannelWithBadContentType() {
    BindingServiceProperties props = new BindingServiceProperties();
    BindingProperties bindingProps = new BindingProperties();
    bindingProps.setContentType("application/json");
    props.setBindings(Collections.singletonMap("foo", bindingProps));
    CompositeMessageConverterFactory converterFactory = new CompositeMessageConverterFactory(Collections.<MessageConverter>emptyList(), null);
    MessageConverterConfigurer configurer = new MessageConverterConfigurer(props, converterFactory);
    QueueChannel out = new QueueChannel();
    configurer.configureOutputChannel(out, "foo");
    out.send(new GenericMessage<Foo>(new Foo(), Collections.<String, Object>singletonMap(MessageHeaders.CONTENT_TYPE, "bad/ct")));
    Message<?> received = out.receive(0);
    assertThat(received).isNotNull();
    assertThat(received.getPayload()).isInstanceOf(Foo.class);
}
Also used : QueueChannel(org.springframework.integration.channel.QueueChannel) BindingProperties(org.springframework.cloud.stream.config.BindingProperties) BindingServiceProperties(org.springframework.cloud.stream.config.BindingServiceProperties) CompositeMessageConverterFactory(org.springframework.cloud.stream.converter.CompositeMessageConverterFactory)

Aggregations

CompositeMessageConverterFactory (org.springframework.cloud.stream.converter.CompositeMessageConverterFactory)6 BindingServiceProperties (org.springframework.cloud.stream.config.BindingServiceProperties)5 BindingProperties (org.springframework.cloud.stream.config.BindingProperties)4 QueueChannel (org.springframework.integration.channel.QueueChannel)4 Test (org.junit.Test)3 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)2 Method (java.lang.reflect.Method)1 Properties (java.util.Properties)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Ignore (org.junit.Ignore)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)1 ConsumerProperties (org.springframework.cloud.stream.binder.ConsumerProperties)1 DefaultBinderFactory (org.springframework.cloud.stream.binder.DefaultBinderFactory)1 ExtendedProducerProperties (org.springframework.cloud.stream.binder.ExtendedProducerProperties)1 ExtendedPropertiesBinder (org.springframework.cloud.stream.binder.ExtendedPropertiesBinder)1 ProducerProperties (org.springframework.cloud.stream.binder.ProducerProperties)1