use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.
the class FtpMessageHistoryTests method testMessageHistory.
@Test
public void testMessageHistory() throws Exception {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("ftp-message-history-context.xml", this.getClass());
SourcePollingChannelAdapter adapter = ac.getBean("adapterFtp", SourcePollingChannelAdapter.class);
assertEquals("adapterFtp", adapter.getComponentName());
assertEquals("ftp:inbound-channel-adapter", adapter.getComponentType());
ac.close();
}
use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.
the class RedisStoreInboundChannelAdapterIntegrationTests method testListInboundConfiguration.
@Test
@RedisAvailable
@SuppressWarnings("unchecked")
public void testListInboundConfiguration() throws Exception {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter spca = context.getBean("listAdapter", SourcePollingChannelAdapter.class);
spca.start();
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<Integer> message = (Message<Integer>) redisChannel.receive(10000);
assertNotNull(message);
assertEquals(Integer.valueOf(13), message.getPayload());
// poll again, should get the same stuff
message = (Message<Integer>) redisChannel.receive(10000);
assertNotNull(message);
assertEquals(Integer.valueOf(13), message.getPayload());
this.deletePresidents(jcf);
context.close();
}
use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.
the class RedisStoreInboundChannelAdapterIntegrationTests method testListInboundConfigurationWithSynchronizationAndRollback.
@SuppressWarnings("resource")
@Test
@RedisAvailable
public // synchronization rollback renames the list
void testListInboundConfigurationWithSynchronizationAndRollback() throws Exception {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate template = this.createStringRedisTemplate(jcf);
template.delete("baz");
this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SubscribableChannel fail = context.getBean("redisFailChannel", SubscribableChannel.class);
final CountDownLatch latch = new CountDownLatch(1);
fail.subscribe(message -> {
latch.countDown();
throw new RuntimeException("Test Rollback");
});
SourcePollingChannelAdapter spca = context.getBean("listAdapterWithSynchronizationAndRollback", SourcePollingChannelAdapter.class);
spca.start();
assertTrue(latch.await(10, TimeUnit.SECONDS));
int n = 0;
while (n++ < 100 && template.keys("baz").size() == 0) {
Thread.sleep(100);
}
assertTrue("Rename didn't occur", n < 100);
assertEquals(Long.valueOf(13), template.boundListOps("baz").size());
template.delete("baz");
spca.stop();
context.close();
}
use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.
the class InboundChannelAdapterParserTests method testAutoChannel.
@Test
public void testAutoChannel() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("InboundChannelAdapterParserTests-context.xml", this.getClass());
// Auto-created channel
MessageChannel autoChannel = context.getBean("autoChannel", MessageChannel.class);
SourcePollingChannelAdapter autoChannelAdapter = context.getBean("autoChannel.adapter", SourcePollingChannelAdapter.class);
assertEquals("/foo", TestUtils.getPropertyValue(autoChannelAdapter, "source.synchronizer.remoteDirectoryExpression", Expression.class).getExpressionString());
assertSame(autoChannel, TestUtils.getPropertyValue(autoChannelAdapter, "outputChannel"));
assertEquals(Integer.MIN_VALUE, TestUtils.getPropertyValue(autoChannelAdapter, "source.maxFetchSize"));
context.close();
}
use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.
the class InboundChannelAdapterParserTests method testWithLocalFiles.
@Test
public void testWithLocalFiles() throws Exception {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("InboundChannelAdapterParserTests-context.xml", this.getClass());
assertTrue(new File("src/main/resources").exists());
Object adapter = context.getBean("sftpAdapterAutoCreate");
assertTrue(adapter instanceof SourcePollingChannelAdapter);
SftpInboundFileSynchronizingMessageSource source = (SftpInboundFileSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source");
assertNotNull(source);
PriorityBlockingQueue<?> blockingQueue = TestUtils.getPropertyValue(adapter, "source.fileSource.toBeReceived", PriorityBlockingQueue.class);
Comparator<?> comparator = blockingQueue.comparator();
assertNotNull(comparator);
SftpInboundFileSynchronizer synchronizer = TestUtils.getPropertyValue(source, "synchronizer", SftpInboundFileSynchronizer.class);
assertEquals("'/foo'", TestUtils.getPropertyValue(synchronizer, "remoteDirectoryExpression", Expression.class).getExpressionString());
assertNotNull(TestUtils.getPropertyValue(synchronizer, "localFilenameGeneratorExpression"));
assertTrue(TestUtils.getPropertyValue(synchronizer, "preserveTimestamp", Boolean.class));
String remoteFileSeparator = (String) TestUtils.getPropertyValue(synchronizer, "remoteFileSeparator");
assertEquals(".bar", TestUtils.getPropertyValue(synchronizer, "temporaryFileSuffix", String.class));
assertNotNull(remoteFileSeparator);
assertEquals(".", remoteFileSeparator);
PollableChannel requestChannel = context.getBean("requestChannel", PollableChannel.class);
assertNotNull(requestChannel.receive(10000));
FileListFilter<?> acceptAllFilter = context.getBean("acceptAllFilter", FileListFilter.class);
@SuppressWarnings("unchecked") Collection<FileListFilter<?>> filters = TestUtils.getPropertyValue(source, "fileSource.scanner.filter.fileFilters", Collection.class);
assertThat(filters, hasItem(acceptAllFilter));
assertEquals(42, source.getMaxFetchSize());
context.close();
}
Aggregations