Use Jackson ObjectMapper from AutoConfiguration
- For the message converters that use Jackson ObjectMapper, autowire the ObjectMapper from JacksonAutoConfiguration - This will allow configuration of ObjectMapper using boot configuration properties `JacksonProperties` - Add test This resolves #466
This commit is contained in:
committed by
Marius Bogoevici
parent
4466331266
commit
277d896e1d
@@ -16,6 +16,7 @@
|
||||
package org.springframework.cloud.stream.config;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -39,6 +40,9 @@ import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.tuple.Tuple;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
||||
/**
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
@@ -49,6 +53,9 @@ public class MessageChannelConfigurerTests {
|
||||
@Autowired @Bindings(TestSink.class)
|
||||
private Sink testSink;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Test
|
||||
public void testMessageConverterConfigurer() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
@@ -66,6 +73,12 @@ public class MessageChannelConfigurerTests {
|
||||
assertTrue(latch.await(10, TimeUnit.SECONDS));
|
||||
testSink.input().unsubscribe(messageHandler);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testObjectMapperConfig() {
|
||||
assertNotNull( "ObjectMapper should exist", objectMapper);
|
||||
assertTrue("SerializationFeature 'WRITE_DATES_AS_TIMESTAMPS' should be disabled", !objectMapper.getSerializationConfig().isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS));
|
||||
}
|
||||
|
||||
@EnableBinding(Sink.class)
|
||||
@EnableAutoConfiguration
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
spring.cloud.stream.bindings.input.destination=configure1
|
||||
spring.cloud.stream.bindings.input.contentType=application/x-spring-tuple
|
||||
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS:false
|
||||
|
||||
Reference in New Issue
Block a user