use of org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer in project spring-integration by spring-projects.
the class TcpConnectionEventListenerTests method testNoFilter.
@Test
public void testNoFilter() {
ApplicationEventListeningMessageProducer eventProducer = new ApplicationEventListeningMessageProducer();
QueueChannel outputChannel = new QueueChannel();
eventProducer.setOutputChannel(outputChannel);
eventProducer.setEventTypes(TcpConnectionEvent.class);
BeanFactory mock = mock(BeanFactory.class);
given(mock.getBean(AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class)).willReturn(mock(ApplicationEventMulticaster.class));
eventProducer.setBeanFactory(mock);
eventProducer.afterPropertiesSet();
eventProducer.start();
TcpConnectionSupport connection = Mockito.mock(TcpConnectionSupport.class);
assertTrue(eventProducer.supportsEventType(ResolvableType.forClass(TcpConnectionOpenEvent.class)));
TcpConnectionEvent event1 = new TcpConnectionOpenEvent(connection, "foo");
eventProducer.onApplicationEvent(event1);
assertTrue(eventProducer.supportsEventType(ResolvableType.forClass(FooEvent.class)));
FooEvent event2 = new FooEvent(connection, "foo");
eventProducer.onApplicationEvent(event2);
assertTrue(eventProducer.supportsEventType(ResolvableType.forClass(BarEvent.class)));
BarEvent event3 = new BarEvent(connection, "foo");
eventProducer.onApplicationEvent(event3);
Message<?> message = outputChannel.receive(0);
assertNotNull(message);
assertSame(event1, message.getPayload());
message = outputChannel.receive(0);
assertNotNull(message);
assertSame(event2, message.getPayload());
message = outputChannel.receive(0);
assertNotNull(message);
assertSame(event3, message.getPayload());
message = outputChannel.receive(0);
assertNull(message);
}
use of org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer in project faf-java-server by FAForever.
the class IntegrationConfig method applicationEventListeningMessageProducer.
/**
* Turns specific application events into messages.
*/
@Bean
public ApplicationEventListeningMessageProducer applicationEventListeningMessageProducer() {
ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer();
producer.setEventTypes(ClientDisconnectedEvent.class);
producer.setOutputChannelName(ChannelNames.INBOUND_DISPATCH);
return producer;
}
Aggregations