use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class MessageFilterTests method filterThrowsExceptionWithChannels.
@Test(expected = MessageRejectedException.class)
public void filterThrowsExceptionWithChannels() {
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
MessageFilter filter = new MessageFilter(message -> false);
filter.setOutputChannel(outputChannel);
filter.setThrowExceptionOnRejection(true);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class MessageFilterTests method filterRejectsSilentlyWithChannels.
@Test
public void filterRejectsSilentlyWithChannels() {
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
MessageFilter filter = new MessageFilter(message -> false);
filter.setOutputChannel(outputChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
assertNull(outputChannel.receive(0));
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class MessageFilterTests method filterDiscardsMessageAndThrowsException.
@Test(expected = MessageRejectedException.class)
public void filterDiscardsMessageAndThrowsException() throws Exception {
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
QueueChannel discardChannel = new QueueChannel();
MessageFilter filter = new MessageFilter(message -> false);
filter.setOutputChannel(outputChannel);
filter.setDiscardChannel(discardChannel);
filter.setThrowExceptionOnRejection(true);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new GenericMessage<String>("test");
try {
assertTrue(inputChannel.send(message));
} catch (Exception e) {
throw e;
} finally {
Message<?> reply = discardChannel.receive(0);
assertNotNull(reply);
assertEquals(message, reply);
assertNull(outputChannel.receive(0));
}
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class MessageFilterTests method filterDiscardsMessage.
@Test
public void filterDiscardsMessage() {
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
QueueChannel discardChannel = new QueueChannel();
MessageFilter filter = new MessageFilter(message -> false);
filter.setOutputChannel(outputChannel);
filter.setDiscardChannel(discardChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
Message<?> reply = discardChannel.receive(0);
assertNotNull(reply);
assertEquals(message, reply);
assertNull(outputChannel.receive(0));
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class GatewayProxyFactoryBeanTests method testCheckedExceptionRethrownAsIs.
@Test(expected = TestException.class)
public void testCheckedExceptionRethrownAsIs() throws Exception {
GatewayProxyFactoryBean proxyFactory = new GatewayProxyFactoryBean();
DirectChannel channel = new DirectChannel();
EventDrivenConsumer consumer = new EventDrivenConsumer(channel, new MessageHandler() {
@Override
public void handleMessage(Message<?> message) {
Method method = ReflectionUtils.findMethod(GatewayProxyFactoryBeanTests.class, "throwTestException");
ReflectionUtils.invokeMethod(method, this);
}
});
consumer.start();
proxyFactory.setDefaultRequestChannel(channel);
proxyFactory.setServiceInterface(TestExceptionThrowingInterface.class);
proxyFactory.setBeanName("testGateway");
proxyFactory.setBeanFactory(mock(BeanFactory.class));
proxyFactory.afterPropertiesSet();
TestExceptionThrowingInterface proxy = (TestExceptionThrowingInterface) proxyFactory.getObject();
proxy.throwCheckedException("test");
}
Aggregations