use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class ConnectionToConnectionTests method testConnectRaw.
@Test
public void testConnectRaw() throws Exception {
ByteArrayRawSerializer serializer = new ByteArrayRawSerializer();
clientNet.setSerializer(serializer);
serverNet.setDeserializer(serializer);
clientNet.start();
TcpConnection connection = clientNet.getConnection();
connection.send(MessageBuilder.withPayload("Test").build());
connection.close();
Message<?> message = serverSideChannel.receive(10000);
assertNotNull(message);
MessageHistory history = MessageHistory.read(message);
// org.springframework.integration.test.util.TestUtils
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "gwNet", 0);
assertNotNull(componentHistoryRecord);
assertTrue(componentHistoryRecord.get("type").equals("ip:tcp-inbound-gateway"));
assertNotNull(message);
assertEquals("Test", new String((byte[]) message.getPayload()));
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testWithMessageHistory.
@Test
@RedisAvailable
public void testWithMessageHistory() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<?> message = new GenericMessage<>("Hello");
DirectChannel fooChannel = new DirectChannel();
fooChannel.setBeanName("fooChannel");
DirectChannel barChannel = new DirectChannel();
barChannel.setBeanName("barChannel");
message = MessageHistory.write(message, fooChannel);
message = MessageHistory.write(message, barChannel);
store.addMessagesToGroup(this.groupId, message);
message = store.getMessageGroup(this.groupId).getMessages().iterator().next();
MessageHistory messageHistory = MessageHistory.read(message);
assertNotNull(messageHistory);
assertEquals(2, messageHistory.size());
Properties fooChannelHistory = messageHistory.get(0);
assertEquals("fooChannel", fooChannelHistory.get("name"));
assertEquals("channel", fooChannelHistory.get("type"));
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class GemfireMessageStoreTests method testWithMessageHistory.
@Test
public void testWithMessageHistory() throws Exception {
GemfireMessageStore store = new GemfireMessageStore(region);
Message<?> message = new GenericMessage<String>("Hello");
DirectChannel fooChannel = new DirectChannel();
fooChannel.setBeanName("fooChannel");
DirectChannel barChannel = new DirectChannel();
barChannel.setBeanName("barChannel");
message = MessageHistory.write(message, fooChannel);
message = MessageHistory.write(message, barChannel);
store.addMessage(message);
message = store.getMessage(message.getHeaders().getId());
MessageHistory messageHistory = MessageHistory.read(message);
assertNotNull(messageHistory);
assertEquals(2, messageHistory.size());
Properties fooChannelHistory = messageHistory.get(0);
assertEquals("fooChannel", fooChannelHistory.get("name"));
assertEquals("channel", fooChannelHistory.get("type"));
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class WebServiceInboundGatewayParserTests method testMessageHistoryWithMarshallingGateway.
@Test
public void testMessageHistoryWithMarshallingGateway() throws Exception {
MessageContext context = new DefaultMessageContext(new StubMessageFactory());
Unmarshaller unmarshaller = mock(Unmarshaller.class);
when(unmarshaller.unmarshal((Source) Mockito.any())).thenReturn("hello");
marshallingGateway.setUnmarshaller(unmarshaller);
marshallingGateway.invoke(context);
Message<?> message = requestsMarshalling.receive(100);
MessageHistory history = MessageHistory.read(message);
assertNotNull(history);
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "marshalling", 0);
assertNotNull(componentHistoryRecord);
assertEquals("ws:inbound-gateway", componentHistoryRecord.get("type"));
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class WebServiceInboundGatewayParserTests method testMessageHistoryWithSimpleGateway.
@Test
public void testMessageHistoryWithSimpleGateway() throws Exception {
MessageContext context = new DefaultMessageContext(new StubMessageFactory());
payloadExtractingGateway.invoke(context);
Message<?> message = requestsSimple.receive(100);
MessageHistory history = MessageHistory.read(message);
assertNotNull(history);
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "extractsPayload", 0);
assertNotNull(componentHistoryRecord);
assertEquals("ws:inbound-gateway", componentHistoryRecord.get("type"));
}
Aggregations