Skip to content

Commit ab8f3c8

Browse files
committed
Add Comparator to (S)FTP order-sensitive tests
https://build.spring.io/browse/INT-MASTER-583/ **Cherry-pick to 4.3.x**
1 parent 4bb3f50 commit ab8f3c8

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpStreamingMessageSourceTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 the original author or authors.
2+
* Copyright 2016-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import static org.junit.Assert.assertThat;
2424

2525
import java.io.InputStream;
26+
import java.util.Comparator;
2627

2728
import org.apache.commons.net.ftp.FTPFile;
2829
import org.junit.Test;
@@ -38,6 +39,7 @@
3839
import org.springframework.integration.core.MessageSource;
3940
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
4041
import org.springframework.integration.file.FileHeaders;
42+
import org.springframework.integration.file.remote.FileInfo;
4143
import org.springframework.integration.file.remote.session.SessionFactory;
4244
import org.springframework.integration.ftp.FtpTestSupport;
4345
import org.springframework.integration.ftp.session.FtpFileInfo;
@@ -124,7 +126,8 @@ public PollerMetadata defaultPoller() {
124126
@Bean
125127
@InboundChannelAdapter(channel = "stream")
126128
public MessageSource<InputStream> ftpMessageSource() {
127-
FtpStreamingMessageSource messageSource = new FtpStreamingMessageSource(template(), null);
129+
FtpStreamingMessageSource messageSource = new FtpStreamingMessageSource(template(),
130+
Comparator.comparing(FileInfo::getFilename));
128131
messageSource.setRemoteDirectory("ftpSource/");
129132
return messageSource;
130133
}

spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void testSftpInboundStreamFlow() throws Exception {
123123
message = out.receive(10_000);
124124
assertNotNull(message);
125125
assertThat(message.getPayload(), instanceOf(InputStream.class));
126-
assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf("sftpSource1.txt", "sftpSource2.txt"));
126+
assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf(" sftpSource1.txt", "sftpSource2.txt"));
127127
((InputStream) message.getPayload()).close();
128128
new IntegrationMessageHeaderAccessor(message).getCloseableResource().close();
129129

spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 the original author or authors.
2+
* Copyright 2016-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import static org.junit.Assert.assertThat;
2424

2525
import java.io.InputStream;
26+
import java.util.Comparator;
2627

2728
import org.junit.Test;
2829
import org.junit.runner.RunWith;
@@ -37,6 +38,7 @@
3738
import org.springframework.integration.core.MessageSource;
3839
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
3940
import org.springframework.integration.file.FileHeaders;
41+
import org.springframework.integration.file.remote.FileInfo;
4042
import org.springframework.integration.file.remote.session.SessionFactory;
4143
import org.springframework.integration.scheduling.PollerMetadata;
4244
import org.springframework.integration.sftp.SftpTestSupport;
@@ -125,7 +127,8 @@ public PollerMetadata defaultPoller() {
125127
@Bean
126128
@InboundChannelAdapter(channel = "stream")
127129
public MessageSource<InputStream> sftpMessageSource() {
128-
SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template(), null);
130+
SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template(),
131+
Comparator.comparing(FileInfo::getFilename));
129132
messageSource.setRemoteDirectory("sftpSource/");
130133
return messageSource;
131134
}

0 commit comments

Comments
 (0)