From ab8f3c8f05e41e122c3deb27a1bcfd0a260ff1e5 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Sat, 11 Mar 2017 13:28:55 -0500 Subject: [PATCH] Add Comparator to (S)FTP order-sensitive tests https://build.spring.io/browse/INT-MASTER-583/ **Cherry-pick to 4.3.x** --- .../ftp/inbound/FtpStreamingMessageSourceTests.java | 7 +++++-- .../springframework/integration/sftp/dsl/SftpTests.java | 2 +- .../sftp/inbound/SftpStreamingMessageSourceTests.java | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpStreamingMessageSourceTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpStreamingMessageSourceTests.java index f63ad96ee8..913978825f 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpStreamingMessageSourceTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpStreamingMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import java.io.InputStream; +import java.util.Comparator; import org.apache.commons.net.ftp.FTPFile; import org.junit.Test; @@ -38,6 +39,7 @@ import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.core.MessageSource; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.file.FileHeaders; +import org.springframework.integration.file.remote.FileInfo; import org.springframework.integration.file.remote.session.SessionFactory; import org.springframework.integration.ftp.FtpTestSupport; import org.springframework.integration.ftp.session.FtpFileInfo; @@ -124,7 +126,8 @@ public class FtpStreamingMessageSourceTests extends FtpTestSupport { @Bean @InboundChannelAdapter(channel = "stream") public MessageSource ftpMessageSource() { - FtpStreamingMessageSource messageSource = new FtpStreamingMessageSource(template(), null); + FtpStreamingMessageSource messageSource = new FtpStreamingMessageSource(template(), + Comparator.comparing(FileInfo::getFilename)); messageSource.setRemoteDirectory("ftpSource/"); return messageSource; } diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java index 276521c054..2478c98d5c 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java @@ -123,7 +123,7 @@ public class SftpTests extends SftpTestSupport { message = out.receive(10_000); assertNotNull(message); assertThat(message.getPayload(), instanceOf(InputStream.class)); - assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf("sftpSource1.txt", "sftpSource2.txt")); + assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf(" sftpSource1.txt", "sftpSource2.txt")); ((InputStream) message.getPayload()).close(); new IntegrationMessageHeaderAccessor(message).getCloseableResource().close(); diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java index 0cff210045..1efd40376a 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import java.io.InputStream; +import java.util.Comparator; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,6 +38,7 @@ import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.core.MessageSource; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.file.FileHeaders; +import org.springframework.integration.file.remote.FileInfo; import org.springframework.integration.file.remote.session.SessionFactory; import org.springframework.integration.scheduling.PollerMetadata; import org.springframework.integration.sftp.SftpTestSupport; @@ -125,7 +127,8 @@ public class SftpStreamingMessageSourceTests extends SftpTestSupport { @Bean @InboundChannelAdapter(channel = "stream") public MessageSource sftpMessageSource() { - SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template(), null); + SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template(), + Comparator.comparing(FileInfo::getFilename)); messageSource.setRemoteDirectory("sftpSource/"); return messageSource; }