use of org.springframework.integration.channel.DirectChannel in project spring-integration by spring-projects.
the class MessageFilterTests method filterAcceptsWithChannels.
@Test
public void filterAcceptsWithChannels() {
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
MessageFilter filter = new MessageFilter(message -> true);
filter.setOutputChannel(outputChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
Message<?> reply = outputChannel.receive(0);
assertNotNull(reply);
assertEquals(message.getPayload(), reply.getPayload());
}
use of org.springframework.integration.channel.DirectChannel in project spring-integration by spring-projects.
the class GatewayProxyFactoryBeanTests method testProxiedToStringMethod.
@Test
public void testProxiedToStringMethod() throws Exception {
GatewayProxyFactoryBean proxyFactory = new GatewayProxyFactoryBean();
proxyFactory.setDefaultRequestChannel(new DirectChannel());
proxyFactory.setServiceInterface(TestService.class);
proxyFactory.setBeanName("testGateway");
proxyFactory.setBeanFactory(mock(BeanFactory.class));
proxyFactory.afterPropertiesSet();
Object proxy = proxyFactory.getObject();
String expected = "gateway proxy for";
assertEquals(expected, proxy.toString().substring(0, expected.length()));
}
use of org.springframework.integration.channel.DirectChannel in project spring-integration by spring-projects.
the class CorrelationIdTests method testCorrelationIdPassedIfAvailable.
@Test
public void testCorrelationIdPassedIfAvailable() {
Object correlationId = "123-ABC";
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(correlationId, new IntegrationMessageHeaderAccessor(reply).getCorrelationId());
}
use of org.springframework.integration.channel.DirectChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncSendAndReceiveWithDefaultChannel.
@Test
public void asyncSendAndReceiveWithDefaultChannel() throws Exception {
DirectChannel channel = new DirectChannel();
channel.subscribe(new EchoHandler(200));
AsyncMessagingTemplate template = new AsyncMessagingTemplate();
template.setDefaultDestination(channel);
long start = System.currentTimeMillis();
Future<Message<?>> result = template.asyncSendAndReceive(MessageBuilder.withPayload("test").build());
assertNotNull(result.get());
long elapsed = System.currentTimeMillis() - start;
assertTrue(elapsed >= 200 - safety);
}
use of org.springframework.integration.channel.DirectChannel in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method testMessageEndpointAnnotationInheritedFromInterfaceWithProxy.
@Test
public void testMessageEndpointAnnotationInheritedFromInterfaceWithProxy() {
TestApplicationContext context = TestUtils.createTestApplicationContext();
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
context.registerChannel("inputChannel", inputChannel);
context.registerChannel("outputChannel", outputChannel);
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
ProxyFactory proxyFactory = new ProxyFactory(new SimpleAnnotatedEndpointImplementation());
Object proxy = proxyFactory.getProxy();
postProcessor.postProcessAfterInitialization(proxy, "proxy");
context.refresh();
inputChannel.send(new GenericMessage<String>("ABC"));
Message<?> message = outputChannel.receive(1000);
assertEquals("test-ABC", message.getPayload());
context.stop();
}
Aggregations