Search in sources :

Example 1 with FtpInboundFileSynchronizer

use of org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer 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 FtpInboundFileSynchronizer

use of org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer 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)

Example 3 with FtpInboundFileSynchronizer

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

the class FtpInboundChannelAdapterParserTests method cachingSessionFactory.

@Test
public void cachingSessionFactory() throws Exception {
    Object sessionFactory = TestUtils.getPropertyValue(simpleAdapterWithCachedSessions, "source.synchronizer.remoteFileTemplate.sessionFactory");
    assertEquals(CachingSessionFactory.class, sessionFactory.getClass());
    FtpInboundFileSynchronizer fisync = TestUtils.getPropertyValue(simpleAdapterWithCachedSessions, "source.synchronizer", FtpInboundFileSynchronizer.class);
    String remoteFileSeparator = (String) TestUtils.getPropertyValue(fisync, "remoteFileSeparator");
    assertNotNull(remoteFileSeparator);
    assertEquals("/", remoteFileSeparator);
    assertEquals("foo/bar", TestUtils.getPropertyValue(fisync, "remoteDirectoryExpression", Expression.class).getExpressionString());
    assertEquals(Integer.MIN_VALUE, TestUtils.getPropertyValue(simpleAdapterWithCachedSessions, "source.maxFetchSize"));
}
Also used : FtpInboundFileSynchronizer(org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 FtpInboundFileSynchronizer (org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer)3 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