From e83b472a37007e89b6287eb6cd77f227ae08f474 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 27 Jun 2018 16:32:55 -0400 Subject: [PATCH] RotatingSTests: Don't delete files between polls On Windows `File.delete()` causes to file to be modified first of all. with the high polling interval (`fixedDelay(1)`) there is a chance to pick the same file from the local directory again, since the `AbstractPersistentAcceptOnceFileListFilter` is based on the `lastModified` * Do not delete files manually at all - just rely on the `clean()` with the `@Before` **Cherry-pick to 5.0.x** --- .../ftp/inbound/RotatingServersTests.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java index c2da6d2d10..489ae6fa28 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java @@ -58,6 +58,7 @@ import org.springframework.integration.metadata.SimpleMetadataStore; /** * @author Gary Russell + * @author Artem Bilan * * @since 5.0.7 * @@ -103,10 +104,6 @@ public class RotatingServersTests extends FtpTestSupport { assertThat(f2.exists()).isTrue(); File f3 = new File(tmpDir + File.separator + "standard" + File.separator + "f3"); assertThat(f3.exists()).isTrue(); - assertThat(f1.delete()).isTrue(); - assertThat(f2.delete()).isTrue(); - assertThat(f3.delete()).isTrue(); - ctx.getBean("files", QueueChannel.class); assertThat(ctx.getBean("files", QueueChannel.class).getQueueSize()).isEqualTo(3); ctx.close(); } @@ -124,9 +121,6 @@ public class RotatingServersTests extends FtpTestSupport { assertThat(f2.exists()).isTrue(); File f3 = new File(tmpDir + File.separator + "fair" + File.separator + "f3"); assertThat(f3.exists()).isTrue(); - assertThat(f1.delete()).isTrue(); - assertThat(f2.delete()).isTrue(); - assertThat(f3.delete()).isTrue(); assertThat(ctx.getBean("files", QueueChannel.class).getQueueSize()).isEqualTo(3); ctx.close(); } @@ -144,12 +138,6 @@ public class RotatingServersTests extends FtpTestSupport { assertThat(f2.exists()).isTrue(); File f3 = new File(tmpDir + File.separator + "variable" + File.separator + "fiz" + File.separator + "f3"); assertThat(f3.exists()).isTrue(); - assertThat(f1.delete()).isTrue(); - assertThat(f2.delete()).isTrue(); - assertThat(f3.delete()).isTrue(); - assertThat(f1.getParentFile().delete()).isTrue(); - assertThat(f2.getParentFile().delete()).isTrue(); - assertThat(f3.getParentFile().delete()).isTrue(); assertThat(ctx.getBean("files", QueueChannel.class).getQueueSize()).isEqualTo(3); ctx.close(); } @@ -162,7 +150,6 @@ public class RotatingServersTests extends FtpTestSupport { List sfCalls = config.sessionSources.stream().limit(17).collect(Collectors.toList()); // there's an extra getSession() with this adapter in listFiles assertThat(sfCalls).containsExactly(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 2, 2, 3); - ctx.getBean("files", QueueChannel.class); assertThat(ctx.getBean("files", QueueChannel.class).getQueueSize()).isEqualTo(3); ctx.close(); }