Search in sources :

Example 1 with FtpInboundFileSynchronizingMessageSource

use of org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMessageSource in project spring-integration by spring-projects.

the class FtpsInboundChannelAdapterParserTests method testFtpsInboundChannelAdapterComplete.

@Test
public void testFtpsInboundChannelAdapterComplete() throws Exception {
    assertEquals("ftpInbound", ftpInbound.getComponentName());
    assertEquals("ftp:inbound-channel-adapter", ftpInbound.getComponentType());
    assertNotNull(TestUtils.getPropertyValue(ftpInbound, "poller"));
    assertEquals(this.ftpChannel, TestUtils.getPropertyValue(ftpInbound, "outputChannel"));
    FtpInboundFileSynchronizingMessageSource inbound = (FtpInboundFileSynchronizingMessageSource) TestUtils.getPropertyValue(ftpInbound, "source");
    FtpInboundFileSynchronizer fisync = (FtpInboundFileSynchronizer) TestUtils.getPropertyValue(inbound, "synchronizer");
    assertNotNull(TestUtils.getPropertyValue(fisync, "filter"));
}
Also used : FtpInboundFileSynchronizer(org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer) FtpInboundFileSynchronizingMessageSource(org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMessageSource) Test(org.junit.Test)

Example 2 with FtpInboundFileSynchronizingMessageSource

use of org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMessageSource in project spring-integration by spring-projects.

the class FtpInboundChannelAdapterParserTests method testFtpInboundChannelAdapterComplete.

@Test
public void testFtpInboundChannelAdapterComplete() throws Exception {
    assertFalse(TestUtils.getPropertyValue(ftpInbound, "autoStartup", Boolean.class));
    PriorityBlockingQueue<?> blockingQueue = TestUtils.getPropertyValue(ftpInbound, "source.fileSource.toBeReceived", PriorityBlockingQueue.class);
    Comparator<?> comparator = blockingQueue.comparator();
    assertNotNull(comparator);
    assertEquals("ftpInbound", ftpInbound.getComponentName());
    assertEquals("ftp:inbound-channel-adapter", ftpInbound.getComponentType());
    assertEquals(context.getBean("ftpChannel"), TestUtils.getPropertyValue(ftpInbound, "outputChannel"));
    FtpInboundFileSynchronizingMessageSource inbound = (FtpInboundFileSynchronizingMessageSource) TestUtils.getPropertyValue(ftpInbound, "source");
    assertSame(dirScanner, TestUtils.getPropertyValue(inbound, "fileSource.scanner"));
    FtpInboundFileSynchronizer fisync = (FtpInboundFileSynchronizer) TestUtils.getPropertyValue(inbound, "synchronizer");
    assertEquals("'foo/bar'", TestUtils.getPropertyValue(fisync, "remoteDirectoryExpression", Expression.class).getExpressionString());
    assertNotNull(TestUtils.getPropertyValue(fisync, "localFilenameGeneratorExpression"));
    assertTrue(TestUtils.getPropertyValue(fisync, "preserveTimestamp", Boolean.class));
    assertEquals(".foo", TestUtils.getPropertyValue(fisync, "temporaryFileSuffix", String.class));
    String remoteFileSeparator = (String) TestUtils.getPropertyValue(fisync, "remoteFileSeparator");
    assertNotNull(remoteFileSeparator);
    assertEquals("", remoteFileSeparator);
    FileListFilter<?> filter = TestUtils.getPropertyValue(fisync, "filter", FileListFilter.class);
    assertNotNull(filter);
    assertThat(filter, instanceOf(CompositeFileListFilter.class));
    Set<?> fileFilters = TestUtils.getPropertyValue(filter, "fileFilters", Set.class);
    Iterator<?> filtersIterator = fileFilters.iterator();
    assertThat(filtersIterator.next(), instanceOf(FtpSimplePatternFileListFilter.class));
    assertThat(filtersIterator.next(), instanceOf(FtpPersistentAcceptOnceFileListFilter.class));
    Object sessionFactory = TestUtils.getPropertyValue(fisync, "remoteFileTemplate.sessionFactory");
    assertTrue(DefaultFtpSessionFactory.class.isAssignableFrom(sessionFactory.getClass()));
    FileListFilter<?> acceptAllFilter = context.getBean("acceptAllFilter", FileListFilter.class);
    assertTrue(TestUtils.getPropertyValue(inbound, "fileSource.scanner.filter.fileFilters", Collection.class).contains(acceptAllFilter));
    final AtomicReference<Method> genMethod = new AtomicReference<Method>();
    ReflectionUtils.doWithMethods(AbstractInboundFileSynchronizer.class, method -> {
        method.setAccessible(true);
        genMethod.set(method);
    }, method -> "generateLocalFileName".equals(method.getName()));
    assertEquals("FOO.afoo", genMethod.get().invoke(fisync, "foo"));
    assertEquals(42, inbound.getMaxFetchSize());
}
Also used : CompositeFileListFilter(org.springframework.integration.file.filters.CompositeFileListFilter) AtomicReference(java.util.concurrent.atomic.AtomicReference) Method(java.lang.reflect.Method) FtpPersistentAcceptOnceFileListFilter(org.springframework.integration.ftp.filters.FtpPersistentAcceptOnceFileListFilter) FtpSimplePatternFileListFilter(org.springframework.integration.ftp.filters.FtpSimplePatternFileListFilter) FtpInboundFileSynchronizer(org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer) DefaultFtpSessionFactory(org.springframework.integration.ftp.session.DefaultFtpSessionFactory) FtpInboundFileSynchronizingMessageSource(org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMessageSource) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FtpInboundFileSynchronizer (org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer)2 FtpInboundFileSynchronizingMessageSource (org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMessageSource)2 Method (java.lang.reflect.Method)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CompositeFileListFilter (org.springframework.integration.file.filters.CompositeFileListFilter)1 FtpPersistentAcceptOnceFileListFilter (org.springframework.integration.ftp.filters.FtpPersistentAcceptOnceFileListFilter)1 FtpSimplePatternFileListFilter (org.springframework.integration.ftp.filters.FtpSimplePatternFileListFilter)1 DefaultFtpSessionFactory (org.springframework.integration.ftp.session.DefaultFtpSessionFactory)1