@Test public void testFromMessageExtractStringPayload() throws Exception { Message<String> testMessage = MessageBuilder.withPayload("myPayloadStuff").build(); String expected = "\"myPayloadStuff\""; OutboundJsonMessageMapper mapper = new OutboundJsonMessageMapper(); mapper.setShouldExtractPayload(true); String result = mapper.fromMessage(testMessage); assertEquals(expected, result); }
@Test public void testFromMessageExtractBeanPayload() throws Exception { TestBean payload = new TestBean(); Message<TestBean> testMessage = MessageBuilder.withPayload(payload).build(); OutboundJsonMessageMapper mapper = new OutboundJsonMessageMapper(); mapper.setShouldExtractPayload(true); String result = mapper.fromMessage(testMessage); assertTrue(!result.contains("headers")); TestBean parsedPayload = objectMapper.readValue(result, TestBean.class); assertEquals(payload, parsedPayload); }