Search in sources :

Example 1 with DefaultFtpSessionFactory

use of org.springframework.integration.ftp.session.DefaultFtpSessionFactory in project spring-integration-samples by spring-projects.

the class Application method ftp2.

@Bean
public SessionFactory<FTPFile> ftp2() {
    DefaultFtpSessionFactory ftp = new DefaultFtpSessionFactory();
    ftp.setHost("host3");
    ftp.setUsername("user");
    ftp.setPassword("ftp");
    return ftp;
}
Also used : DefaultFtpSessionFactory(org.springframework.integration.ftp.session.DefaultFtpSessionFactory) Bean(org.springframework.context.annotation.Bean)

Example 2 with DefaultFtpSessionFactory

use of org.springframework.integration.ftp.session.DefaultFtpSessionFactory in project spring-integration by spring-projects.

the class FtpOutboundChannelAdapterParserTests method testFtpOutboundChannelAdapterComplete.

@Test
public void testFtpOutboundChannelAdapterComplete() throws Exception {
    assertEquals(ftpChannel, TestUtils.getPropertyValue(ftpOutbound, "inputChannel"));
    assertEquals("ftpOutbound", ftpOutbound.getComponentName());
    FileTransferringMessageHandler<?> handler = TestUtils.getPropertyValue(ftpOutbound, "handler", FileTransferringMessageHandler.class);
    String remoteFileSeparator = (String) TestUtils.getPropertyValue(handler, "remoteFileTemplate.remoteFileSeparator");
    assertNotNull(remoteFileSeparator);
    assertEquals(".foo", TestUtils.getPropertyValue(handler, "remoteFileTemplate.temporaryFileSuffix", String.class));
    assertEquals("", remoteFileSeparator);
    assertEquals(this.fileNameGenerator, TestUtils.getPropertyValue(handler, "remoteFileTemplate.fileNameGenerator"));
    assertEquals("UTF-8", TestUtils.getPropertyValue(handler, "remoteFileTemplate.charset"));
    assertNotNull(TestUtils.getPropertyValue(handler, "remoteFileTemplate.directoryExpressionProcessor"));
    assertNotNull(TestUtils.getPropertyValue(handler, "remoteFileTemplate.temporaryDirectoryExpressionProcessor"));
    assertEquals(FtpRemoteFileTemplate.ExistsMode.NLST, TestUtils.getPropertyValue(handler, "remoteFileTemplate.existsMode"));
    Object sfProperty = TestUtils.getPropertyValue(handler, "remoteFileTemplate.sessionFactory");
    assertEquals(DefaultFtpSessionFactory.class, sfProperty.getClass());
    DefaultFtpSessionFactory sessionFactory = (DefaultFtpSessionFactory) sfProperty;
    assertEquals("localhost", TestUtils.getPropertyValue(sessionFactory, "host"));
    assertEquals(22, TestUtils.getPropertyValue(sessionFactory, "port"));
    assertEquals(23, TestUtils.getPropertyValue(handler, "order"));
    // verify subscription order
    Object dispatcher = TestUtils.getPropertyValue(ftpChannel, "dispatcher");
    @SuppressWarnings("unchecked") Set<MessageHandler> handlers = (Set<MessageHandler>) TestUtils.getPropertyValue(dispatcher, "handlers");
    Iterator<MessageHandler> iterator = handlers.iterator();
    assertSame(TestUtils.getPropertyValue(this.ftpOutbound2, "handler"), iterator.next());
    assertSame(handler, iterator.next());
    assertEquals(FileExistsMode.APPEND, TestUtils.getPropertyValue(ftpOutbound, "handler.mode"));
}
Also used : Set(java.util.Set) MessageHandler(org.springframework.messaging.MessageHandler) FileTransferringMessageHandler(org.springframework.integration.file.remote.handler.FileTransferringMessageHandler) DefaultFtpSessionFactory(org.springframework.integration.ftp.session.DefaultFtpSessionFactory) Test(org.junit.Test)

Example 3 with DefaultFtpSessionFactory

use of org.springframework.integration.ftp.session.DefaultFtpSessionFactory in project spring-integration-samples by spring-projects.

the class Application method ftp1.

@Bean
public SessionFactory<FTPFile> ftp1() {
    DefaultFtpSessionFactory ftp = new DefaultFtpSessionFactory();
    ftp.setHost("host3");
    ftp.setUsername("user");
    ftp.setPassword("ftp");
    return ftp;
}
Also used : DefaultFtpSessionFactory(org.springframework.integration.ftp.session.DefaultFtpSessionFactory) Bean(org.springframework.context.annotation.Bean)

Example 4 with DefaultFtpSessionFactory

use of org.springframework.integration.ftp.session.DefaultFtpSessionFactory in project spring-integration-samples by spring-projects.

the class Application method ftp3.

@Bean
public SessionFactory<FTPFile> ftp3() {
    DefaultFtpSessionFactory ftp = new DefaultFtpSessionFactory();
    ftp.setHost("host3");
    ftp.setUsername("user");
    ftp.setPassword("ftp");
    return ftp;
}
Also used : DefaultFtpSessionFactory(org.springframework.integration.ftp.session.DefaultFtpSessionFactory) Bean(org.springframework.context.annotation.Bean)

Example 5 with DefaultFtpSessionFactory

use of org.springframework.integration.ftp.session.DefaultFtpSessionFactory in project spring-integration by spring-projects.

the class FtpTestSupport method sessionFactory.

public static SessionFactory<FTPFile> sessionFactory() {
    DefaultFtpSessionFactory sf = new DefaultFtpSessionFactory();
    sf.setHost("localhost");
    sf.setPort(port);
    sf.setUsername("foo");
    sf.setPassword("foo");
    sf.setClientMode(FTPClient.PASSIVE_LOCAL_DATA_CONNECTION_MODE);
    return new CachingSessionFactory<FTPFile>(sf);
}
Also used : CachingSessionFactory(org.springframework.integration.file.remote.session.CachingSessionFactory) DefaultFtpSessionFactory(org.springframework.integration.ftp.session.DefaultFtpSessionFactory)

Aggregations

DefaultFtpSessionFactory (org.springframework.integration.ftp.session.DefaultFtpSessionFactory)5 Bean (org.springframework.context.annotation.Bean)3 Set (java.util.Set)1 Test (org.junit.Test)1 FileTransferringMessageHandler (org.springframework.integration.file.remote.handler.FileTransferringMessageHandler)1 CachingSessionFactory (org.springframework.integration.file.remote.session.CachingSessionFactory)1 MessageHandler (org.springframework.messaging.MessageHandler)1