From 22ee6586a046e6874137a5227e3de03f6f374cb3 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Mon, 20 Jul 2015 13:28:20 -0400 Subject: [PATCH] INT-3593: Fix FTP PartialSuccess Tests JIRA: https://jira.spring.io/browse/INT-3593 Sort the files for the MPUT tests. --- .../FtpServerOutboundTests-context.xml | 5 ++++ .../ftp/outbound/FtpServerOutboundTests.java | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests-context.xml index 722f69d352..94564cb7b8 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests-context.xml @@ -78,6 +78,7 @@ filename-pattern="*.txt" expression="payload" remote-directory="ftpTarget" + mput-filter="sortingFilter" reply-channel="output"/> @@ -90,6 +91,7 @@ filename-pattern="*.txt" expression="payload" remote-directory="ftpTarget" + mput-filter="sortingFilter" reply-channel="output"/> @@ -155,4 +157,7 @@ auto-create-directory="true" remote-file-separator="/" /> + + diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java index 2b606e7884..d035bbde43 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java @@ -38,6 +38,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.Calendar; +import java.util.Comparator; import java.util.List; import java.util.Set; import java.util.concurrent.BlockingQueue; @@ -57,6 +58,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.file.FileHeaders; +import org.springframework.integration.file.filters.FileListFilter; import org.springframework.integration.file.remote.InputStreamCallback; import org.springframework.integration.file.remote.RemoteFileTemplate; import org.springframework.integration.file.remote.SessionCallback; @@ -533,4 +535,29 @@ public class FtpServerOutboundTests { assertEquals(6, files[0].getSize()); } + public static class SortingFileListFilter implements FileListFilter { + + @Override + public List filterFiles(File[] files) { + File[] sorted = Arrays.copyOf(files, files.length); + Arrays.sort(sorted, new Comparator() { + + @Override + public int compare(File o1, File o2) { + if (o1.isDirectory() && !o2.isDirectory()) { + return 1; + } + else if (!o1.isDirectory() && o2.isDirectory()) { + return -1; + } + else { + return o1.getName().compareTo(o2.getName()); + } + } + + }); + return Arrays.asList(sorted); + } + + } }