use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class CGLibProxyHandlerTests method testProxyBridge.
@Test
public void testProxyBridge() {
assertTrue(AopUtils.isCglibProxy(this.bridge));
this.bridge.handleMessage(new GenericMessage<>("foo"));
Message<?> received = this.out.receive(0);
assertNotNull(received);
assertNotNull(received.getHeaders().get(MessageHistory.HEADER_NAME));
MessageHistory history = received.getHeaders().get(MessageHistory.HEADER_NAME, MessageHistory.class);
assertThat(history.size(), equalTo(2));
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class HttpInboundChannelAdapterParserTests method postRequestWithTextContentOk.
@Test
public void postRequestWithTextContentOk() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
request.setContent("test".getBytes());
request.setContentType("text/plain");
MockHttpServletResponse response = new MockHttpServletResponse();
postOnlyAdapter.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
Message<?> message = requests.receive(0);
MessageHistory history = MessageHistory.read(message);
assertNotNull(history);
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "postOnlyAdapter", 0);
assertNotNull(componentHistoryRecord);
assertEquals("http:inbound-channel-adapter", componentHistoryRecord.get("type"));
assertNotNull(message);
assertEquals("test", message.getPayload());
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class FileMessageHistoryTests method testMessageHistory.
@Test
public void testMessageHistory() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("file-message-history-context.xml", getClass());
TemporaryFolder input = context.getBean(TemporaryFolder.class);
File file = input.newFile("FileMessageHistoryTest.txt");
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write("hello");
out.close();
PollableChannel outChannel = context.getBean("outChannel", PollableChannel.class);
Message<?> message = outChannel.receive(10000);
assertThat(message, is(notNullValue()));
MessageHistory history = MessageHistory.read(message);
assertThat(history, is(notNullValue()));
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "fileAdapter", 0);
assertNotNull(componentHistoryRecord);
assertEquals("file:inbound-channel-adapter", componentHistoryRecord.get("type"));
context.close();
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class GemfireGroupStoreTests method testWithMessageHistory.
@Test
public void testWithMessageHistory() throws Exception {
GemfireMessageStore store = new GemfireMessageStore(region);
store.getMessageGroup(1);
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.addMessagesToGroup(1, message);
message = store.getMessageGroup(1).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 JdbcPollingChannelAdapterParserTests method testSimpleInboundChannelAdapter.
@Test
public void testSimpleInboundChannelAdapter() {
setUp("pollingForMapJdbcInboundChannelAdapterTest.xml", getClass());
this.jdbcTemplate.update("insert into item values(1,'',2)");
Message<?> message = messagingTemplate.receive();
assertNotNull("No message found ", message);
assertTrue("Wrong payload type expected instance of List", message.getPayload() instanceof List<?>);
MessageHistory history = MessageHistory.read(message);
assertNotNull(history);
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "jdbcAdapter", 0);
assertNotNull(componentHistoryRecord);
assertEquals("jdbc:inbound-channel-adapter", componentHistoryRecord.get("type"));
}
Aggregations