This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit f056d609caa144d08590d38f72a320d8ce271706 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Mon Oct 3 13:25:29 2022 +0200 CAMEL-18575: use JUnit's 5 TempDir annotation in camel-ftp --- .../integration/FileToFtpTempFileNameIT.java | 8 ++++++-- .../remote/integration/FromFileToFtpDeleteIT.java | 11 +++++++--- .../integration/FromFileToFtpSplitParallelIT.java | 9 ++++++-- .../FromFtpDirectoryToBinaryFilesIT.java | 11 +++++++--- .../integration/FromFtpKeepLastModifiedIT.java | 24 ++++++++++++++-------- .../FromFtpSetNamesWithMultiDirectoriesIT.java | 10 ++++++--- .../remote/integration/FromFtpToAsciiFileIT.java | 8 ++++++-- .../FromFtpToAsciiFileNoBodyConversionIT.java | 7 ++++++- .../remote/integration/FromFtpToBinaryFileIT.java | 9 ++++++-- .../remote/integration/FromFtpToBinaryFilesIT.java | 10 ++++++--- .../FromFtpToFileNoFileNameHeaderIT.java | 9 ++++++-- .../remote/integration/FtpChangedReadLockIT.java | 12 +++++++---- .../integration/FtpChangedRootDirReadLockIT.java | 12 +++++++---- .../FtpChangedZeroLengthReadLockIT.java | 8 ++++++-- ...ConsumerLocalWorkDirectoryAsAbsolutePathIT.java | 16 +++++++-------- .../FtpConsumerLocalWorkDirectoryDirectIT.java | 13 ++++++++---- .../FtpConsumerLocalWorkDirectoryIT.java | 14 ++++++++----- ...pConsumerLocalWorkDirectoryWorkOnPayloadIT.java | 2 +- .../integration/FtpConsumerResumeDownloadIT.java | 15 ++++++++------ .../FtpSimpleConsumeStreamingStepwiseIT.java | 6 +++++- .../RemoteFileProduceOverruleOnlyOnceIT.java | 9 ++++++-- .../SftpConsumerLocalWorkDirectoryIT.java | 14 ++++++++----- .../remote/manual/FtpConsumerCamelManualTest.java | 7 ++++++- .../FtpConsumerCamelRecursiveManualTest.java | 7 ++++++- .../FtpConsumerNotStepwiseCamelManualTest.java | 7 ++++++- ...onsumerNotStepwiseCamelRecursiveManualTest.java | 7 ++++++- .../remote/manual/FtpConsumerScottManualTest.java | 7 ++++++- .../FtpConsumerScottRecursiveManualTest.java | 7 ++++++- .../sftp/integration/SftpChangedReadLockIT.java | 11 +++++++--- .../FileConsumerQuartzSchedulerRestartTest.java | 9 ++++++-- .../quartz/FileConsumerQuartzSchedulerTest.java | 9 ++++++-- 31 files changed, 221 insertions(+), 87 deletions(-) diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpTempFileNameIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpTempFileNameIT.java index 554b8c83591..78493b56097 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpTempFileNameIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpTempFileNameIT.java @@ -17,11 +17,13 @@ package org.apache.camel.component.file.remote.integration; import java.io.File; +import java.nio.file.Path; import org.apache.camel.Exchange; import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -29,12 +31,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * */ public class FileToFtpTempFileNameIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; @Test public void testFileToFtp() { NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create(); - template.sendBodyAndHeader(fileUri("in"), "Hello World", Exchange.FILE_NAME, "sub/hello.txt"); + template.sendBodyAndHeader(fileUri(testDirectory, "in"), "Hello World", Exchange.FILE_NAME, "sub/hello.txt"); assertTrue(notify.matchesWaitTime()); @@ -47,7 +51,7 @@ public class FileToFtpTempFileNameIT extends FtpServerTestSupport { return new RouteBuilder() { @Override public void configure() { - from(fileUri("in?recursive=true")) + from(fileUri(testDirectory, "in?recursive=true")) .to("ftp://admin:admin@localhost:{{ftp.server.port}}" + "/out/?fileName=${file:name}&tempFileName=${file:onlyname}.part&stepwise=false"); } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpDeleteIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpDeleteIT.java index 67ab098a474..cf97a6e9afd 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpDeleteIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpDeleteIT.java @@ -16,17 +16,22 @@ */ package org.apache.camel.component.file.remote.integration; +import java.nio.file.Path; + import org.apache.camel.Exchange; import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.apache.camel.test.junit5.TestSupport.assertFileExists; import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists; import static org.junit.jupiter.api.Assertions.assertTrue; public class FromFileToFtpDeleteIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; protected String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}?password=admin"; @@ -39,13 +44,13 @@ public class FromFileToFtpDeleteIT extends FtpServerTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - template.sendBodyAndHeader(fileUri("delete"), "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(fileUri(testDirectory, "delete"), "Hello World", Exchange.FILE_NAME, "hello.txt"); assertMockEndpointsSatisfied(); assertTrue(notify.matchesWaitTime()); // file should be deleted - assertFileNotExists(testFile("delete/hello.txt")); + assertFileNotExists(testDirectory.resolve("delete/hello.txt")); // file should exists on ftp server assertFileExists(service.ftpFile("hello.txt")); @@ -55,7 +60,7 @@ public class FromFileToFtpDeleteIT extends FtpServerTestSupport { protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from(fileUri("delete?delete=true")).to(getFtpUrl()).to("mock:result"); + from(fileUri(testDirectory, "delete?delete=true")).to(getFtpUrl()).to("mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpSplitParallelIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpSplitParallelIT.java index cd924d71e70..25957282f30 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpSplitParallelIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpSplitParallelIT.java @@ -18,6 +18,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.FileOutputStream; import java.nio.charset.StandardCharsets; +import java.nio.file.Path; import java.util.concurrent.TimeUnit; import org.apache.camel.builder.RouteBuilder; @@ -26,11 +27,15 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.spi.ThreadPoolProfile; import org.apache.camel.util.IOHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class FromFileToFtpSplitParallelIT extends FtpServerTestSupport { private static final int SIZE = 5000; + @TempDir + Path testDirectory; + protected String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/tmp2/big?password=admin"; } @@ -38,7 +43,7 @@ public class FromFileToFtpSplitParallelIT extends FtpServerTestSupport { @Test public void testSplit() throws Exception { // create big file - FileOutputStream fos = new FileOutputStream(testDirectory() + "/bigdata.txt"); + FileOutputStream fos = new FileOutputStream(testDirectory.toString() + "/bigdata.txt"); for (int i = 0; i < SIZE; i++) { String line = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-" + i + "\n"; fos.write(line.getBytes(StandardCharsets.UTF_8)); @@ -66,7 +71,7 @@ public class FromFileToFtpSplitParallelIT extends FtpServerTestSupport { onException().maximumRedeliveries(5).redeliveryDelay(1000); - from(fileUri()).noAutoStartup().routeId("foo") + from(fileUri(testDirectory)).noAutoStartup().routeId("foo") .split(body().tokenize("\n")).executorService("ftp-pool") .to(getFtpUrl()) .to("log:line?groupSize=100") diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpDirectoryToBinaryFilesIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpDirectoryToBinaryFilesIT.java index c419eceb435..740dcdd87eb 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpDirectoryToBinaryFilesIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpDirectoryToBinaryFilesIT.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.File; +import java.nio.file.Path; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; @@ -25,6 +26,7 @@ import org.apache.camel.converter.IOConverter; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -39,6 +41,9 @@ public class FromFtpDirectoryToBinaryFilesIT extends FtpServerTestSupport { private static File logo1File; private static long logo1FileSize; + @TempDir + Path testDirectory; + private String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/incoming/?password=admin" + "&binary=true&useFixedDelay=false&recursive=false&delay=5000"; @@ -73,12 +78,12 @@ public class FromFtpDirectoryToBinaryFilesIT extends FtpServerTestSupport { + " but should have been bigger than 10000"); // assert the file - File logo1DestFile = testFile("logo1.jpeg").toFile(); + File logo1DestFile = testDirectory.resolve("logo1.jpeg").toFile(); assertTrue(logo1DestFile.exists(), "The binary file should exists"); assertEquals(logo1FileSize, logo1DestFile.length(), "File size for logo1.jpg does not match"); // assert the file - File logoDestFile = testFile("logo.jpeg").toFile(); + File logoDestFile = testDirectory.resolve("logo.jpeg").toFile(); assertTrue(logoDestFile.exists(), " The binary file should exists"); assertEquals(logoFileSize, logoDestFile.length(), "File size for logo1.jpg does not match"); } @@ -87,7 +92,7 @@ public class FromFtpDirectoryToBinaryFilesIT extends FtpServerTestSupport { protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from(getFtpUrl()).to(fileUri("?noop=true"), "mock:result"); + from(getFtpUrl()).to(fileUri(testDirectory, "?noop=true"), "mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpKeepLastModifiedIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpKeepLastModifiedIT.java index 1316a51c222..baacca6a4b9 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpKeepLastModifiedIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpKeepLastModifiedIT.java @@ -16,11 +16,14 @@ */ package org.apache.camel.component.file.remote.integration; +import java.nio.file.Path; + import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotSame; @@ -30,6 +33,9 @@ import static org.junit.jupiter.api.Assertions.assertNotSame; */ public class FromFtpKeepLastModifiedIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; + protected String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/keep?password=admin&binary=false&noop=true"; } @@ -46,20 +52,20 @@ public class FromFtpKeepLastModifiedIT extends FtpServerTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from(getFtpUrl()).delay(3000).to(fileUri("?keepLastModified=true"), "mock:result"); + from(getFtpUrl()).delay(3000).to(fileUri(testDirectory, "?keepLastModified=true"), "mock:result"); } }); context.start(); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(testFile("hello.txt")); + mock.expectedFileExists(testDirectory.resolve("hello.txt")); mock.message(0).header(Exchange.FILE_LAST_MODIFIED).isNotNull(); assertMockEndpointsSatisfied(); long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED, long.class); - long t2 = testFile("hello.txt").toFile().lastModified(); + long t2 = testDirectory.resolve("hello.txt").toFile().lastModified(); assertEquals(t1, t2, "Timestamp should have been kept"); } @@ -69,20 +75,20 @@ public class FromFtpKeepLastModifiedIT extends FtpServerTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from(getFtpUrl()).delay(3000).to(fileUri("?keepLastModified=false"), "mock:result"); + from(getFtpUrl()).delay(3000).to(fileUri(testDirectory, "?keepLastModified=false"), "mock:result"); } }); context.start(); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(testFile("hello.txt")); + mock.expectedFileExists(testDirectory.resolve("hello.txt")); mock.message(0).header(Exchange.FILE_LAST_MODIFIED).isNotNull(); assertMockEndpointsSatisfied(); long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED, long.class); - long t2 = testFile("hello.txt").toFile().lastModified(); + long t2 = testDirectory.resolve("hello.txt").toFile().lastModified(); assertNotSame(t1, t2, "Timestamp should NOT have been kept"); } @@ -92,20 +98,20 @@ public class FromFtpKeepLastModifiedIT extends FtpServerTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from(getFtpUrl()).delay(3000).to(fileUri(), "mock:result"); + from(getFtpUrl()).delay(3000).to(fileUri(testDirectory), "mock:result"); } }); context.start(); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(testFile("hello.txt")); + mock.expectedFileExists(testDirectory.resolve("hello.txt")); mock.message(0).header(Exchange.FILE_LAST_MODIFIED).isNotNull(); assertMockEndpointsSatisfied(); long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED, long.class); - long t2 = testFile("hello.txt").toFile().lastModified(); + long t2 = testDirectory.resolve("hello.txt").toFile().lastModified(); assertNotSame(t1, t2, "Timestamp should NOT have been kept"); } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpSetNamesWithMultiDirectoriesIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpSetNamesWithMultiDirectoriesIT.java index 33cc0f2012a..0f0158b5b84 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpSetNamesWithMultiDirectoriesIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpSetNamesWithMultiDirectoriesIT.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.File; +import java.nio.file.Path; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; @@ -26,6 +27,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.converter.IOConverter; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -34,6 +36,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * the same directory layout. */ public class FromFtpSetNamesWithMultiDirectoriesIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; private String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}" @@ -58,12 +62,12 @@ public class FromFtpSetNamesWithMultiDirectoriesIT extends FtpServerTestSupport assertTrue(bytes.length > 10000, "Logo size wrong"); // assert the file - File file = testFile("data1/logo1.jpeg").toFile(); + File file = testDirectory.resolve("data1/logo1.jpeg").toFile(); assertTrue(file.exists(), "The binary file should exists"); assertTrue(file.length() > 10000, "Logo size wrong"); // assert the file - file = testFile("data2/logo2.png").toFile(); + file = testDirectory.resolve("data2/logo2.png").toFile(); assertTrue(file.exists(), " The binary file should exists"); assertTrue(file.length() > 50000, "Logo size wrong"); } @@ -97,7 +101,7 @@ public class FromFtpSetNamesWithMultiDirectoriesIT extends FtpServerTestSupport protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from(getFtpUrl()).routeId("foo").noAutoStartup().to(fileUri(), "mock:result"); + from(getFtpUrl()).routeId("foo").noAutoStartup().to(fileUri(testDirectory), "mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToAsciiFileIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToAsciiFileIT.java index d6873132877..52c6708c25e 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToAsciiFileIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToAsciiFileIT.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.File; +import java.nio.file.Path; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; @@ -25,6 +26,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -32,6 +34,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * Unit test to verify that we can pool an ASCII file from the FTP Server and store it on a local file path */ public class FromFtpToAsciiFileIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; private String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/tmp3/camel?password=admin&binary=false&fileExist=Override"; @@ -53,7 +57,7 @@ public class FromFtpToAsciiFileIT extends FtpServerTestSupport { resultEndpoint.assertIsSatisfied(); // assert the file - File file = testFile("deleteme.txt").toFile(); + File file = testDirectory.resolve("deleteme.txt").toFile(); assertTrue(file.exists(), "The ASCII file should exists"); assertTrue(file.length() > 10, "File size wrong"); } @@ -77,7 +81,7 @@ public class FromFtpToAsciiFileIT extends FtpServerTestSupport { return new RouteBuilder() { public void configure() { from(getFtpUrl()).setHeader(Exchange.FILE_NAME, constant("deleteme.txt")).convertBodyTo(String.class) - .to(fileUri("?fileExist=Override&noop=true")).to("mock:result"); + .to(fileUri(testDirectory, "?fileExist=Override&noop=true")).to("mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToAsciiFileNoBodyConversionIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToAsciiFileNoBodyConversionIT.java index 1ab50ff871e..60ae6260132 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToAsciiFileNoBodyConversionIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToAsciiFileNoBodyConversionIT.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.file.remote.integration; +import java.nio.file.Path; + import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.Producer; @@ -23,11 +25,14 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** * Unit testing a FTP ASCII transfer that Camel provides the needed conversion to String from the input stream. */ public class FromFtpToAsciiFileNoBodyConversionIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; private String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/tmp5/camel?password=admin&binary=false"; @@ -65,7 +70,7 @@ public class FromFtpToAsciiFileNoBodyConversionIT extends FtpServerTestSupport { protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from(getFtpUrl()).to(fileUri("?fileExist=Override&noop=true"), "mock:result"); + from(getFtpUrl()).to(fileUri(testDirectory, "?fileExist=Override&noop=true"), "mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToBinaryFileIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToBinaryFileIT.java index 5c38dc211a4..97eab50cb31 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToBinaryFileIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToBinaryFileIT.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.File; +import java.nio.file.Path; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; @@ -26,6 +27,7 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.converter.IOConverter; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -34,6 +36,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class FromFtpToBinaryFileIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; + // must user "consumer." prefix on the parameters to the file component private String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/tmp4/camel?password=admin&binary=true" @@ -57,7 +62,7 @@ public class FromFtpToBinaryFileIT extends FtpServerTestSupport { assertTrue(bytes.length > 10000, "Logo size wrong"); // assert the file - File file = testFile("deleteme.jpg").toFile(); + File file = testDirectory.resolve("deleteme.jpg").toFile(); assertTrue(file.exists(), "The binary file should exists"); assertTrue(file.length() > 10000, "Logo size wrong"); } @@ -80,7 +85,7 @@ public class FromFtpToBinaryFileIT extends FtpServerTestSupport { protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - String fileUrl = fileUri("?noop=true&fileExist=Override"); + String fileUrl = fileUri(testDirectory, "?noop=true&fileExist=Override"); from(getFtpUrl()).setHeader(Exchange.FILE_NAME, constant("deleteme.jpg")).to(fileUrl, "mock:result"); } }; diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToBinaryFilesIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToBinaryFilesIT.java index 09f4a1a1991..3d720ef0855 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToBinaryFilesIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToBinaryFilesIT.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.File; +import java.nio.file.Path; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; @@ -26,6 +27,7 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.converter.IOConverter; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -33,6 +35,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * Unit test to verify that we can pool a BINARY file from the FTP Server and store it on a local file path */ public class FromFtpToBinaryFilesIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; // must user "consumer." prefix on the parameters to the file component private String getFtpUrl() { @@ -56,12 +60,12 @@ public class FromFtpToBinaryFilesIT extends FtpServerTestSupport { assertTrue(bytes.length > 10000, "Logo size wrong"); // assert the file - File file = testFile("logo.jpeg").toFile(); + File file = testDirectory.resolve("logo.jpeg").toFile(); assertTrue(file.exists(), " The binary file should exists"); assertTrue(file.length() > 10000, "Logo size wrong"); // assert the file - file = testFile("a/logo1.jpeg").toFile(); + file = testDirectory.resolve("a/logo1.jpeg").toFile(); assertTrue(file.exists(), "The binary file should exists"); assertTrue(file.length() > 10000, "Logo size wrong"); } @@ -98,7 +102,7 @@ public class FromFtpToBinaryFilesIT extends FtpServerTestSupport { protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from(getFtpUrl()).to(fileUri("?noop=true"), "mock:result"); + from(getFtpUrl()).to(fileUri(testDirectory, "?noop=true"), "mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToFileNoFileNameHeaderIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToFileNoFileNameHeaderIT.java index 7dcacbe064f..c1867e6a1ba 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToFileNoFileNameHeaderIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpToFileNoFileNameHeaderIT.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.file.remote.integration; +import java.nio.file.Path; + import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.Producer; @@ -23,12 +25,15 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** * Unit test for consuming files from a FTP Server to files where we want to use the filename from the FTPServer instead * of explicit setting a filename using the file headername option. */ public class FromFtpToFileNoFileNameHeaderIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; private String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/tmp3/camel?password=admin&binary=false"; @@ -46,7 +51,7 @@ public class FromFtpToFileNoFileNameHeaderIT extends FtpServerTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello World from FTPServer"); - mock.expectedFileExists(testFile("hello.txt"), "Hello World from FTPServer"); + mock.expectedFileExists(testDirectory.resolve("hello.txt"), "Hello World from FTPServer"); mock.assertIsSatisfied(); } @@ -69,7 +74,7 @@ public class FromFtpToFileNoFileNameHeaderIT extends FtpServerTestSupport { protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - String fileUrl = fileUri("?fileExist=Override&noop=true"); + String fileUrl = fileUri(testDirectory, "?fileExist=Override&noop=true"); // we do not set any filename in the header property so the // filename should be the one // from the FTP server we downloaded diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedReadLockIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedReadLockIT.java index 5256157346d..e12405ffc67 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedReadLockIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedReadLockIT.java @@ -17,10 +17,12 @@ package org.apache.camel.component.file.remote.integration; import java.io.FileOutputStream; +import java.nio.file.Path; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,9 +33,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * */ public class FtpChangedReadLockIT extends FtpServerTestSupport { - private static final Logger LOG = LoggerFactory.getLogger(FtpChangedReadLockIT.class); + @TempDir + Path testDirectory; + protected String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}" + "/changed?password=admin&readLock=changed&readLockCheckInterval=1000&delete=true"; @@ -43,13 +47,13 @@ public class FtpChangedReadLockIT extends FtpServerTestSupport { public void testChangedReadLock() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(testFile("out/slowfile.dat")); + mock.expectedFileExists(testDirectory.resolve("out/slowfile.dat")); writeSlowFile(); assertMockEndpointsSatisfied(); - String content = context.getTypeConverter().convertTo(String.class, testFile("out/slowfile.dat").toFile()); + String content = context.getTypeConverter().convertTo(String.class, testDirectory.resolve("out/slowfile.dat").toFile()); String[] lines = content.split(LS); assertEquals(20, lines.length, "There should be 20 lines in the file"); for (int i = 0; i < 20; i++) { @@ -78,7 +82,7 @@ public class FtpChangedReadLockIT extends FtpServerTestSupport { return new RouteBuilder() { @Override public void configure() { - from(getFtpUrl()).to(fileUri("out"), "mock:result"); + from(getFtpUrl()).to(fileUri(testDirectory, "out"), "mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedRootDirReadLockIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedRootDirReadLockIT.java index 110bbe7488b..3384653a24e 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedRootDirReadLockIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedRootDirReadLockIT.java @@ -18,11 +18,13 @@ package org.apache.camel.component.file.remote.integration; import java.io.FileOutputStream; import java.nio.file.Files; +import java.nio.file.Path; import java.util.List; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,9 +35,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * */ public class FtpChangedRootDirReadLockIT extends FtpServerTestSupport { - private static final Logger LOG = LoggerFactory.getLogger(FtpChangedRootDirReadLockIT.class); + @TempDir + Path testDirectory; + protected String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}" + "/?password=admin&readLock=changed&readLockCheckInterval=1000&delete=true"; @@ -45,13 +49,13 @@ public class FtpChangedRootDirReadLockIT extends FtpServerTestSupport { public void testChangedReadLock() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(testFile("slowfile.dat")); + mock.expectedFileExists(testDirectory.resolve("slowfile.dat")); writeSlowFile(); assertMockEndpointsSatisfied(); - List<String> lines = Files.readAllLines(testFile("slowfile.dat")); + List<String> lines = Files.readAllLines(testDirectory.resolve("slowfile.dat")); assertEquals(20, lines.size(), "There should be 20 lines in the file"); for (int i = 0; i < 20; i++) { assertEquals("Line " + i, lines.get(i)); @@ -79,7 +83,7 @@ public class FtpChangedRootDirReadLockIT extends FtpServerTestSupport { return new RouteBuilder() { @Override public void configure() { - from(getFtpUrl()).to(fileUri(), "mock:result"); + from(getFtpUrl()).to(fileUri(testDirectory), "mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedZeroLengthReadLockIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedZeroLengthReadLockIT.java index e2742de104d..f2265ff02bb 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedZeroLengthReadLockIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpChangedZeroLengthReadLockIT.java @@ -17,10 +17,12 @@ package org.apache.camel.component.file.remote.integration; import java.io.FileOutputStream; +import java.nio.file.Path; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.apache.camel.test.junit5.TestSupport.createDirectory; @@ -28,6 +30,8 @@ import static org.apache.camel.test.junit5.TestSupport.createDirectory; * */ public class FtpChangedZeroLengthReadLockIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; protected String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}" @@ -38,7 +42,7 @@ public class FtpChangedZeroLengthReadLockIT extends FtpServerTestSupport { public void testChangedReadLock() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(testFile("zerofile.dat")); + mock.expectedFileExists(testDirectory.resolve("zerofile.dat")); writeZeroFile(); @@ -57,7 +61,7 @@ public class FtpChangedZeroLengthReadLockIT extends FtpServerTestSupport { return new RouteBuilder() { @Override public void configure() { - from(getFtpUrl()).to(fileUri(), "mock:result"); + from(getFtpUrl()).to(fileUri(testDirectory), "mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryAsAbsolutePathIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryAsAbsolutePathIT.java index b8383521147..286ed3c2db3 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryAsAbsolutePathIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryAsAbsolutePathIT.java @@ -29,6 +29,7 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.util.FileUtil; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.apache.camel.test.junit5.TestSupport.assertFileExists; import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists; @@ -38,13 +39,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class FtpConsumerLocalWorkDirectoryAsAbsolutePathIT extends FtpServerTestSupport { - - private Path base; + @TempDir + Path testDirectory; protected String getFtpUrl() { - base = testDirectory("lwd").toAbsolutePath(); return "ftp://admin@localhost:{{ftp.server.port}}/lwd/?password=admin&delay=5000&noop=true&localWorkDirectory=" - + base; + + testDirectory.toAbsolutePath(); } @Override @@ -65,10 +65,10 @@ public class FtpConsumerLocalWorkDirectoryAsAbsolutePathIT extends FtpServerTest // give test some time to close file resources // now the lwd file should be deleted await().atMost(6, TimeUnit.SECONDS) - .untilAsserted(() -> assertFileNotExists(base.resolve("hello.txt"))); + .untilAsserted(() -> assertFileNotExists(testDirectory.resolve("hello.txt"))); // and the out file should exists - assertFileExists(testFile("out/hello.txt"), "Hello World"); + assertFileExists(testDirectory.resolve("out/hello.txt"), "Hello World"); } private void prepareFtpServer() throws Exception { @@ -95,9 +95,9 @@ public class FtpConsumerLocalWorkDirectoryAsAbsolutePathIT extends FtpServerTest assertNotNull(body); assertTrue(body.isAbsolute(), "Should be absolute path"); assertTrue(body.exists(), "Local work file should exists"); - assertEquals(FileUtil.normalizePath(base.resolve("hello.txt").toString()), body.getPath()); + assertEquals(FileUtil.normalizePath(testDirectory.resolve("hello.txt").toString()), body.getPath()); } - }).to("mock:result", fileUri("out")); + }).to("mock:result", fileUri(testDirectory, "out")); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryDirectIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryDirectIT.java index 0ec64c82dcf..2bc22fc3f3d 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryDirectIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryDirectIT.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.file.remote.integration; +import java.nio.file.Path; + import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.Producer; @@ -23,16 +25,19 @@ import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.apache.camel.test.junit5.TestSupport.assertFileExists; import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists; import static org.junit.jupiter.api.Assertions.assertTrue; public class FtpConsumerLocalWorkDirectoryDirectIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; protected String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/lwd/?password=admin&delay=5000" - + "&localWorkDirectory=" + testDirectory("lwd") + + "&localWorkDirectory=" + testDirectory.resolve("lwd") + "&noop=true"; } @@ -63,17 +68,17 @@ public class FtpConsumerLocalWorkDirectoryDirectIT extends FtpServerTestSupport assertTrue(notify.matchesWaitTime(), "Should process one file"); // and the out file should exists - assertFileExists(testFile("out/hello.txt"), "Hello World"); + assertFileExists(testDirectory.resolve("out/hello.txt"), "Hello World"); // now the lwd file should be deleted - assertFileNotExists(testFile("lwd/hello.txt")); + assertFileNotExists(testDirectory.resolve("lwd/hello.txt")); } @Override protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from(getFtpUrl()).to(fileUri("out")); + from(getFtpUrl()).to(fileUri(testDirectory, "out")); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryIT.java index 97aca0343e5..ffef8061bdd 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryIT.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.File; +import java.nio.file.Path; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; @@ -28,6 +29,7 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.util.FileUtil; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.apache.camel.test.junit5.TestSupport.assertFileExists; import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists; @@ -36,10 +38,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class FtpConsumerLocalWorkDirectoryIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; protected String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/lwd/?password=admin" - + "&localWorkDirectory=" + testDirectory("lwd") + + "&localWorkDirectory=" + testDirectory.resolve("lwd") + "&noop=true"; } @@ -79,10 +83,10 @@ public class FtpConsumerLocalWorkDirectoryIT extends FtpServerTestSupport { assertTrue(notify.matchesWaitTime()); // and the out file should exists - assertFileExists(testFile("out/hello.txt"), "Hello World"); + assertFileExists(testDirectory.resolve("out/hello.txt"), "Hello World"); // now the lwd file should be deleted - assertFileNotExists(testFile("lwd/hello.txt")); + assertFileNotExists(testDirectory.resolve("lwd/hello.txt")); } @Override @@ -94,9 +98,9 @@ public class FtpConsumerLocalWorkDirectoryIT extends FtpServerTestSupport { File body = exchange.getIn().getBody(File.class); assertNotNull(body); assertTrue(body.exists(), "Local work file should exists"); - assertEquals(FileUtil.normalizePath(testFile("lwd/hello.txt").toString()), body.getPath()); + assertEquals(FileUtil.normalizePath(testDirectory.resolve("lwd/hello.txt").toString()), body.getPath()); } - }).to("mock:result", fileUri("out")); + }).to("mock:result", fileUri(testDirectory, "out")); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryWorkOnPayloadIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryWorkOnPayloadIT.java index 9217d59d7c3..263f519355c 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryWorkOnPayloadIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerLocalWorkDirectoryWorkOnPayloadIT.java @@ -32,7 +32,7 @@ public class FtpConsumerLocalWorkDirectoryWorkOnPayloadIT extends FtpConsumerLoc exchange.getIn().setBody("Hello World"); } - }).to("mock:result", fileUri("out")); + }).to("mock:result", fileUri(testDirectory, "out")); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerResumeDownloadIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerResumeDownloadIT.java index f6e5ef81268..64c8ca5a7fb 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerResumeDownloadIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerResumeDownloadIT.java @@ -24,6 +24,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.apache.camel.test.junit5.TestSupport.assertFileExists; import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists; @@ -32,8 +33,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class FtpConsumerResumeDownloadIT extends FtpServerTestSupport { + @TempDir + Path lwd; + protected String getFtpUrl() { - return "ftp://admin@localhost:{{ftp.server.port}}/myserver/?password=admin&localWorkDirectory=" + testDirectory("lwd") + return "ftp://admin@localhost:{{ftp.server.port}}/myserver/?password=admin&localWorkDirectory=" + lwd.resolve("lwd") + "&resumeDownload=true&binary=true"; } @@ -48,7 +52,6 @@ public class FtpConsumerResumeDownloadIT extends FtpServerTestSupport { Files.write(myserver.resolve("hello.txt"), "Hello\nWorld\nI was here".getBytes()); // create in-progress file with partial download - Path lwd = testDirectory("lwd", true); Files.write(lwd.resolve("hello.txt.inprogress"), "Hello\n".getBytes()); } @@ -66,20 +69,20 @@ public class FtpConsumerResumeDownloadIT extends FtpServerTestSupport { assertTrue(notify.matchesWaitTime()); // and the out file should exists - assertFileExists(testFile("out/hello.txt"), "Hello\nWorld\nI was here"); + assertFileExists(lwd.resolve("out/hello.txt"), "Hello\nWorld\nI was here"); // now the lwd file should be deleted - assertFileNotExists(testFile("lwd/hello.txt")); + assertFileNotExists(lwd.resolve("lwd/hello.txt")); // and so the in progress - assertFileNotExists(testFile("lwd/hello.txt.inprogress")); + assertFileNotExists(lwd.resolve("lwd/hello.txt.inprogress")); } @Override protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from(getFtpUrl()).routeId("myRoute").noAutoStartup().to("mock:result", fileUri("out")); + from(getFtpUrl()).routeId("myRoute").noAutoStartup().to("mock:result", fileUri(lwd, "out")); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpSimpleConsumeStreamingStepwiseIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpSimpleConsumeStreamingStepwiseIT.java index cfb56bc4a97..d50a7d76cda 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpSimpleConsumeStreamingStepwiseIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpSimpleConsumeStreamingStepwiseIT.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.InputStream; +import java.nio.file.Path; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; @@ -26,6 +27,7 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.converter.IOConverter; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -36,6 +38,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; // On plain local vsftpd the download failed for every > 1mb file, here I had to make it bigger to trigger the error. public class FtpSimpleConsumeStreamingStepwiseIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; private String getFtpUrl() { return "ftp://admin@localhost:{{ftp.server.port}}/tmp4/camel?password=admin&binary=true&delay=5000" + @@ -76,7 +80,7 @@ public class FtpSimpleConsumeStreamingStepwiseIT extends FtpServerTestSupport { return new RouteBuilder() { public void configure() { from(getFtpUrl()).setHeader(Exchange.FILE_NAME, constant("deleteme.jpg")) - .to(fileUri(), "mock:result"); + .to(fileUri(testDirectory), "mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/RemoteFileProduceOverruleOnlyOnceIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/RemoteFileProduceOverruleOnlyOnceIT.java index b73f28cd099..122e2620f71 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/RemoteFileProduceOverruleOnlyOnceIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/RemoteFileProduceOverruleOnlyOnceIT.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.file.remote.integration; +import java.nio.file.Path; import java.util.HashMap; import java.util.Map; @@ -23,11 +24,14 @@ import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** * */ public class RemoteFileProduceOverruleOnlyOnceIT extends FtpServerTestSupport { + @TempDir + Path testDirectory; @Test public void testFileToFtp() throws Exception { @@ -39,7 +43,7 @@ public class RemoteFileProduceOverruleOnlyOnceIT extends FtpServerTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedHeaderReceived(Exchange.FILE_NAME, "/sub/hello.txt"); mock.expectedFileExists(service.ftpFile("out/sub/ruled.txt"), "Hello World"); - mock.expectedFileExists(testFile("out/sub/hello.txt"), "Hello World"); + mock.expectedFileExists(testDirectory.resolve("out/sub/hello.txt"), "Hello World"); assertMockEndpointsSatisfied(); } @@ -49,7 +53,8 @@ public class RemoteFileProduceOverruleOnlyOnceIT extends FtpServerTestSupport { return new RouteBuilder() { @Override public void configure() { - from("direct:input").to("ftp://admin:admin@localhost:{{ftp.server.port}}/out/").to(fileUri("out"), + from("direct:input").to("ftp://admin:admin@localhost:{{ftp.server.port}}/out/").to( + fileUri(testDirectory, "out"), "mock:result"); } }; diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/SftpConsumerLocalWorkDirectoryIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/SftpConsumerLocalWorkDirectoryIT.java index d6f86e01031..fecafca5e66 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/SftpConsumerLocalWorkDirectoryIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/SftpConsumerLocalWorkDirectoryIT.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file.remote.integration; import java.io.File; +import java.nio.file.Path; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; @@ -29,6 +30,7 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.util.FileUtil; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.apache.camel.test.junit5.TestSupport.assertFileExists; import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists; @@ -37,10 +39,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class SftpConsumerLocalWorkDirectoryIT extends SftpServerTestSupport { + @TempDir + Path testDirectory; protected String getFtpUrl() { return "sftp://localhost:{{ftp.server.port}}/{{ftp.root.dir}}/?password=admin" - + "&localWorkDirectory=" + testDirectory("lwd") + + "&localWorkDirectory=" + testDirectory.resolve("lwd") + "&noop=true"; } @@ -80,10 +84,10 @@ public class SftpConsumerLocalWorkDirectoryIT extends SftpServerTestSupport { assertTrue(notify.matchesWaitTime()); // and the out file should exists - assertFileExists(testFile("out/hello.txt"), "Hello World"); + assertFileExists(testDirectory.resolve("out/hello.txt"), "Hello World"); // now the lwd file should be deleted - assertFileNotExists(testFile("lwd/hello.txt")); + assertFileNotExists(testDirectory.resolve("lwd/hello.txt")); } @Override @@ -95,9 +99,9 @@ public class SftpConsumerLocalWorkDirectoryIT extends SftpServerTestSupport { File body = exchange.getIn().getBody(File.class); assertNotNull(body); assertTrue(body.exists(), "Local work file should exists"); - assertEquals(FileUtil.normalizePath(testFile("lwd/hello.txt").toString()), body.getPath()); + assertEquals(FileUtil.normalizePath(testDirectory.resolve("lwd/hello.txt").toString()), body.getPath()); } - }).to("mock:result", fileUri("out")); + }).to("mock:result", fileUri(testDirectory, "out")); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerCamelManualTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerCamelManualTest.java index 73eb52b1230..6e655e34e5f 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerCamelManualTest.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerCamelManualTest.java @@ -16,13 +16,18 @@ */ package org.apache.camel.component.file.remote.manual; +import java.nio.file.Path; + import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; @Disabled("Run this test manually") public class FtpConsumerCamelManualTest extends CamelTestSupport { + @TempDir + Path testDirectory; @Test public void testFtpConsumerManual() throws Exception { @@ -35,7 +40,7 @@ public class FtpConsumerCamelManualTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from("ftp:localhost/one/two?username=camel&password=camel&noop=true").to(fileUri()) + from("ftp:localhost/one/two?username=camel&password=camel&noop=true").to(fileUri(testDirectory)) .to("mock:result"); } }; diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerCamelRecursiveManualTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerCamelRecursiveManualTest.java index 73755a5176f..0ecbd8ecadf 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerCamelRecursiveManualTest.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerCamelRecursiveManualTest.java @@ -16,13 +16,18 @@ */ package org.apache.camel.component.file.remote.manual; +import java.nio.file.Path; + import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; @Disabled("Run this test manually") public class FtpConsumerCamelRecursiveManualTest extends CamelTestSupport { + @TempDir + Path testDirectory; @Test public void testFtpConsumerManual() throws Exception { @@ -35,7 +40,7 @@ public class FtpConsumerCamelRecursiveManualTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from("ftp:localhost/one/two?username=camel&password=camel&recursive=true&noop=true").to(fileUri()) + from("ftp:localhost/one/two?username=camel&password=camel&recursive=true&noop=true").to(fileUri(testDirectory)) .to("mock:result"); } }; diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerNotStepwiseCamelManualTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerNotStepwiseCamelManualTest.java index 78d68d3e8ec..8e5fe8ccd3b 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerNotStepwiseCamelManualTest.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerNotStepwiseCamelManualTest.java @@ -16,13 +16,18 @@ */ package org.apache.camel.component.file.remote.manual; +import java.nio.file.Path; + import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; @Disabled("Run this test manually") public class FtpConsumerNotStepwiseCamelManualTest extends CamelTestSupport { + @TempDir + Path testDirectory; @Test public void testFtpConsumerManual() throws Exception { @@ -35,7 +40,7 @@ public class FtpConsumerNotStepwiseCamelManualTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from("ftp:localhost/one/two?username=camel&password=camel&noop=true&stepwise=false").to(fileUri()) + from("ftp:localhost/one/two?username=camel&password=camel&noop=true&stepwise=false").to(fileUri(testDirectory)) .to("mock:result"); } }; diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerNotStepwiseCamelRecursiveManualTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerNotStepwiseCamelRecursiveManualTest.java index bbe5c2c101a..c6582f9024d 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerNotStepwiseCamelRecursiveManualTest.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerNotStepwiseCamelRecursiveManualTest.java @@ -16,13 +16,18 @@ */ package org.apache.camel.component.file.remote.manual; +import java.nio.file.Path; + import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; @Disabled("Run this test manually") public class FtpConsumerNotStepwiseCamelRecursiveManualTest extends CamelTestSupport { + @TempDir + Path testDirectory; @Test public void testFtpConsumerManual() throws Exception { @@ -36,7 +41,7 @@ public class FtpConsumerNotStepwiseCamelRecursiveManualTest extends CamelTestSup @Override public void configure() { from("ftp:localhost/one/two?username=camel&password=camel&recursive=true&noop=true&stepwise=false") - .to(fileUri()).to("mock:result"); + .to(fileUri(testDirectory)).to("mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerScottManualTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerScottManualTest.java index 2f5d3242134..87a13e1cd77 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerScottManualTest.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerScottManualTest.java @@ -16,13 +16,18 @@ */ package org.apache.camel.component.file.remote.manual; +import java.nio.file.Path; + import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; @Disabled("Run this test manually") public class FtpConsumerScottManualTest extends CamelTestSupport { + @TempDir + Path testDirectory; @Test public void testFtpConsumerManual() throws Exception { @@ -35,7 +40,7 @@ public class FtpConsumerScottManualTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from("ftp:localhost?username=scott&password=tiger&noop=true").to(fileUri()).to("mock:result"); + from("ftp:localhost?username=scott&password=tiger&noop=true").to(fileUri(testDirectory)).to("mock:result"); } }; } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerScottRecursiveManualTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerScottRecursiveManualTest.java index 09881241eac..2e962e3fb6d 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerScottRecursiveManualTest.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/manual/FtpConsumerScottRecursiveManualTest.java @@ -16,13 +16,18 @@ */ package org.apache.camel.component.file.remote.manual; +import java.nio.file.Path; + import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; @Disabled("Run this test manually") public class FtpConsumerScottRecursiveManualTest extends CamelTestSupport { + @TempDir + Path testDirectory; @Test public void testFtpConsumerManual() throws Exception { @@ -35,7 +40,7 @@ public class FtpConsumerScottRecursiveManualTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from("ftp:localhost?username=scott&password=tiger&noop=true&recursive=true").to(fileUri()) + from("ftp:localhost?username=scott&password=tiger&noop=true&recursive=true").to(fileUri(testDirectory)) .to("mock:result"); } }; diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChangedReadLockIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChangedReadLockIT.java index ca341721a1e..36cb55ad256 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChangedReadLockIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChangedReadLockIT.java @@ -17,11 +17,13 @@ package org.apache.camel.component.file.remote.sftp.integration; import java.io.FileOutputStream; +import java.nio.file.Path; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIf; +import org.junit.jupiter.api.io.TempDir; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +35,9 @@ public class SftpChangedReadLockIT extends SftpServerTestSupport { private static final Logger LOG = LoggerFactory.getLogger(SftpChangedReadLockIT.class); + @TempDir + Path testDirectory; + protected String getFtpUrl() { return "sftp://localhost:{{ftp.server.port}}/{{ftp.root.dir}}/changed" + "?username=admin&password=admin&readLock=changed&readLockCheckInterval=1000&delete=true"; @@ -42,7 +47,7 @@ public class SftpChangedReadLockIT extends SftpServerTestSupport { public void testChangedReadLock() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(testFile("out/slowfile.dat")); + mock.expectedFileExists(testDirectory.resolve("out/slowfile.dat")); context.getRouteController().startRoute("foo"); @@ -50,7 +55,7 @@ public class SftpChangedReadLockIT extends SftpServerTestSupport { assertMockEndpointsSatisfied(); - String content = context.getTypeConverter().convertTo(String.class, testFile("out/slowfile.dat").toFile()); + String content = context.getTypeConverter().convertTo(String.class, testDirectory.resolve("out/slowfile.dat").toFile()); String[] lines = content.split(LS); assertEquals(20, lines.length, "There should be 20 lines in the file"); for (int i = 0; i < 20; i++) { @@ -78,7 +83,7 @@ public class SftpChangedReadLockIT extends SftpServerTestSupport { return new RouteBuilder() { @Override public void configure() { - from(getFtpUrl()).routeId("foo").noAutoStartup().to(fileUri("out"), "mock:result"); + from(getFtpUrl()).routeId("foo").noAutoStartup().to(fileUri(testDirectory, "out"), "mock:result"); } }; } diff --git a/components/camel-quartz/src/test/java/org/apache/camel/pollconsumer/quartz/FileConsumerQuartzSchedulerRestartTest.java b/components/camel-quartz/src/test/java/org/apache/camel/pollconsumer/quartz/FileConsumerQuartzSchedulerRestartTest.java index 1c03ccfff67..5e6f6e99551 100644 --- a/components/camel-quartz/src/test/java/org/apache/camel/pollconsumer/quartz/FileConsumerQuartzSchedulerRestartTest.java +++ b/components/camel-quartz/src/test/java/org/apache/camel/pollconsumer/quartz/FileConsumerQuartzSchedulerRestartTest.java @@ -16,17 +16,22 @@ */ package org.apache.camel.pollconsumer.quartz; +import java.nio.file.Path; + import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class FileConsumerQuartzSchedulerRestartTest extends CamelTestSupport { + @TempDir + Path testDirectory; @Test public void testQuartzSchedulerRestart() throws Exception { getMockEndpoint("mock:result").expectedMessageCount(1); - template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(fileUri(testDirectory), "Hello World", Exchange.FILE_NAME, "hello.txt"); context.getRouteController().startRoute("foo"); assertMockEndpointsSatisfied(); @@ -34,7 +39,7 @@ public class FileConsumerQuartzSchedulerRestartTest extends CamelTestSupport { resetMocks(); getMockEndpoint("mock:result").expectedMessageCount(1); - template.sendBodyAndHeader(fileUri(), "Bye World", Exchange.FILE_NAME, "bye.txt"); + template.sendBodyAndHeader(fileUri(testDirectory), "Bye World", Exchange.FILE_NAME, "bye.txt"); context.getRouteController().startRoute("foo"); assertMockEndpointsSatisfied(); } diff --git a/components/camel-quartz/src/test/java/org/apache/camel/pollconsumer/quartz/FileConsumerQuartzSchedulerTest.java b/components/camel-quartz/src/test/java/org/apache/camel/pollconsumer/quartz/FileConsumerQuartzSchedulerTest.java index 82a9d73ee7e..9d745536cec 100644 --- a/components/camel-quartz/src/test/java/org/apache/camel/pollconsumer/quartz/FileConsumerQuartzSchedulerTest.java +++ b/components/camel-quartz/src/test/java/org/apache/camel/pollconsumer/quartz/FileConsumerQuartzSchedulerTest.java @@ -16,18 +16,23 @@ */ package org.apache.camel.pollconsumer.quartz; +import java.nio.file.Path; + import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class FileConsumerQuartzSchedulerTest extends CamelTestSupport { + @TempDir + Path testDirectory; @Test public void testQuartzScheduler() throws Exception { getMockEndpoint("mock:result").expectedMessageCount(1); - template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(fileUri(testDirectory), "Hello World", Exchange.FILE_NAME, "hello.txt"); context.getRouteController().startRoute("foo"); @@ -39,7 +44,7 @@ public class FileConsumerQuartzSchedulerTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from(fileUri("?scheduler=quartz&scheduler.cron=0/2+*+*+*+*+?")).routeId("foo").noAutoStartup() + from(fileUri(testDirectory,"?scheduler=quartz&scheduler.cron=0/2+*+*+*+*+?")).routeId("foo").noAutoStartup() .to("mock:result"); } };