use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class MessagingAnnotationsWithBeanAnnotationTests method testMessagingAnnotationsFlow.
@Test
public void testMessagingAnnotationsFlow() {
Stream.of(this.sourcePollingChannelAdapters).forEach(a -> a.start());
// this.sourcePollingChannelAdapter.start();
for (int i = 0; i < 10; i++) {
Message<?> receive = this.discardChannel.receive(10000);
assertNotNull(receive);
assertTrue(((Integer) receive.getPayload()) % 2 == 0);
receive = this.counterErrorChannel.receive(10000);
assertNotNull(receive);
assertThat(receive, instanceOf(ErrorMessage.class));
assertThat(receive.getPayload(), instanceOf(MessageRejectedException.class));
MessageRejectedException exception = (MessageRejectedException) receive.getPayload();
assertThat(exception.getMessage(), containsString("MessageFilter " + "'messagingAnnotationsWithBeanAnnotationTests.ContextConfiguration.filter.filter.handler'" + " rejected Message"));
}
for (Message<?> message : collector) {
assertFalse(((Integer) message.getPayload()) % 2 == 0);
MessageHistory messageHistory = MessageHistory.read(message);
assertNotNull(messageHistory);
String messageHistoryString = messageHistory.toString();
assertThat(messageHistoryString, Matchers.containsString("routerChannel"));
assertThat(messageHistoryString, Matchers.containsString("filterChannel"));
assertThat(messageHistoryString, Matchers.containsString("aggregatorChannel"));
assertThat(messageHistoryString, Matchers.containsString("splitterChannel"));
assertThat(messageHistoryString, Matchers.containsString("serviceChannel"));
assertThat(messageHistoryString, Matchers.not(Matchers.containsString("discardChannel")));
}
assertNull(this.skippedServiceActivator);
assertNull(this.skippedMessageHandler);
assertNull(this.skippedChannel);
assertNull(this.skippedChannel2);
assertNull(this.skippedMessageSource);
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class RoutingSlipTests method testRoutingSlip.
@Test
@SuppressWarnings("unchecked")
public void testRoutingSlip() {
PollableChannel replyChannel = new QueueChannel();
Message<List<String>> request = MessageBuilder.withPayload(Arrays.asList("test1", "test2")).setReplyChannel(replyChannel).setHeader("myRoutingSlipChannel", "channel5").build();
this.input.send(request);
Message<?> reply = replyChannel.receive(10000);
assertNotNull(reply);
List<Message<?>> messages = (List<Message<?>>) reply.getPayload();
for (Message<?> message : messages) {
Map<List<String>, Integer> routingSlip = message.getHeaders().get(IntegrationMessageHeaderAccessor.ROUTING_SLIP, Map.class);
assertEquals(routingSlip.keySet().iterator().next().size(), routingSlip.values().iterator().next().intValue());
MessageHistory messageHistory = MessageHistory.read(message);
List<String> channelNames = Arrays.asList("input", "split", "process", "channel1", "channel2", "channel3", "channel4", "channel5", "aggregate");
for (Properties properties : messageHistory) {
assertTrue(channelNames.contains(properties.getProperty("name")));
}
}
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class MessageHistoryTests method addComponents.
@Test
public void addComponents() {
GenericMessage<String> original = new GenericMessage<String>("foo");
assertNull(MessageHistory.read(original));
Message<String> result1 = MessageHistory.write(original, new TestComponent(1));
MessageHistory history1 = MessageHistory.read(result1);
assertNotNull(history1);
assertEquals("testComponent-1", history1.toString());
Message<String> result2 = MessageHistory.write(result1, new TestComponent(2));
MessageHistory history2 = MessageHistory.read(result2);
assertNotNull(history2);
assertEquals("testComponent-1,testComponent-2", history2.toString());
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class MessageHistoryTests method verifyImmutability.
@Test(expected = UnsupportedOperationException.class)
public void verifyImmutability() {
Message<?> message = MessageHistory.write(MessageBuilder.withPayload("test").build(), new TestComponent(1));
MessageHistory history = MessageHistory.read(message);
history.add(new Properties());
}
use of org.springframework.integration.history.MessageHistory in project spring-integration by spring-projects.
the class MessageHistoryTests method testCorrectMutableMessageAfterWrite.
@Test
public void testCorrectMutableMessageAfterWrite() {
MutableMessage<String> original = new MutableMessage<>("foo");
assertNull(MessageHistory.read(original));
Message<String> result1 = MessageHistory.write(original, new TestComponent(1));
assertThat(result1, instanceOf(MutableMessage.class));
assertSame(original, result1);
MessageHistory history1 = MessageHistory.read(result1);
assertNotNull(history1);
assertEquals("testComponent-1", history1.toString());
Message<String> result2 = MessageHistory.write(result1, new TestComponent(2));
assertSame(original, result2);
MessageHistory history2 = MessageHistory.read(result2);
assertNotNull(history2);
assertEquals("testComponent-1,testComponent-2", history2.toString());
}
Aggregations