@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 testFromMessageWithHeadersAndStringPayload() throws Exception {
   Message<String> testMessage = MessageBuilder.withPayload("myPayloadStuff").build();
   OutboundJsonMessageMapper mapper = new OutboundJsonMessageMapper();
   String result = mapper.fromMessage(testMessage);
   assertTrue(result.contains("\"headers\":{"));
   assertTrue(result.contains("\"$timestamp\":" + testMessage.getHeaders().getTimestamp()));
   assertTrue(result.contains("\"$id\":\"" + testMessage.getHeaders().getId() + "\""));
   assertTrue(result.contains("\"payload\":\"myPayloadStuff\""));
 }
 @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);
 }
 @Test
 public void testFromMessageWithHeadersAndBeanPayload() throws Exception {
   TestBean payload = new TestBean();
   Message<TestBean> testMessage = MessageBuilder.withPayload(payload).build();
   OutboundJsonMessageMapper mapper = new OutboundJsonMessageMapper();
   String result = mapper.fromMessage(testMessage);
   assertTrue(result.contains("\"headers\":{"));
   assertTrue(result.contains("\"$timestamp\":" + testMessage.getHeaders().getTimestamp()));
   assertTrue(result.contains("\"$id\":\"" + testMessage.getHeaders().getId() + "\""));
   TestBean parsedPayload = extractJsonPayloadToTestBean(result);
   assertEquals(payload, parsedPayload);
 }