INT-1614 added more inbound tests for FTP/FTPS

This commit is contained in:
Oleg Zhurakousky
2010-11-15 18:26:55 -05:00
parent 7a16548f50
commit 4e048f7072
4 changed files with 152 additions and 5 deletions

View File

@@ -9,7 +9,25 @@
<int-ftp:inbound-channel-adapter
id="ftpOutbound"
id="ftpInbound"
username="user"
password="password"
channel="ftpChannel"
remote-directory="foo/bar"
host="localhost"
charset="UTF-8"
client-mode="active-local-data-connection-mode"
file-type="binary-file-type"
port="22"
auto-create-directories="true"
auto-delete-remote-files-on-sync="true"
filename-pattern=".?txt"
filter="entryListFilter"
local-working-directory=".">
<int:poller fixed-rate="1000"/>
</int-ftp:inbound-channel-adapter>
<int-ftp:inbound-channel-adapter
username="user"
password="password"
channel="ftpChannel"

View File

@@ -16,9 +16,24 @@
package org.springframework.integration.ftp.config;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.file.filters.CompositeFileListFilter;
import org.springframework.integration.ftp.client.FtpClientFactory;
import org.springframework.integration.ftp.client.FtpClientPool;
import org.springframework.integration.ftp.inbound.FtpInboundRemoteFileSystemSynchronizer;
import org.springframework.integration.ftp.inbound.FtpInboundRemoteFileSystemSynchronizingMessageSource;
import org.springframework.integration.test.util.TestUtils;
/**
* @author Oleg Zhurakousky
@@ -27,7 +42,47 @@ public class FtpInboundChannelAdapterParserTests {
@Test
public void testFtpInboundChannelAdapterComplete() throws Exception{
new ClassPathXmlApplicationContext("FtpInboundChannelAdapterParserTests-context.xml", this.getClass());
ApplicationContext ac =
new ClassPathXmlApplicationContext("FtpInboundChannelAdapterParserTests-context.xml", this.getClass());
SourcePollingChannelAdapter adapter = ac.getBean("ftpInbound", SourcePollingChannelAdapter.class);
assertEquals("ftpInbound", adapter.getComponentName());
assertEquals("ftp:inbound-channel-adapter", adapter.getComponentType());
assertNotNull(TestUtils.getPropertyValue(adapter, "poller"));
assertEquals(ac.getBean("ftpChannel"), TestUtils.getPropertyValue(adapter, "outputChannel"));
FtpInboundRemoteFileSystemSynchronizingMessageSource inbound =
(FtpInboundRemoteFileSystemSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source");
FtpInboundRemoteFileSystemSynchronizer fisync =
(FtpInboundRemoteFileSystemSynchronizer) TestUtils.getPropertyValue(inbound, "synchronizer");
CompositeFileListFilter<?> filter = (CompositeFileListFilter<?>) TestUtils.getPropertyValue(fisync, "filter");
Set<?> filters = (Set<?>) TestUtils.getPropertyValue(filter, "fileFilters");
assertEquals(2, filters.size());
assertTrue(filters.contains(ac.getBean("entryListFilter")));
FtpClientPool clientPoll = (FtpClientPool) TestUtils.getPropertyValue(inbound, "clientPool");
FtpClientFactory<?> clientFactory = (FtpClientFactory<?>) TestUtils.getPropertyValue(clientPoll, "factory");
assertEquals("localhost", TestUtils.getPropertyValue(clientFactory, "host"));
assertEquals(22, TestUtils.getPropertyValue(clientFactory, "port"));
assertEquals("user", TestUtils.getPropertyValue(clientFactory, "username"));
assertEquals("password", TestUtils.getPropertyValue(clientFactory, "password"));
assertEquals("foo/bar", TestUtils.getPropertyValue(clientFactory, "remoteWorkingDirectory"));
System.out.println();
}
@Test
public void testFtpInboundChannelAdapterCompleteNoId() throws Exception{
ApplicationContext ac =
new ClassPathXmlApplicationContext("FtpInboundChannelAdapterParserTests-context.xml", this.getClass());
Map<String, SourcePollingChannelAdapter> spcas = ac.getBeansOfType(SourcePollingChannelAdapter.class);
SourcePollingChannelAdapter adapter = null;
for (String key : spcas.keySet()) {
if (!key.equals("ftpInbound")){
adapter = spcas.get(key);
}
}
assertNotNull(adapter);
}
}

View File

@@ -9,7 +9,25 @@
<int-ftps:inbound-channel-adapter
id="ftpOutbound"
id="ftpInbound"
username="user"
password="password"
channel="ftpChannel"
remote-directory="foo/bar"
host="localhost"
charset="UTF-8"
client-mode="active-local-data-connection-mode"
file-type="binary-file-type"
port="22"
auto-create-directories="true"
auto-delete-remote-files-on-sync="true"
filename-pattern=".?txt"
filter="entryListFilter"
local-working-directory=".">
<int:poller fixed-rate="1000"/>
</int-ftps:inbound-channel-adapter>
<int-ftps:inbound-channel-adapter
username="user"
password="password"
channel="ftpChannel"

View File

@@ -16,9 +16,24 @@
package org.springframework.integration.ftp.config;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.file.filters.CompositeFileListFilter;
import org.springframework.integration.ftp.client.FtpClientFactory;
import org.springframework.integration.ftp.client.FtpClientPool;
import org.springframework.integration.ftp.inbound.FtpInboundRemoteFileSystemSynchronizer;
import org.springframework.integration.ftp.inbound.FtpInboundRemoteFileSystemSynchronizingMessageSource;
import org.springframework.integration.test.util.TestUtils;
/**
* @author Oleg Zhurakousky
@@ -26,8 +41,49 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public class FtpsInboundChannelAdapterParserTests {
@Test
public void testFtpsInboundChannelAdapterComplete() throws Exception {
new ClassPathXmlApplicationContext("FtpsInboundChannelAdapterParserTests-context.xml", this.getClass());
public void testFtpsInboundChannelAdapterComplete() throws Exception{
ApplicationContext ac =
new ClassPathXmlApplicationContext("FtpsInboundChannelAdapterParserTests-context.xml", this.getClass());
SourcePollingChannelAdapter adapter = ac.getBean("ftpInbound", SourcePollingChannelAdapter.class);
assertEquals("ftpInbound", adapter.getComponentName());
assertEquals("ftp:inbound-channel-adapter", adapter.getComponentType());
assertNotNull(TestUtils.getPropertyValue(adapter, "poller"));
assertEquals(ac.getBean("ftpChannel"), TestUtils.getPropertyValue(adapter, "outputChannel"));
FtpInboundRemoteFileSystemSynchronizingMessageSource inbound =
(FtpInboundRemoteFileSystemSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source");
FtpInboundRemoteFileSystemSynchronizer fisync =
(FtpInboundRemoteFileSystemSynchronizer) TestUtils.getPropertyValue(inbound, "synchronizer");
CompositeFileListFilter<?> filter = (CompositeFileListFilter<?>) TestUtils.getPropertyValue(fisync, "filter");
Set<?> filters = (Set<?>) TestUtils.getPropertyValue(filter, "fileFilters");
assertEquals(2, filters.size());
assertTrue(filters.contains(ac.getBean("entryListFilter")));
FtpClientPool clientPoll = (FtpClientPool) TestUtils.getPropertyValue(inbound, "clientPool");
FtpClientFactory<?> clientFactory = (FtpClientFactory<?>) TestUtils.getPropertyValue(clientPoll, "factory");
assertEquals("localhost", TestUtils.getPropertyValue(clientFactory, "host"));
assertEquals(22, TestUtils.getPropertyValue(clientFactory, "port"));
assertEquals("user", TestUtils.getPropertyValue(clientFactory, "username"));
assertEquals("password", TestUtils.getPropertyValue(clientFactory, "password"));
assertEquals("foo/bar", TestUtils.getPropertyValue(clientFactory, "remoteWorkingDirectory"));
System.out.println();
}
@Test
public void testFtpsInboundChannelAdapterCompleteNoId() throws Exception{
ApplicationContext ac =
new ClassPathXmlApplicationContext("FtpsInboundChannelAdapterParserTests-context.xml", this.getClass());
Map<String, SourcePollingChannelAdapter> spcas = ac.getBeansOfType(SourcePollingChannelAdapter.class);
SourcePollingChannelAdapter adapter = null;
for (String key : spcas.keySet()) {
if (!key.equals("ftpInbound")){
adapter = spcas.get(key);
}
}
assertNotNull(adapter);
}
}