use of org.springframework.integration.transformer.MessageTransformingHandler in project spring-integration by spring-projects.
the class HeaderAnnotationTransformerTests method headerAnnotationWithPrefixedHeader.
// INT-1082
@Test
public void headerAnnotationWithPrefixedHeader() {
Object target = new TestTransformer();
MethodInvokingTransformer transformer = new MethodInvokingTransformer(target, "appendCorrelationId");
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("testabc", result.getPayload());
assertEquals("abc", new IntegrationMessageHeaderAccessor(result).getCorrelationId());
}
use of org.springframework.integration.transformer.MessageTransformingHandler in project spring-integration by spring-projects.
the class HeaderAnnotationTransformerTests method headerAnnotationWithUnprefixedHeader.
@Test
public void headerAnnotationWithUnprefixedHeader() {
Object target = new TestTransformer();
MethodInvokingTransformer transformer = new MethodInvokingTransformer(target, "appendFoo");
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
handler.setBeanFactory(mock(BeanFactory.class));
handler.afterPropertiesSet();
QueueChannel outputChannel = new QueueChannel();
handler.setOutputChannel(outputChannel);
handler.handleMessage(MessageBuilder.withPayload("test").setHeader("foo", "bar").build());
Message<?> result = outputChannel.receive(0);
assertNotNull(result);
assertEquals("testbar", result.getPayload());
assertEquals("bar", result.getHeaders().get("foo"));
}
use of org.springframework.integration.transformer.MessageTransformingHandler in project spring-integration by spring-projects.
the class HeaderAnnotationTransformerTests method headerAnnotationWithUnprefixedHeaderAndRelativeExpression.
@Test
public void headerAnnotationWithUnprefixedHeaderAndRelativeExpression() {
Object target = new TestTransformer();
MethodInvokingTransformer transformer = new MethodInvokingTransformer(target, "evalFoo");
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
handler.setBeanFactory(mock(BeanFactory.class));
handler.afterPropertiesSet();
QueueChannel outputChannel = new QueueChannel();
handler.setOutputChannel(outputChannel);
handler.handleMessage(MessageBuilder.withPayload("test").setHeader("foo", "bar").build());
Message<?> result = outputChannel.receive(0);
assertNotNull(result);
assertEquals("BAR", result.getPayload());
assertEquals("bar", result.getHeaders().get("foo"));
}
use of org.springframework.integration.transformer.MessageTransformingHandler in project spring-integration by spring-projects.
the class TransformerFactoryBean method createExpressionEvaluatingHandler.
@Override
protected MessageHandler createExpressionEvaluatingHandler(Expression expression) {
Transformer transformer = new ExpressionEvaluatingTransformer(expression);
MessageTransformingHandler handler = this.createHandler(transformer);
handler.setPrimaryExpression(expression);
return handler;
}
use of org.springframework.integration.transformer.MessageTransformingHandler in project spring-integration by spring-projects.
the class TransformerFactoryBean method createHandler.
protected MessageTransformingHandler createHandler(Transformer transformer) {
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
this.postProcessReplyProducer(handler);
return handler;
}
Aggregations