Search in sources :

Example 11 with FileListFilter

use of org.springframework.integration.file.filters.FileListFilter 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

FileListFilter (org.springframework.integration.file.filters.FileListFilter)11 Test (org.junit.Test)10 CompositeFileListFilter (org.springframework.integration.file.filters.CompositeFileListFilter)9 File (java.io.File)8 AcceptOnceFileListFilter (org.springframework.integration.file.filters.AcceptOnceFileListFilter)6 RegexPatternFileListFilter (org.springframework.integration.file.filters.RegexPatternFileListFilter)5 ArrayList (java.util.ArrayList)4 Set (java.util.Set)4 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)4 SimplePatternFileListFilter (org.springframework.integration.file.filters.SimplePatternFileListFilter)4 Collection (java.util.Collection)3 BeanFactory (org.springframework.beans.factory.BeanFactory)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 Expression (org.springframework.expression.Expression)2 AcceptAllFileListFilter (org.springframework.integration.file.filters.AcceptAllFileListFilter)2 PropertiesPersistingMetadataStore (org.springframework.integration.metadata.PropertiesPersistingMetadataStore)2 LsEntry (com.jcraft.jsch.ChannelSftp.LsEntry)1 Method (java.lang.reflect.Method)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Pattern (java.util.regex.Pattern)1