Search in sources :

Example 1 with SftpInboundFileSynchronizingMessageSource

use of org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizingMessageSource 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();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) FileListFilter(org.springframework.integration.file.filters.FileListFilter) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) SourcePollingChannelAdapter(org.springframework.integration.endpoint.SourcePollingChannelAdapter) SftpInboundFileSynchronizingMessageSource(org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizingMessageSource) SftpInboundFileSynchronizer(org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizer) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 Test (org.junit.Test)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1 SourcePollingChannelAdapter (org.springframework.integration.endpoint.SourcePollingChannelAdapter)1 FileListFilter (org.springframework.integration.file.filters.FileListFilter)1 SftpInboundFileSynchronizer (org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizer)1 SftpInboundFileSynchronizingMessageSource (org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizingMessageSource)1 PollableChannel (org.springframework.messaging.PollableChannel)1