use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class CorrelationIdTests method testCorrelationNotCopiedFromRequestMessgeIdIfAlreadySetByHandler.
@Test
public void testCorrelationNotCopiedFromRequestMessgeIdIfAlreadySetByHandler() throws Exception {
Message<?> message = new GenericMessage<String>("test");
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel(1);
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "createMessage");
serviceActivator.setOutputChannel(outputChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, serviceActivator);
endpoint.start();
assertTrue(inputChannel.send(message));
Message<?> reply = outputChannel.receive(0);
assertEquals("456-XYZ", new IntegrationMessageHeaderAccessor(reply).getCorrelationId());
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class CorrelationIdTests method testCorrelationIdCopiedFromMessageCorrelationIdIfAvailable.
@Test
public void testCorrelationIdCopiedFromMessageCorrelationIdIfAvailable() {
Message<String> message = MessageBuilder.withPayload("test").setCorrelationId("correlationId").build();
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel(1);
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "upperCase");
serviceActivator.setOutputChannel(outputChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, serviceActivator);
endpoint.start();
assertTrue(inputChannel.send(message));
Message<?> reply = outputChannel.receive(0);
assertEquals(new IntegrationMessageHeaderAccessor(message).getCorrelationId(), new IntegrationMessageHeaderAccessor(reply).getCorrelationId());
assertTrue(new IntegrationMessageHeaderAccessor(message).getCorrelationId().equals(new IntegrationMessageHeaderAccessor(reply).getCorrelationId()));
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class MethodInvokingReleaseStrategyTests method testAdapterWithWildcardParametrizedMessageBasedMethod.
@Test
public void testAdapterWithWildcardParametrizedMessageBasedMethod() {
class TestReleaseStrategy {
@SuppressWarnings("unused")
public boolean checkCompletenessOnListOfMessagesParametrizedWithWildcard(List<Message<?>> messages) {
Assert.assertTrue(messages.size() > 0);
return messages.size() > new IntegrationMessageHeaderAccessor(messages.iterator().next()).getSequenceSize();
}
}
ReleaseStrategy adapter = new MethodInvokingReleaseStrategy(new TestReleaseStrategy(), "checkCompletenessOnListOfMessagesParametrizedWithWildcard");
MessageGroup messages = createListOfMessages(3);
Assert.assertTrue(adapter.canRelease(messages));
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class MethodInvokingReleaseStrategyTests method testAdapterWithTypeParametrizedMessageBasedMethod.
@Test
public void testAdapterWithTypeParametrizedMessageBasedMethod() {
class TestReleaseStrategy {
@SuppressWarnings("unused")
public boolean checkCompletenessOnListOfMessagesParametrizedWithString(List<Message<String>> messages) {
Assert.assertTrue(messages.size() > 0);
return messages.size() > new IntegrationMessageHeaderAccessor(messages.iterator().next()).getSequenceSize();
}
}
ReleaseStrategy adapter = new MethodInvokingReleaseStrategy(new TestReleaseStrategy(), "checkCompletenessOnListOfMessagesParametrizedWithString");
MessageGroup messages = createListOfMessages(3);
Assert.assertTrue(adapter.canRelease(messages));
}
use of org.springframework.integration.IntegrationMessageHeaderAccessor in project spring-integration by spring-projects.
the class HeaderAnnotationTransformerTests method headerAnnotationWithPrefixedHeaderAndRelativeExpression.
// INT-1082
@Test
public void headerAnnotationWithPrefixedHeaderAndRelativeExpression() {
Object target = new TestTransformer();
MethodInvokingTransformer transformer = new MethodInvokingTransformer(target, "evalCorrelationId");
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
handler.setBeanFactory(mock(BeanFactory.class));
handler.afterPropertiesSet();
QueueChannel outputChannel = new QueueChannel();
handler.setOutputChannel(outputChannel);
handler.handleMessage(MessageBuilder.withPayload("test").setCorrelationId("abc").build());
Message<?> result = outputChannel.receive(0);
assertNotNull(result);
assertEquals("ABC", result.getPayload());
assertEquals("abc", new IntegrationMessageHeaderAccessor(result).getCorrelationId());
}
Aggregations