use of org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer in project spring-integration by spring-projects.
the class EventInboundChannelAdapterParserTests method validateEventParser.
@Test
public void validateEventParser() {
Object adapter = context.getBean("eventAdapterSimple");
Assert.assertNotNull(adapter);
Assert.assertTrue(adapter instanceof ApplicationEventListeningMessageProducer);
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
Assert.assertEquals(context.getBean("input"), adapterAccessor.getPropertyValue("outputChannel"));
Assert.assertSame(errorChannel, adapterAccessor.getPropertyValue("errorChannel"));
}
use of org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer in project spring-integration by spring-projects.
the class EventInboundChannelAdapterParserTests method validateEventParserWithEventTypes.
@Test
@SuppressWarnings("unchecked")
public void validateEventParserWithEventTypes() {
Object adapter = context.getBean("eventAdapterFiltered");
Assert.assertNotNull(adapter);
Assert.assertTrue(adapter instanceof ApplicationEventListeningMessageProducer);
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
Assert.assertEquals(context.getBean("inputFiltered"), adapterAccessor.getPropertyValue("outputChannel"));
Set<ResolvableType> eventTypes = (Set<ResolvableType>) adapterAccessor.getPropertyValue("eventTypes");
assertNotNull(eventTypes);
assertTrue(eventTypes.size() == 3);
assertTrue(eventTypes.contains(ResolvableType.forClass(SampleEvent.class)));
assertTrue(eventTypes.contains(ResolvableType.forClass(AnotherSampleEvent.class)));
assertTrue(eventTypes.contains(ResolvableType.forClass(Date.class)));
assertNull(adapterAccessor.getPropertyValue("errorChannel"));
}
use of org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer in project spring-integration by spring-projects.
the class EventInboundChannelAdapterParserTests method validatePayloadExpression.
@Test
public void validatePayloadExpression() {
Object adapter = context.getBean("eventAdapterSpel");
Assert.assertNotNull(adapter);
Assert.assertTrue(adapter instanceof ApplicationEventListeningMessageProducer);
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
Expression expression = (Expression) adapterAccessor.getPropertyValue("payloadExpression");
Assert.assertEquals("source + '-test'", expression.getExpressionString());
}
use of org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer in project spring-integration by spring-projects.
the class TcpConnectionEventListenerTests method testFilter.
@Test
public void testFilter() {
ApplicationEventListeningMessageProducer eventProducer = new ApplicationEventListeningMessageProducer();
QueueChannel outputChannel = new QueueChannel();
eventProducer.setOutputChannel(outputChannel);
eventProducer.setEventTypes(FooEvent.class, BarEvent.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);
assertFalse(eventProducer.supportsEventType(ResolvableType.forClass(TcpConnectionOpenEvent.class)));
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(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 spring-integration by spring-projects.
the class EventInboundChannelAdapterParserTests method validateEventParserWithEventTypesAndPlaceholder.
@Test
@SuppressWarnings("unchecked")
public void validateEventParserWithEventTypesAndPlaceholder() {
Object adapter = context.getBean("eventAdapterFilteredPlaceHolder");
Assert.assertNotNull(adapter);
Assert.assertTrue(adapter instanceof ApplicationEventListeningMessageProducer);
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
Assert.assertEquals(context.getBean("inputFilteredPlaceHolder"), adapterAccessor.getPropertyValue("outputChannel"));
Set<ResolvableType> eventTypes = (Set<ResolvableType>) adapterAccessor.getPropertyValue("eventTypes");
assertNotNull(eventTypes);
assertTrue(eventTypes.size() == 2);
assertTrue(eventTypes.contains(ResolvableType.forClass(SampleEvent.class)));
assertTrue(eventTypes.contains(ResolvableType.forClass(AnotherSampleEvent.class)));
}
Aggregations