use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class EventInboundChannelAdapterParserTests method validateUsageWithHistory.
@Test
public void validateUsageWithHistory() {
PollableChannel channel = context.getBean("input", PollableChannel.class);
assertEquals(ContextRefreshedEvent.class, channel.receive(0).getPayload().getClass());
context.publishEvent(new SampleEvent("hello"));
Message<?> message = channel.receive(0);
MessageHistory history = MessageHistory.read(message);
assertNotNull(history);
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "eventAdapterSimple", 0);
assertNotNull(componentHistoryRecord);
assertEquals("event:inbound-channel-adapter", componentHistoryRecord.get("type"));
assertNotNull(message);
assertEquals(SampleEvent.class, message.getPayload().getClass());
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class RedisQueueMessageDrivenEndpointTests method testInt3932ReadFromLeft.
@Test
@RedisAvailable
@SuppressWarnings("unchecked")
public void testInt3932ReadFromLeft() {
String queueName = "si.test.redisQueueInboundChannelAdapterTests3932";
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(this.connectionFactory);
redisTemplate.setEnableDefaultSerializer(false);
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
redisTemplate.afterPropertiesSet();
String payload = "testing";
redisTemplate.boundListOps(queueName).rightPush(payload);
Date payload2 = new Date();
redisTemplate.boundListOps(queueName).rightPush(payload2);
PollableChannel channel = new QueueChannel();
RedisQueueMessageDrivenEndpoint endpoint = new RedisQueueMessageDrivenEndpoint(queueName, this.connectionFactory);
endpoint.setBeanFactory(Mockito.mock(BeanFactory.class));
endpoint.setOutputChannel(channel);
endpoint.setReceiveTimeout(10);
endpoint.setRightPop(false);
endpoint.afterPropertiesSet();
endpoint.start();
Message<Object> receive = (Message<Object>) channel.receive(10000);
assertNotNull(receive);
assertEquals(payload, receive.getPayload());
receive = (Message<Object>) channel.receive(10000);
assertNotNull(receive);
assertEquals(payload2, receive.getPayload());
endpoint.stop();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class FtpOutboundTests method testFtpOutboundGatewayInsideChain.
// INT-2275
@Test
public void testFtpOutboundGatewayInsideChain() throws Exception {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("FtpOutboundInsideChainTests-context.xml", getClass());
MessageChannel channel = context.getBean("ftpOutboundGatewayInsideChain", MessageChannel.class);
channel.send(MessageBuilder.withPayload("remote-test-dir").build());
PollableChannel output = context.getBean("output", PollableChannel.class);
Message<?> result = output.receive();
Object payload = result.getPayload();
assertTrue(payload instanceof List<?>);
@SuppressWarnings("unchecked") List<? extends FileInfo<?>> remoteFiles = (List<? extends FileInfo<?>>) payload;
assertEquals(3, remoteFiles.size());
List<String> files = Arrays.asList(new File("remote-test-dir").list());
for (FileInfo<?> remoteFile : remoteFiles) {
assertTrue(files.contains(remoteFile.getFilename()));
}
context.close();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class GroovyServiceActivatorTests method testScriptWithoutVariables.
@Test
public void testScriptWithoutVariables() throws Exception {
PollableChannel replyChannel = new QueueChannel();
for (int i = 1; i <= 3; i++) {
Message<?> message = MessageBuilder.withPayload("test-" + i).setReplyChannel(replyChannel).build();
this.scriptWithoutVariablesInput.send(message);
}
DateFormat format = new SimpleDateFormat("dd.MM.yyyy");
String now = format.format(new Date());
assertEquals("withoutVariables-test-1 : " + now, replyChannel.receive(0).getPayload());
assertEquals("withoutVariables-test-2 : " + now, replyChannel.receive(0).getPayload());
assertEquals("withoutVariables-test-3 : " + now, replyChannel.receive(0).getPayload());
assertNull(replyChannel.receive(0));
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class SftpOutboundTests method testFtpOutboundGatewayInsideChain.
// INT-2275
@Test
public void testFtpOutboundGatewayInsideChain() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("SftpOutboundInsideChainTests-context.xml", getClass());
MessageChannel channel = context.getBean("outboundGatewayInsideChain", MessageChannel.class);
channel.send(MessageBuilder.withPayload("remote-test-dir").build());
PollableChannel output = context.getBean("replyChannel", PollableChannel.class);
Message<?> result = output.receive();
Object payload = result.getPayload();
assertTrue(payload instanceof List<?>);
@SuppressWarnings("unchecked") List<? extends FileInfo<?>> remoteFiles = (List<? extends FileInfo<?>>) payload;
assertEquals(3, remoteFiles.size());
List<String> files = Arrays.asList(new File("remote-test-dir").list());
for (FileInfo<?> remoteFile : remoteFiles) {
assertTrue(files.contains(remoteFile.getFilename()));
}
context.close();
}
Aggregations