use of org.springframework.integration.support.json.JsonOutboundMessageMapper in project spring-integration by spring-projects.
the class JsonOutboundMessageMapperTests method testFromMessageWithHeadersAndBeanPayload.
@Test
public void testFromMessageWithHeadersAndBeanPayload() throws Exception {
TestBean payload = new TestBean();
Message<TestBean> testMessage = MessageBuilder.withPayload(payload).build();
JsonOutboundMessageMapper mapper = new JsonOutboundMessageMapper();
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);
}
use of org.springframework.integration.support.json.JsonOutboundMessageMapper in project spring-integration by spring-projects.
the class StoredProcOutboundGatewayWithSpelIntegrationTests method testInt2865SqlReturnType.
@Test
@Transactional
public void testInt2865SqlReturnType() throws Exception {
Mockito.reset(this.clobSqlReturnType);
Message<String> testMessage = MessageBuilder.withPayload("TEST").setHeader("FOO", "BAR").build();
String messageId = testMessage.getHeaders().getId().toString();
String jsonMessage = new JsonOutboundMessageMapper().fromMessage(testMessage);
this.jdbcTemplate.update("INSERT INTO json_message VALUES (?,?)", messageId, jsonMessage);
this.getMessageChannel.send(new GenericMessage<String>(messageId));
Message<?> resultMessage = this.output2Channel.receive(10000);
assertNotNull(resultMessage);
Object resultPayload = resultMessage.getPayload();
assertTrue(resultPayload instanceof String);
Message<?> message = new JsonInboundMessageMapper(String.class, new Jackson2JsonMessageParser()).toMessage((String) resultPayload);
assertEquals(testMessage.getPayload(), message.getPayload());
assertEquals(testMessage.getHeaders().get("FOO"), message.getHeaders().get("FOO"));
Mockito.verify(clobSqlReturnType).getTypeValue(Mockito.any(CallableStatement.class), Mockito.eq(2), Mockito.eq(JdbcTypesEnum.CLOB.getCode()), Mockito.eq((String) null));
}
Aggregations