use of org.springframework.integration.redis.inbound.RedisInboundChannelAdapter in project spring-integration by spring-projects.
the class RedisInboundChannelAdapterParserTests method testInboundChannelAdapterMessaging.
@Test
@RedisAvailable
public void testInboundChannelAdapterMessaging() throws Exception {
RedisInboundChannelAdapter adapter = context.getBean("adapter", RedisInboundChannelAdapter.class);
this.awaitContainerSubscribedWithPatterns(TestUtils.getPropertyValue(adapter, "container", RedisMessageListenerContainer.class));
RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest();
connectionFactory.getConnection().publish("foo".getBytes(), "Hello Redis from foo".getBytes());
connectionFactory.getConnection().publish("bar".getBytes(), "Hello Redis from bar".getBytes());
QueueChannel receiveChannel = context.getBean("receiveChannel", QueueChannel.class);
for (int i = 0; i < 3; i++) {
Message<?> receive = receiveChannel.receive(10000);
assertNotNull(receive);
assertThat(receive.getPayload(), Matchers.<Object>isOneOf("Hello Redis from foo", "Hello Redis from bar"));
}
}
use of org.springframework.integration.redis.inbound.RedisInboundChannelAdapter in project spring-integration by spring-projects.
the class RedisInboundChannelAdapterParserTests method validateConfiguration.
@Test
public void validateConfiguration() {
RedisInboundChannelAdapter adapter = context.getBean("adapter", RedisInboundChannelAdapter.class);
assertEquals("adapter", adapter.getComponentName());
assertEquals("redis:inbound-channel-adapter", adapter.getComponentType());
DirectFieldAccessor accessor = new DirectFieldAccessor(adapter);
Object errorChannelBean = context.getBean("testErrorChannel");
assertEquals(errorChannelBean, accessor.getPropertyValue("errorChannel"));
Object converterBean = context.getBean("testConverter");
assertEquals(converterBean, accessor.getPropertyValue("messageConverter"));
assertEquals(context.getBean("serializer"), accessor.getPropertyValue("serializer"));
Object container = accessor.getPropertyValue("container");
DirectFieldAccessor containerAccessor = new DirectFieldAccessor(container);
assertSame(this.executor, containerAccessor.getPropertyValue("taskExecutor"));
Object bean = context.getBean("withoutSerializer.adapter");
assertNotNull(bean);
assertNull(TestUtils.getPropertyValue(bean, "serializer"));
}
Aggregations