use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class ServiceActivatorEndpointTests method correlationIdSetByHandlerTakesPrecedence.
@Test
public void correlationIdSetByHandlerTakesPrecedence() {
QueueChannel replyChannel = new QueueChannel(1);
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new Object() {
@SuppressWarnings("unused")
public Message<?> handle(Message<?> message) {
return MessageBuilder.fromMessage(message).setCorrelationId("ABC-123").build();
}
}, "handle");
Message<String> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
endpoint.handleMessage(message);
Message<?> reply = replyChannel.receive(500);
Object correlationId = new IntegrationMessageHeaderAccessor(reply).getCorrelationId();
assertFalse(message.getHeaders().getId().equals(correlationId));
assertEquals("ABC-123", correlationId);
}
use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class ServiceActivatorEndpointTests method correlationIdNotSetIfMessageIsReturnedUnaltered.
@Test
public void correlationIdNotSetIfMessageIsReturnedUnaltered() {
QueueChannel replyChannel = new QueueChannel(1);
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new Object() {
@SuppressWarnings("unused")
public Message<?> handle(Message<?> message) {
return message;
}
}, "handle");
Message<String> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
endpoint.handleMessage(message);
Message<?> reply = replyChannel.receive(500);
assertNull(new IntegrationMessageHeaderAccessor(reply).getCorrelationId());
}
use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class ServiceActivatorEndpointTests method outputChannelTakesPrecedence.
@Test
public void outputChannelTakesPrecedence() {
QueueChannel channel1 = new QueueChannel(1);
QueueChannel channel2 = new QueueChannel(1);
ServiceActivatingHandler endpoint = this.createEndpoint();
endpoint.setOutputChannel(channel1);
Message<?> message = MessageBuilder.withPayload("foo").setReplyChannel(channel2).build();
endpoint.handleMessage(message);
Message<?> reply1 = channel1.receive(0);
assertNotNull(reply1);
assertEquals("FOO", reply1.getPayload());
Message<?> reply2 = channel2.receive(0);
assertNull(reply2);
}
use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class ServiceActivatorEndpointTests method outputChannel.
@Test
public void outputChannel() {
QueueChannel channel = new QueueChannel(1);
ServiceActivatingHandler endpoint = this.createEndpoint();
endpoint.setOutputChannel(channel);
Message<?> message = MessageBuilder.withPayload("foo").build();
endpoint.handleMessage(message);
Message<?> reply = channel.receive(0);
assertNotNull(reply);
assertEquals("FOO", reply.getPayload());
}
use of org.springframework.integration.handler.ServiceActivatingHandler in project spring-integration by spring-projects.
the class ServiceActivatorEndpointTests method testBeanFactoryPopulation.
@Test
public void testBeanFactoryPopulation() {
ServiceActivatingHandler endpoint = this.createEndpoint();
BeanFactory mock = mock(BeanFactory.class);
endpoint.setBeanFactory(mock);
endpoint.afterPropertiesSet();
Object beanFactory = TestUtils.getPropertyValue(endpoint, "processor.beanFactory");
assertNotNull(beanFactory);
assertSame(mock, beanFactory);
}
Aggregations