INT-1901 added support for 'comparator' atribute for FTP/SFTP Inbound Channel adapters

This commit is contained in:
Oleg Zhurakousky
2011-05-11 15:03:09 -04:00
parent 21cb39b892
commit 08d601a2ba
10 changed files with 67 additions and 2 deletions

View File

@@ -16,6 +16,9 @@
package org.springframework.integration.ftp.inbound;
import java.io.File;
import java.util.Comparator;
import org.apache.commons.net.ftp.FTPFile;
import org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer;
@@ -27,6 +30,7 @@ import org.springframework.integration.file.remote.synchronizer.AbstractInboundF
* @author Iwein Fuld
* @author Josh Long
* @author Mark Fisher
* @author Oleg Zhurakousky
* @since 2.0
*/
public class FtpInboundFileSynchronizingMessageSource extends AbstractInboundFileSynchronizingMessageSource<FTPFile> {
@@ -34,6 +38,10 @@ public class FtpInboundFileSynchronizingMessageSource extends AbstractInboundFil
public FtpInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer<FTPFile> synchronizer) {
super(synchronizer);
}
public FtpInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer<FTPFile> synchronizer, Comparator<File> comparator) {
super(synchronizer, comparator);
}
public String getComponentType() {

View File

@@ -116,6 +116,14 @@ endpoint itself is a Polling Consumer for a channel with a queue.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="comparator" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specify a Comparator to be used when ordering Files. If none is provided, the
order will be determined by the java.io.File implementation of Comparable.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="filter" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>

View File

@@ -20,10 +20,15 @@
filename-pattern="*.txt"
local-directory="."
remote-file-separator=""
comparator="comparator"
temporary-file-suffix=".foo"
remote-directory="foo/bar">
<int:poller fixed-rate="1000"/>
</int-ftp:inbound-channel-adapter>
<bean id="comparator" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="java.util.Comparator"/>
</bean>
<int-ftp:inbound-channel-adapter
channel="ftpChannel"

View File

@@ -22,6 +22,8 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.util.Comparator;
import java.util.Map;
import org.junit.Test;
@@ -44,11 +46,14 @@ import org.springframework.integration.test.util.TestUtils;
*/
public class FtpInboundChannelAdapterParserTests {
@SuppressWarnings("unchecked")
@Test
public void testFtpInboundChannelAdapterComplete() throws Exception{
ApplicationContext ac =
new ClassPathXmlApplicationContext("FtpInboundChannelAdapterParserTests-context.xml", this.getClass());
SourcePollingChannelAdapter adapter = ac.getBean("ftpInbound", SourcePollingChannelAdapter.class);
Comparator<File> comparator = TestUtils.getPropertyValue(adapter, "source.fileSource.toBeReceived.q.comparator", Comparator.class);
assertNotNull(comparator);
assertEquals("ftpInbound", adapter.getComponentName());
assertEquals("ftp:inbound-channel-adapter", adapter.getComponentType());
assertNotNull(TestUtils.getPropertyValue(adapter, "poller"));