You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/10/03 15:58:29 UTC

[camel] branch main updated (eaa359b7eac -> 15031810259)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from eaa359b7eac camel-jbang - Upgrade to Camel 3.19.0
     new 911dae99f7f CAMEL-18575: allow creating data directories from Path instances in camel-test-infra-activemq
     new 990559c66f7 CAMEL-18575: use JUnit's 5 TempDir annotation camel-activemq
     new 9acb1e0bacb CAMEL-18575: use JUnit's 5 TempDir annotation camel-barcode
     new f056d609caa CAMEL-18575: use JUnit's 5 TempDir annotation in camel-ftp
     new 79d5c376639 CAMEL-18575: use JUnit's 5 TempDir annotation in camel-jetty
     new b691215b6dd CAMEL-18575: use JUnit's 5 TempDir annotation in camel-stax
     new 229dfd18be3 CAMEL-18575: use JUnit's 5 TempDir annotation in camel-saxon
     new f812558136f CAMEL-18575: use JUnit's 5 TempDir annotation in camel-jaxb
     new 0dc0e99fb14 CAMEL-18575: use JUnit's 5 TempDir annotation camel-endpointdsl
     new bf66cf4302a CAMEL-18575: use JUnit's 5 TempDir annotation in camel-quartz
     new 15031810259 CAMEL-18575: removed unused test methods from CamelTestSupport

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/activemq/JmsJdbcXATest.java    |  9 ++-
 .../support/ActiveMQSpringTestSupport.java         |  7 ---
 .../activemq/support/ActiveMQSupport.java          |  8 ---
 .../activemq/support/ActiveMQTestSupport.java      |  5 --
 .../barcode/BarcodeDataFormatCamelTest.java        | 17 ++++--
 .../dataformat/barcode/BarcodeUnmarshalTest.java   |  7 ++-
 .../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 +++-
 .../ExplicitEncodingAndXMLCharFilteringTest.java   | 10 +++-
 .../camel/example/ExplicitFileEncodingTest.java    | 11 +++-
 .../jetty/HttpStreamCacheFileIssueTest.java        | 12 +++-
 .../jetty/HttpStreamCacheFileResponseTest.java     |  8 ++-
 .../component/jetty/HttpStreamCacheFileTest.java   | 12 +++-
 .../camel/component/jetty/HttpToFileTest.java      |  8 ++-
 .../jetty/file/JettyFileConsumerTest.java          | 19 ++++---
 .../FileConsumerQuartzSchedulerRestartTest.java    | 11 +++-
 .../quartz/FileConsumerQuartzSchedulerTest.java    |  9 ++-
 .../saxon/XPathSplitChoicePerformanceTest.java     | 12 ++--
 .../xquery/XQueryFromFileExceptionTest.java        | 19 ++++---
 .../camel/component/xquery/XQueryFromFileTest.java |  8 ++-
 .../xquery/XQueryLanguageFromFileTest.java         | 11 +++-
 .../component/stax/IssueWithWrongEncodingTest.java | 23 ++++----
 .../xtokenizer/SplitGroupMultiXmlTokenTest.java    |  9 ++-
 .../SplitGroupWrappedMultiXmlTokenTest.java        |  9 ++-
 .../xtokenizer/SpringXMLTokenSplitTest.java        |  6 +-
 .../language/xtokenizer/XMLTokenSplitTest.java     | 13 +++--
 .../XMLTokenizeLanguageStreamingFileTest.java      |  9 ++-
 .../apache/camel/test/junit5/CamelTestSupport.java | 66 ++--------------------
 .../test/spring/junit5/CamelSpringTestSupport.java |  6 +-
 .../endpoint/FileAbsolutePathIssueTest.java        |  9 ++-
 .../services/ActiveMQEmbeddedServiceBuilder.java   |  5 ++
 58 files changed, 404 insertions(+), 244 deletions(-)


[camel] 10/11: CAMEL-18575: use JUnit's 5 TempDir annotation in camel-quartz

Posted by or...@apache.org.
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 bf66cf4302a54ad8139c8d78339ccd508c29de1b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 15:27:31 2022 +0200

    CAMEL-18575: use JUnit's 5 TempDir annotation in camel-quartz
---
 .../pollconsumer/quartz/FileConsumerQuartzSchedulerRestartTest.java     | 2 +-
 .../camel/pollconsumer/quartz/FileConsumerQuartzSchedulerTest.java      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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 5e6f6e99551..cf21c55fbb8 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
@@ -49,7 +49,7 @@ public class FileConsumerQuartzSchedulerRestartTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from(fileUri(
+                from(fileUri(testDirectory,
                         "?scheduler=quartz&scheduler.cron=0/2+*+*+*+*+?&scheduler.triggerGroup=myGroup&scheduler.triggerId=myId"))
                                 .routeId("foo").noAutoStartup()
                                 .to("mock:result");
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 9d745536cec..9c0e26ca9bc 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
@@ -44,7 +44,7 @@ public class FileConsumerQuartzSchedulerTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from(fileUri(testDirectory,"?scheduler=quartz&scheduler.cron=0/2+*+*+*+*+?")).routeId("foo").noAutoStartup()
+                from(fileUri(testDirectory, "?scheduler=quartz&scheduler.cron=0/2+*+*+*+*+?")).routeId("foo").noAutoStartup()
                         .to("mock:result");
             }
         };


[camel] 05/11: CAMEL-18575: use JUnit's 5 TempDir annotation in camel-jetty

Posted by or...@apache.org.
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 79d5c376639a2558fa79640e534e51d1f4bb2d52
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 13:32:55 2022 +0200

    CAMEL-18575: use JUnit's 5 TempDir annotation in camel-jetty
---
 .../component/jetty/HttpStreamCacheFileIssueTest.java | 12 +++++++++---
 .../jetty/HttpStreamCacheFileResponseTest.java        |  8 +++++---
 .../component/jetty/HttpStreamCacheFileTest.java      | 12 +++++++++---
 .../apache/camel/component/jetty/HttpToFileTest.java  |  8 ++++++--
 .../component/jetty/file/JettyFileConsumerTest.java   | 19 ++++++++++++-------
 5 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileIssueTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileIssueTest.java
index 9aec0bd70d2..f1eb3eb0a05 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileIssueTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileIssueTest.java
@@ -16,16 +16,22 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.io.File;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 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.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class HttpStreamCacheFileIssueTest extends BaseJettyTest {
 
+    @TempDir
+    File testDirectory;
+
     private String body = "12345678901234567890123456789012345678901234567890";
 
     @Test
@@ -36,7 +42,7 @@ public class HttpStreamCacheFileIssueTest extends BaseJettyTest {
         assertEquals(body, out);
 
         // the temporary files should have been deleted
-        String[] files = testDirectory().toFile().list();
+        String[] files = testDirectory.list();
         assertEquals(0, files.length, "There should be no files");
 
         assertMockEndpointsSatisfied();
@@ -51,14 +57,14 @@ public class HttpStreamCacheFileIssueTest extends BaseJettyTest {
                 // to write to file
                 context.getStreamCachingStrategy().setSpoolEnabled(true);
                 context.getStreamCachingStrategy().setSpoolThreshold(16);
-                context.getStreamCachingStrategy().setSpoolDirectory(testDirectory().toFile());
+                context.getStreamCachingStrategy().setSpoolDirectory(testDirectory);
                 context.setStreamCaching(true);
 
                 // use a route so we got an unit of work
                 from("direct:start").to("http://localhost:{{port}}/myserver").process(new Processor() {
                     public void process(Exchange exchange) {
                         // there should be a temp cache file
-                        String[] files = testDirectory().toFile().list();
+                        String[] files = testDirectory.list();
                         assertTrue(files.length > 0, "There should be a temp cache file");
                     }
                 })
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileResponseTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileResponseTest.java
index 192438abb59..2a880d2d8d0 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileResponseTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileResponseTest.java
@@ -23,11 +23,14 @@ import java.time.Duration;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class HttpStreamCacheFileResponseTest extends BaseJettyTest {
+    @TempDir
+    File testDirectory;
 
     private String body = "12345678901234567890123456789012345678901234567890";
     private String body2 = "Bye " + body;
@@ -37,10 +40,9 @@ public class HttpStreamCacheFileResponseTest extends BaseJettyTest {
         String out = template.requestBody("http://localhost:{{port}}/myserver", body, String.class);
         assertEquals(body2, out);
 
-        File dir = testDirectory().toFile();
         await()
                 .atMost(Duration.ofSeconds(1))
-                .untilAsserted(() -> assertEquals(0, dir.list().length, "There should be no files"));
+                .untilAsserted(() -> assertEquals(0, testDirectory.list().length, "There should be no files"));
     }
 
     @Override
@@ -51,7 +53,7 @@ public class HttpStreamCacheFileResponseTest extends BaseJettyTest {
                 // enable stream caching and use a low threshold so its forced
                 // to write to file
                 context.getStreamCachingStrategy().setSpoolEnabled(true);
-                context.getStreamCachingStrategy().setSpoolDirectory(testDirectory().toFile());
+                context.getStreamCachingStrategy().setSpoolDirectory(testDirectory);
                 context.getStreamCachingStrategy().setSpoolThreshold(16);
                 context.setStreamCaching(true);
 
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java
index 9f28fe8c32d..fd372373fdf 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.io.File;
+
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -23,6 +25,7 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.http.base.HttpOperationFailedException;
 import org.apache.camel.util.ObjectHelper;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -30,6 +33,9 @@ import static org.junit.jupiter.api.Assertions.fail;
 
 public class HttpStreamCacheFileTest extends BaseJettyTest {
 
+    @TempDir
+    File testDirectory;
+
     private final String responseBody = "12345678901234567890123456789012345678901234567890";
 
     @Test
@@ -38,7 +44,7 @@ public class HttpStreamCacheFileTest extends BaseJettyTest {
         assertEquals("Bye World", out);
 
         // the temporary files should have been deleted
-        String[] files = testDirectory().toFile().list();
+        String[] files = testDirectory.list();
         assertEquals(0, files.length, "There should be no files");
     }
 
@@ -54,7 +60,7 @@ public class HttpStreamCacheFileTest extends BaseJettyTest {
         }
 
         // the temporary files should have been deleted
-        String[] files = testDirectory().toFile().list();
+        String[] files = testDirectory.list();
         assertEquals(0, files.length, "There should be no files");
     }
 
@@ -67,7 +73,7 @@ public class HttpStreamCacheFileTest extends BaseJettyTest {
                 // to write to file
                 context.getStreamCachingStrategy().setSpoolEnabled(true);
                 context.getStreamCachingStrategy().setSpoolThreshold(16);
-                context.getStreamCachingStrategy().setSpoolDirectory(testDirectory().toFile());
+                context.getStreamCachingStrategy().setSpoolDirectory(testDirectory);
                 context.setStreamCaching(true);
 
                 // use a route so we got an unit of work
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpToFileTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpToFileTest.java
index 9359b3bd8da..8780452cf81 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpToFileTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpToFileTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.nio.file.Path;
 import java.time.Duration;
 
 import org.apache.camel.Exchange;
@@ -23,6 +24,7 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.awaitility.Awaitility;
 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.junit.jupiter.api.Assertions.assertEquals;
@@ -31,6 +33,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
  * Unit testing demonstrating how to store incoming requests as files and serving a response back.
  */
 public class HttpToFileTest extends BaseJettyTest {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testToJettyAndSaveToFile() throws Exception {
@@ -47,7 +51,7 @@ public class HttpToFileTest extends BaseJettyTest {
         // give file some time to save
         Awaitility.await()
                 .atMost(Duration.ofSeconds(1))
-                .untilAsserted(() -> assertFileExists(testFile("hello.txt"), "Hello World"));
+                .untilAsserted(() -> assertFileExists(testDirectory.resolve("hello.txt"), "Hello World"));
     }
 
     @Override
@@ -61,7 +65,7 @@ public class HttpToFileTest extends BaseJettyTest {
 
                 // store the content from the queue as a file
                 from("seda:in").setHeader(Exchange.FILE_NAME, constant("hello.txt")).convertBodyTo(String.class)
-                        .to(fileUri()).to("mock:result");
+                        .to(fileUri(testDirectory)).to("mock:result");
             }
         };
     }
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/file/JettyFileConsumerTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/file/JettyFileConsumerTest.java
index d8a9346acde..6d170046766 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/file/JettyFileConsumerTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/file/JettyFileConsumerTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.jetty.file;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.nio.file.Path;
 import java.time.Duration;
 
 import org.apache.camel.Exchange;
@@ -26,17 +27,20 @@ import org.apache.camel.component.jetty.BaseJettyTest;
 import org.awaitility.Awaitility;
 import org.junit.jupiter.api.Disabled;
 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;
 
 public class JettyFileConsumerTest extends BaseJettyTest {
+    @TempDir
+    Path testDirectory;
 
     private void testingSendingFile(File src) throws Exception {
         FileInputStream fis = new FileInputStream(src);
         String response = template.requestBody("http://localhost:{{port}}/myapp/myservice", fis, String.class);
         assertEquals("OK", response, "Response should be OK ");
-        File des = testFile("test/temp.xml").toFile();
+        File des = testDirectory.resolve("test/temp.xml").toFile();
         assertTrue(des.exists(), "The uploaded file should exists");
         assertEquals(src.length(), des.length(), "This two file should have same size");
     }
@@ -59,7 +63,7 @@ public class JettyFileConsumerTest extends BaseJettyTest {
         File jpg = new File("src/test/resources/java.jpg");
         String response = template.requestBody("http://localhost:{{port}}/myapp/myservice2", jpg, String.class);
         assertEquals("OK", response, "Response should be OK ");
-        File des = testFile("test/java.jpg").toFile();
+        File des = testDirectory.resolve("test/java.jpg").toFile();
         assertTrue(des.exists(), "The uploaded file should exists");
         assertEquals(jpg.length(), des.length(), "This two file should have same size");
     }
@@ -69,11 +73,11 @@ public class JettyFileConsumerTest extends BaseJettyTest {
         getMockEndpoint("mock:result").expectedMessageCount(1);
 
         File jpg = new File("src/test/resources/java.jpg");
-        template.sendBodyAndHeader(fileUri("binary"), jpg, Exchange.FILE_NAME, "java.jpg");
+        template.sendBodyAndHeader(fileUri(testDirectory, "binary"), jpg, Exchange.FILE_NAME, "java.jpg");
 
         assertMockEndpointsSatisfied();
 
-        File des = testFile("test/java.jpg").toFile();
+        File des = testDirectory.resolve("test/java.jpg").toFile();
         Awaitility.await().atMost(Duration.ofSeconds(2))
                 .untilAsserted(() -> assertTrue(des.exists(), "The uploaded file should exists"));
         assertEquals(jpg.length(), des.length(), "This two file should have same size");
@@ -83,13 +87,14 @@ public class JettyFileConsumerTest extends BaseJettyTest {
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("jetty:http://localhost:{{port}}/myapp/myservice").to(fileUri("test?fileName=temp.xml"))
+                from("jetty:http://localhost:{{port}}/myapp/myservice").to(fileUri(testDirectory, "test?fileName=temp.xml"))
                         .setBody(constant("OK"));
 
                 from("jetty:http://localhost:{{port}}/myapp/myservice2").to("log:foo?showAll=true")
-                        .to(fileUri("test?fileName=java.jpg")).setBody(constant("OK"));
+                        .to(fileUri(testDirectory, "test?fileName=java.jpg")).setBody(constant("OK"));
 
-                from(fileUri("binary?noop=true")).to("http://localhost:{{port}}/myapp/myservice2").to("mock:result");
+                from(fileUri(testDirectory, "binary?noop=true")).to("http://localhost:{{port}}/myapp/myservice2")
+                        .to("mock:result");
             }
         };
     }


[camel] 08/11: CAMEL-18575: use JUnit's 5 TempDir annotation in camel-jaxb

Posted by or...@apache.org.
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 f812558136f1e255756cee79d0628130f05403dd
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 14:55:34 2022 +0200

    CAMEL-18575: use JUnit's 5 TempDir annotation in camel-jaxb
---
 .../example/ExplicitEncodingAndXMLCharFilteringTest.java      | 10 +++++++---
 .../org/apache/camel/example/ExplicitFileEncodingTest.java    | 11 ++++++++---
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/example/ExplicitEncodingAndXMLCharFilteringTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/example/ExplicitEncodingAndXMLCharFilteringTest.java
index 4c0115f177e..a5f7487372e 100644
--- a/components/camel-jaxb/src/test/java/org/apache/camel/example/ExplicitEncodingAndXMLCharFilteringTest.java
+++ b/components/camel-jaxb/src/test/java/org/apache/camel/example/ExplicitEncodingAndXMLCharFilteringTest.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
@@ -30,10 +31,13 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class ExplicitEncodingAndXMLCharFilteringTest extends CamelTestSupport {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testIsoAndCharacterFiltering() throws Exception {
@@ -46,14 +50,14 @@ public class ExplicitEncodingAndXMLCharFilteringTest extends CamelTestSupport {
         order.setPrice(2.22);
 
         MockEndpoint result = getMockEndpoint("mock:file");
-        result.expectedFileExists(testFile("output.xml"));
+        result.expectedFileExists(testDirectory.resolve("output.xml"));
 
         template.sendBody("direct:start", order);
         assertMockEndpointsSatisfied();
 
         JAXBContext jaxbContext = JAXBContext.newInstance("org.apache.camel.example");
         Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-        InputStream inputStream = new FileInputStream(testFile("output.xml").toFile());
+        InputStream inputStream = new FileInputStream(testDirectory.resolve("output.xml").toFile());
         Reader reader = new InputStreamReader(inputStream, StandardCharsets.ISO_8859_1);
         PurchaseOrder obj = (PurchaseOrder) unmarshaller.unmarshal(reader);
         assertEquals(expected, obj.getName());
@@ -70,7 +74,7 @@ public class ExplicitEncodingAndXMLCharFilteringTest extends CamelTestSupport {
 
                 from("direct:start")
                         .marshal(jaxb)
-                        .to(fileUri("?fileName=output.xml&charset=iso-8859-1"));
+                        .to(fileUri(testDirectory, "?fileName=output.xml&charset=iso-8859-1"));
             }
         };
     }
diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/example/ExplicitFileEncodingTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/example/ExplicitFileEncodingTest.java
index ba55d201c42..b39b89db75e 100644
--- a/components/camel-jaxb/src/test/java/org/apache/camel/example/ExplicitFileEncodingTest.java
+++ b/components/camel-jaxb/src/test/java/org/apache/camel/example/ExplicitFileEncodingTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.example;
 
+import java.nio.file.Path;
+
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
 
@@ -24,10 +26,13 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class ExplicitFileEncodingTest extends CamelTestSupport {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testISOFileEncoding() throws Exception {
@@ -39,14 +44,14 @@ public class ExplicitFileEncodingTest extends CamelTestSupport {
         order.setPrice(2.22);
 
         MockEndpoint result = getMockEndpoint("mock:file");
-        result.expectedFileExists(testFile("output.txt"));
+        result.expectedFileExists(testDirectory.resolve("output.txt"));
 
         template.sendBody("direct:start", order);
         assertMockEndpointsSatisfied();
 
         JAXBContext jaxbContext = JAXBContext.newInstance("org.apache.camel.example");
         Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-        PurchaseOrder obj = (PurchaseOrder) unmarshaller.unmarshal(testFile("output.txt").toFile());
+        PurchaseOrder obj = (PurchaseOrder) unmarshaller.unmarshal(testDirectory.resolve("output.txt").toFile());
         assertEquals(obj.getName(), name);
     }
 
@@ -60,7 +65,7 @@ public class ExplicitFileEncodingTest extends CamelTestSupport {
 
                 from("direct:start")
                         .marshal(jaxb)
-                        .to(fileUri("?fileName=output.txt&charset=iso-8859-1"));
+                        .to(fileUri(testDirectory, "?fileName=output.txt&charset=iso-8859-1"));
             }
         };
     }


[camel] 04/11: CAMEL-18575: use JUnit's 5 TempDir annotation in camel-ftp

Posted by or...@apache.org.
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 <an...@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");
             }
         };


[camel] 06/11: CAMEL-18575: use JUnit's 5 TempDir annotation in camel-stax

Posted by or...@apache.org.
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 b691215b6ddc9611a7674f3d58faf6be4eb8753b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 13:41:26 2022 +0200

    CAMEL-18575: use JUnit's 5 TempDir annotation in camel-stax
---
 .../component/stax/IssueWithWrongEncodingTest.java | 23 +++++++++++-----------
 .../xtokenizer/SplitGroupMultiXmlTokenTest.java    |  9 +++++++--
 .../SplitGroupWrappedMultiXmlTokenTest.java        |  9 +++++++--
 .../xtokenizer/SpringXMLTokenSplitTest.java        |  6 +++++-
 .../language/xtokenizer/XMLTokenSplitTest.java     | 13 ++++++++----
 .../XMLTokenizeLanguageStreamingFileTest.java      |  9 +++++++--
 6 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/components/camel-stax/src/test/java/org/apache/camel/component/stax/IssueWithWrongEncodingTest.java b/components/camel-stax/src/test/java/org/apache/camel/component/stax/IssueWithWrongEncodingTest.java
index 732b4468dbc..a03388b07c5 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/component/stax/IssueWithWrongEncodingTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/component/stax/IssueWithWrongEncodingTest.java
@@ -19,17 +19,17 @@ package org.apache.camel.component.stax;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.stax.model.Product;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import static org.apache.camel.component.stax.StAXBuilder.stax;
-import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
 
 public class IssueWithWrongEncodingTest extends CamelTestSupport {
 
@@ -44,19 +44,18 @@ public class IssueWithWrongEncodingTest extends CamelTestSupport {
                                         + "    </product>\n"
                                         + "</products>";
 
-    @Override
-    @BeforeEach
-    public void setUp() throws Exception {
-        deleteDirectory("target/encoding");
-        super.setUp();
-    }
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testOkEncoding() throws Exception {
+        resetMocks();
         getMockEndpoint("mock:result").expectedMessageCount(1);
 
         File file = new File("src/test/resources/products_with_valid_utf8.xml");
-        template.sendBodyAndHeader("file:target/encoding", file, Exchange.FILE_NAME, "products_with_valid_utf8.xml");
+
+        template.sendBodyAndHeader("file:" + testDirectory.toString(), file, Exchange.FILE_NAME,
+                "products_with_valid_utf8.xml");
 
         assertMockEndpointsSatisfied();
     }
@@ -64,9 +63,9 @@ public class IssueWithWrongEncodingTest extends CamelTestSupport {
     @Test
     public void testInvalidEncoding() throws Exception {
         getMockEndpoint("mock:result").expectedMessageCount(0);
-        getMockEndpoint("mock:result").expectedFileExists("target/encoding/error/invalid.xml");
+        getMockEndpoint("mock:result").expectedFileExists(testDirectory.resolve("error/invalid.xml"));
 
-        File file = new File("target/encoding/invalid.xml");
+        File file = testDirectory.resolve("invalid.xml").toFile();
         FileOutputStream fos = new FileOutputStream(file, false);
         fos.write(XML_1.getBytes(StandardCharsets.UTF_8));
         // thai elephant is 4 bytes
@@ -86,7 +85,7 @@ public class IssueWithWrongEncodingTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("file:target/encoding?moveFailed=error")
+                fromF("file:%s?moveFailed=error", testDirectory.toString())
                         .split(stax(Product.class))
                         .to("mock:result");
             }
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SplitGroupMultiXmlTokenTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SplitGroupMultiXmlTokenTest.java
index f0f838405d4..bdd86d93ae3 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SplitGroupMultiXmlTokenTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SplitGroupMultiXmlTokenTest.java
@@ -16,14 +16,19 @@
  */
 package org.apache.camel.language.xtokenizer;
 
+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.apache.camel.support.builder.Namespaces;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class SplitGroupMultiXmlTokenTest extends CamelTestSupport {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testTokenXMLPairGroup() throws Exception {
@@ -38,7 +43,7 @@ public class SplitGroupMultiXmlTokenTest extends CamelTestSupport {
         mock.message(2).body().isEqualTo("<group><order id=\"5\" xmlns=\"http:acme.com\">Groovy in Action</order></group>");
 
         String body = createBody();
-        template.sendBodyAndHeader(fileUri(), body, Exchange.FILE_NAME, "orders.xml");
+        template.sendBodyAndHeader(fileUri(testDirectory), body, Exchange.FILE_NAME, "orders.xml");
 
         assertMockEndpointsSatisfied();
     }
@@ -63,7 +68,7 @@ public class SplitGroupMultiXmlTokenTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 // START SNIPPET: e1
-                from(fileUri("?initialDelay=0&delay=10"))
+                from(fileUri(testDirectory, "?initialDelay=0&delay=10"))
                         // split the order child tags, and inherit namespaces from
                         // the orders root tag
                         .split().xtokenize("//order", 'i', ns, 2).to("log:split").to("mock:split");
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SplitGroupWrappedMultiXmlTokenTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SplitGroupWrappedMultiXmlTokenTest.java
index 88c15b61736..eb15c93f7da 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SplitGroupWrappedMultiXmlTokenTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SplitGroupWrappedMultiXmlTokenTest.java
@@ -16,14 +16,19 @@
  */
 package org.apache.camel.language.xtokenizer;
 
+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.apache.camel.support.builder.Namespaces;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class SplitGroupWrappedMultiXmlTokenTest extends CamelTestSupport {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testTokenXMLPairGroup() throws Exception {
@@ -39,7 +44,7 @@ public class SplitGroupWrappedMultiXmlTokenTest extends CamelTestSupport {
                 "<?xml version=\"1.0\"?>\n<orders xmlns=\"http:acme.com\">\n  <order id=\"5\">Groovy in Action</order></orders>");
 
         String body = createBody();
-        template.sendBodyAndHeader(fileUri(), body, Exchange.FILE_NAME, "orders.xml");
+        template.sendBodyAndHeader(fileUri(testDirectory), body, Exchange.FILE_NAME, "orders.xml");
 
         assertMockEndpointsSatisfied();
     }
@@ -64,7 +69,7 @@ public class SplitGroupWrappedMultiXmlTokenTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 // START SNIPPET: e1
-                from(fileUri("?initialDelay=0&delay=10"))
+                from(fileUri(testDirectory, "?initialDelay=0&delay=10"))
                         // split the order child tags, and inherit namespaces from
                         // the orders root tag
                         .split().xtokenize("//order", 'w', ns, 2).to("log:split").to("mock:split");
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SpringXMLTokenSplitTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SpringXMLTokenSplitTest.java
index db39383d1e0..4b575f1c364 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SpringXMLTokenSplitTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/SpringXMLTokenSplitTest.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.language.xtokenizer;
 
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
@@ -24,6 +27,7 @@ import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class SpringXMLTokenSplitTest extends CamelSpringTestSupport {
+    Path testDirectory = Paths.get("target", "data", SpringXMLTokenSplitTest.class.getSimpleName());
 
     @Test
     public void testXMLToken() throws Exception {
@@ -34,7 +38,7 @@ public class SpringXMLTokenSplitTest extends CamelSpringTestSupport {
         mock.message(2).body().isEqualTo("<order id=\"3\" xmlns=\"http:acme.com\">DSL in Action</order>");
 
         String body = createBody();
-        template.sendBodyAndHeader(fileUri("xtokenizer"), body, Exchange.FILE_NAME, "orders.xml");
+        template.sendBodyAndHeader(fileUri(testDirectory, "xtokenizer"), body, Exchange.FILE_NAME, "orders.xml");
 
         assertMockEndpointsSatisfied();
     }
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenSplitTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenSplitTest.java
index 13a306a0b22..4e47a4a6382 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenSplitTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenSplitTest.java
@@ -16,14 +16,19 @@
  */
 package org.apache.camel.language.xtokenizer;
 
+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.apache.camel.support.builder.Namespaces;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class XMLTokenSplitTest extends CamelTestSupport {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testXMLToken() throws Exception {
@@ -34,7 +39,7 @@ public class XMLTokenSplitTest extends CamelTestSupport {
         mock.message(2).body().isEqualTo("<order id=\"3\" xmlns=\"http:acme.com\">DSL in Action</order>");
 
         String body = createBody();
-        template.sendBodyAndHeader(fileUri("xtokenizer"), body, Exchange.FILE_NAME, "orders.xml");
+        template.sendBodyAndHeader(fileUri(testDirectory, "xtokenizer"), body, Exchange.FILE_NAME, "orders.xml");
 
         assertMockEndpointsSatisfied();
     }
@@ -48,7 +53,7 @@ public class XMLTokenSplitTest extends CamelTestSupport {
         mock.message(2).body().isEqualTo("<order id=\"3\" xmlns=\"http:acme.com\">DSL in Action</order>");
 
         String body = createBody();
-        template.sendBodyAndHeader(fileUri("xtokenizer2"), body, Exchange.FILE_NAME, "orders.xml");
+        template.sendBodyAndHeader(fileUri(testDirectory, "xtokenizer2"), body, Exchange.FILE_NAME, "orders.xml");
 
         assertMockEndpointsSatisfied();
     }
@@ -72,13 +77,13 @@ public class XMLTokenSplitTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 // START SNIPPET: e1
-                from(fileUri("xtokenizer?initialDelay=0&delay=10"))
+                from(fileUri(testDirectory, "xtokenizer?initialDelay=0&delay=10"))
                         // split the order child tags, and inherit namespaces from
                         // the orders root tag
                         .split().xtokenize("//orders/order", ns).to("mock:split");
                 // END SNIPPET: e1
 
-                from(fileUri("xtokenizer2?initialDelay=0&delay=10"))
+                from(fileUri(testDirectory, "xtokenizer2?initialDelay=0&delay=10"))
                         // split the order child tags, and inherit namespaces from
                         // the orders root tag
                         .split(body().xtokenize("//orders/order", ns)).to("mock:split");
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageStreamingFileTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageStreamingFileTest.java
index 5eca0d279f5..c4efba3b035 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageStreamingFileTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageStreamingFileTest.java
@@ -16,13 +16,18 @@
  */
 package org.apache.camel.language.xtokenizer;
 
+import java.nio.file.Path;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.support.builder.Namespaces;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class XMLTokenizeLanguageStreamingFileTest extends CamelTestSupport {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testFromFile() throws Exception {
@@ -38,7 +43,7 @@ public class XMLTokenizeLanguageStreamingFileTest extends CamelTestSupport {
                   + "<c:child some_attr='b' anotherAttr='b'></c:child>" + "<c:child some_attr='c' anotherAttr='c'></c:child>"
                   + "<c:child some_attr='d' anotherAttr='d'></c:child>" + "</c:parent>";
 
-        template.sendBodyAndHeader(fileUri(), body, Exchange.FILE_NAME, "myxml.xml");
+        template.sendBodyAndHeader(fileUri(testDirectory), body, Exchange.FILE_NAME, "myxml.xml");
 
         assertMockEndpointsSatisfied();
     }
@@ -49,7 +54,7 @@ public class XMLTokenizeLanguageStreamingFileTest extends CamelTestSupport {
             Namespaces ns = new Namespaces("C", "urn:c");
 
             public void configure() {
-                from(fileUri("?initialDelay=0&delay=10")).split().xtokenize("//C:child", ns).streaming()
+                from(fileUri(testDirectory, "?initialDelay=0&delay=10")).split().xtokenize("//C:child", ns).streaming()
                         .to("mock:result").end();
             }
         };


[camel] 09/11: CAMEL-18575: use JUnit's 5 TempDir annotation camel-endpointdsl

Posted by or...@apache.org.
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 0dc0e99fb14186ff43fafd1700ee7dee5e7f35ca
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 15:03:08 2022 +0200

    CAMEL-18575: use JUnit's 5 TempDir annotation camel-endpointdsl
---
 .../apache/camel/builder/endpoint/FileAbsolutePathIssueTest.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FileAbsolutePathIssueTest.java b/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FileAbsolutePathIssueTest.java
index 02fcf1486c3..f721938a303 100644
--- a/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FileAbsolutePathIssueTest.java
+++ b/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FileAbsolutePathIssueTest.java
@@ -16,15 +16,20 @@
  */
 package org.apache.camel.builder.endpoint;
 
+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.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class FileAbsolutePathIssueTest extends BaseEndpointDslTest {
+    @TempDir
+    static Path testDirectory;
 
-    private String start = testDirectory("issue").toAbsolutePath().toString();
-    private String done = testDirectory("done").toAbsolutePath().toString();
+    private String start = testDirectory.resolve("issue").toAbsolutePath().toString();
+    private String done = testDirectory.resolve("done").toAbsolutePath().toString();
 
     @Test
     public void testMoveAbsolute() throws Exception {


[camel] 11/11: CAMEL-18575: removed unused test methods from CamelTestSupport

Posted by or...@apache.org.
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 150318102592bee4807c6542e5b308f2fce9075f
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 12:14:23 2022 +0200

    CAMEL-18575: removed unused test methods from CamelTestSupport
    
    Also marked outdated methods as deprecated in camel-test-junit5
---
 .../apache/camel/test/junit5/CamelTestSupport.java | 66 ++--------------------
 .../test/spring/junit5/CamelSpringTestSupport.java |  6 +-
 2 files changed, 11 insertions(+), 61 deletions(-)

diff --git a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
index e97c321a4c4..3e2af694bfb 100644
--- a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
+++ b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
@@ -16,11 +16,8 @@
  */
 package org.apache.camel.test.junit5;
 
-import java.io.IOException;
 import java.lang.annotation.Annotation;
-import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -83,7 +80,6 @@ import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
 import static org.apache.camel.test.junit5.TestSupport.isCamelDebugPresent;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
@@ -126,7 +122,6 @@ public abstract class CamelTestSupport
     private boolean isCreateCamelContextPerClass = false;
     private CamelRouteCoverageDumper routeCoverageDumper = new CamelRouteCoverageDumper();
     private ExtensionContext.Store globalStore;
-    private boolean testDirectoryCleaned;
     // CHECKSTYLE:ON
 
     @Override
@@ -600,7 +595,6 @@ public abstract class CamelTestSupport
             doPostTearDown();
             cleanupResources();
         }
-        testDirectoryCleaned = false;
     }
 
     void tearDownCreateCamelContextPerClass() throws Exception {
@@ -623,7 +617,6 @@ public abstract class CamelTestSupport
      * Strategy to perform resources setup, before {@link CamelContext} is created
      */
     protected void setupResources() throws Exception {
-        deleteTestDirectory();
     }
 
     /**
@@ -1074,60 +1067,13 @@ public abstract class CamelTestSupport
         }
     }
 
-    protected Path testDirectory() {
-        return testDirectory(false);
+    @Deprecated
+    protected static String fileUri(Path testDirectory) {
+        return "file:" + testDirectory;
     }
 
-    protected Path testDirectory(boolean create) {
-        Class<?> testClass = getClass();
-        return testDirectory(testClass, create);
+    @Deprecated
+    protected static String fileUri(Path testDirectory, String query) {
+        return "file:" + testDirectory + (query.startsWith("?") ? "" : "/") + query;
     }
-
-    public static Path testDirectory(Class<?> testClass, boolean create) {
-        Path dir = Paths.get("target", "data", testClass.getSimpleName());
-        if (create) {
-            try {
-                Files.createDirectories(dir);
-            } catch (IOException e) {
-                throw new IllegalStateException("Unable to create test directory: " + dir, e);
-            }
-        }
-        return dir;
-    }
-
-    protected Path testFile(String dir) {
-        return testDirectory().resolve(dir);
-    }
-
-    protected Path testDirectory(String dir) {
-        return testDirectory(dir, false);
-    }
-
-    protected Path testDirectory(String dir, boolean create) {
-        Path f = testDirectory().resolve(dir);
-        if (create) {
-            try {
-                Files.createDirectories(f);
-            } catch (IOException e) {
-                throw new IllegalStateException("Unable to create test directory: " + dir, e);
-            }
-        }
-        return f;
-    }
-
-    protected String fileUri() {
-        return "file:" + testDirectory();
-    }
-
-    protected String fileUri(String query) {
-        return "file:" + testDirectory() + (query.startsWith("?") ? "" : "/") + query;
-    }
-
-    public void deleteTestDirectory() {
-        if (!testDirectoryCleaned) {
-            deleteDirectory(testDirectory());
-            testDirectoryCleaned = true;
-        }
-    }
-
 }
diff --git a/components/camel-test/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestSupport.java b/components/camel-test/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestSupport.java
index cc70caeee4a..25e56f26d59 100644
--- a/components/camel-test/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestSupport.java
+++ b/components/camel-test/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestSupport.java
@@ -22,6 +22,8 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -256,7 +258,9 @@ public abstract class CamelSpringTestSupport extends CamelTestSupport {
         Map<String, String> props = new HashMap<>();
         props.put(TEST_CLASS_NAME_PROPERTY, testClass.getName());
         props.put(TEST_CLASS_SIMPLE_NAME_PROPERTY, testClass.getSimpleName());
-        props.put(TEST_DIRECTORY_PROPERTY, testDirectory(testClass, false).toString());
+
+        Path testDir = Paths.get("target", "data", testClass.getSimpleName());
+        props.put(TEST_DIRECTORY_PROPERTY, testDir.toString());
         return props;
     }
 


[camel] 01/11: CAMEL-18575: allow creating data directories from Path instances in camel-test-infra-activemq

Posted by or...@apache.org.
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 911dae99f7fa53bf027801c29c0894db98970d40
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 11:40:35 2022 +0200

    CAMEL-18575: allow creating data directories from Path instances in camel-test-infra-activemq
---
 .../test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java
index 21159fb143f..695f92bf581 100644
--- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java
+++ b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java
@@ -20,6 +20,7 @@ package org.apache.camel.test.infra.activemq.services;
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
+import java.nio.file.Path;
 import java.util.List;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.LongAdder;
@@ -97,6 +98,10 @@ public final class ActiveMQEmbeddedServiceBuilder {
         return this;
     }
 
+    public ActiveMQEmbeddedServiceBuilder withDataDirectory(Path dataDirectory) {
+        return withDataDirectory(dataDirectory.toAbsolutePath().toString());
+    }
+
     public ActiveMQEmbeddedServiceBuilder withDataDirectory(String dataDirectory) {
         brokerService.setDataDirectory(dataDirectory);
 


[camel] 07/11: CAMEL-18575: use JUnit's 5 TempDir annotation in camel-saxon

Posted by or...@apache.org.
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 229dfd18be393a1ad7850c7de14504ec4db77266
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 13:48:20 2022 +0200

    CAMEL-18575: use JUnit's 5 TempDir annotation in camel-saxon
---
 .../saxon/XPathSplitChoicePerformanceTest.java        | 12 +++++++-----
 .../component/xquery/XQueryFromFileExceptionTest.java | 19 ++++++++++++-------
 .../camel/component/xquery/XQueryFromFileTest.java    |  8 ++++++--
 .../component/xquery/XQueryLanguageFromFileTest.java  | 11 ++++++++---
 4 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XPathSplitChoicePerformanceTest.java b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XPathSplitChoicePerformanceTest.java
index 1278392c848..c2ff91d2848 100644
--- a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XPathSplitChoicePerformanceTest.java
+++ b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XPathSplitChoicePerformanceTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.builder.saxon;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.nio.file.Path;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -31,6 +32,7 @@ import org.apache.camel.util.TimeUtils;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,9 +43,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
  *
  */
 public class XPathSplitChoicePerformanceTest extends CamelTestSupport {
-
     private static final Logger LOG = LoggerFactory.getLogger(XPathSplitChoicePerformanceTest.class);
 
+    @TempDir
+    Path testDirectory;
+
     private int size = 20 * 1000;
     private final AtomicInteger tiny = new AtomicInteger();
     private final AtomicInteger small = new AtomicInteger();
@@ -84,7 +88,7 @@ public class XPathSplitChoicePerformanceTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from(fileUri("?noop=true"))
+                from(fileUri(testDirectory, "?noop=true"))
                         .process(new Processor() {
                             public void process(Exchange exchange) {
                                 log.info("Starting to process file");
@@ -152,11 +156,9 @@ public class XPathSplitChoicePerformanceTest extends CamelTestSupport {
     }
 
     public void createDataFile(Logger log, int size) throws Exception {
-        deleteTestDirectory();
-
         log.info("Creating data file ...");
 
-        File file = testDirectory(true).resolve("data.xml").toFile();
+        File file = testDirectory.resolve("data.xml").toFile();
         FileOutputStream fos = new FileOutputStream(file, true);
         fos.write("<orders>\n".getBytes());
 
diff --git a/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryFromFileExceptionTest.java b/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryFromFileExceptionTest.java
index bede4897b42..cece05369c7 100644
--- a/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryFromFileExceptionTest.java
+++ b/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryFromFileExceptionTest.java
@@ -16,10 +16,13 @@
  */
 package org.apache.camel.component.xquery;
 
+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;
 
 import static org.apache.camel.test.junit5.TestSupport.assertFileExists;
 import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists;
@@ -28,6 +31,8 @@ import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists;
  *
  */
 public class XQueryFromFileExceptionTest extends CamelTestSupport {
+    @TempDir
+    static Path testDirectory;
 
     @Test
     public void testXQueryFromFileExceptionOk() throws Exception {
@@ -36,14 +41,14 @@ public class XQueryFromFileExceptionTest extends CamelTestSupport {
 
         String body = "<person user='James'><firstName>James</firstName>"
                       + "<lastName>Strachan</lastName><city>London</city></person>";
-        template.sendBodyAndHeader(fileUri(), body, Exchange.FILE_NAME, "hello.xml");
+        template.sendBodyAndHeader(fileUri(testDirectory), body, Exchange.FILE_NAME, "hello.xml");
 
         assertMockEndpointsSatisfied();
 
         Thread.sleep(500);
 
-        assertFileNotExists(testFile("hello.xml"));
-        assertFileExists(testFile("ok/hello.xml"));
+        assertFileNotExists(testDirectory.resolve("hello.xml"));
+        assertFileExists(testDirectory.resolve("ok/hello.xml"));
     }
 
     @Test
@@ -54,14 +59,14 @@ public class XQueryFromFileExceptionTest extends CamelTestSupport {
         // the last tag is not ended properly
         String body = "<person user='James'><firstName>James</firstName>"
                       + "<lastName>Strachan</lastName><city>London</city></person";
-        template.sendBodyAndHeader(fileUri(), body, Exchange.FILE_NAME, "hello2.xml");
+        template.sendBodyAndHeader(fileUri(testDirectory), body, Exchange.FILE_NAME, "hello2.xml");
 
         assertMockEndpointsSatisfied();
 
         Thread.sleep(500);
 
-        assertFileNotExists(testFile("hello2.xml"));
-        assertFileExists(testFile("error/hello2.xml"));
+        assertFileNotExists(testDirectory.resolve("hello2.xml"));
+        assertFileExists(testDirectory.resolve("error/hello2.xml"));
     }
 
     @Override
@@ -69,7 +74,7 @@ public class XQueryFromFileExceptionTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from(fileUri("?moveFailed=error&move=ok"))
+                fromF("file:%s?moveFailed=error&move=ok", testDirectory.toString())
                         .onException(Exception.class)
                         .to("mock:error")
                         .end()
diff --git a/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryFromFileTest.java b/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryFromFileTest.java
index c1dfe46bf1b..96c60e260d0 100644
--- a/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryFromFileTest.java
+++ b/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryFromFileTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.xquery;
 
+import java.nio.file.Path;
 import java.util.List;
 
 import org.apache.camel.Exchange;
@@ -23,6 +24,7 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
 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.assertNotNull;
@@ -31,13 +33,15 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
  *
  */
 public class XQueryFromFileTest extends CamelTestSupport {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testXQueryFromFile() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
-        template.sendBodyAndHeader(fileUri(), "<mail><subject>Hey</subject><body>Hello world!</body></mail>",
+        template.sendBodyAndHeader(fileUri(testDirectory), "<mail><subject>Hey</subject><body>Hello world!</body></mail>",
                 Exchange.FILE_NAME, "body.xml");
 
         assertMockEndpointsSatisfied();
@@ -56,7 +60,7 @@ public class XQueryFromFileTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from(fileUri())
+                from(fileUri(testDirectory))
                         .to("xquery:org/apache/camel/component/xquery/transform.xquery")
                         .to("mock:result");
             }
diff --git a/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryLanguageFromFileTest.java b/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryLanguageFromFileTest.java
index 3eeca3c58c6..c997bd12fdf 100644
--- a/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryLanguageFromFileTest.java
+++ b/components/camel-saxon/src/test/java/org/apache/camel/component/xquery/XQueryLanguageFromFileTest.java
@@ -16,16 +16,21 @@
  */
 package org.apache.camel.component.xquery;
 
+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.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 /**
  *
  */
 public class XQueryLanguageFromFileTest extends CamelTestSupport {
+    @TempDir
+    Path testDirectory;
 
     @Test
     public void testXQueryFromFile() throws Exception {
@@ -37,11 +42,11 @@ public class XQueryLanguageFromFileTest extends CamelTestSupport {
         other.expectedMessageCount(1);
         other.message(0).body(String.class).contains("Bye World");
 
-        template.sendBodyAndHeader(fileUri(),
+        template.sendBodyAndHeader(fileUri(testDirectory),
                 "<mail from=\"davsclaus@apache.org\"><subject>Hey</subject><body>Hello World!</body></mail>",
                 Exchange.FILE_NAME, "claus.xml");
 
-        template.sendBodyAndHeader(fileUri(),
+        template.sendBodyAndHeader(fileUri(testDirectory),
                 "<mail from=\"janstey@apache.org\"><subject>Hey</subject><body>Bye World!</body></mail>",
                 Exchange.FILE_NAME, "janstey.xml");
 
@@ -53,7 +58,7 @@ public class XQueryLanguageFromFileTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from(fileUri())
+                from(fileUri(testDirectory))
                         .choice()
                         .when().xquery("/mail/@from = 'davsclaus@apache.org'")
                         .convertBodyTo(String.class)


[camel] 02/11: CAMEL-18575: use JUnit's 5 TempDir annotation camel-activemq

Posted by or...@apache.org.
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 990559c66f7fee74ed9c5162ac487f0ecb97018a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 11:41:22 2022 +0200

    CAMEL-18575: use JUnit's 5 TempDir annotation camel-activemq
    
    Also removed unused temp directory methods
---
 .../java/org/apache/camel/component/activemq/JmsJdbcXATest.java  | 9 +++++++--
 .../component/activemq/support/ActiveMQSpringTestSupport.java    | 7 -------
 .../apache/camel/component/activemq/support/ActiveMQSupport.java | 8 --------
 .../camel/component/activemq/support/ActiveMQTestSupport.java    | 5 -----
 4 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/JmsJdbcXATest.java b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/JmsJdbcXATest.java
index 3bb22c92314..fa93ff51082 100644
--- a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/JmsJdbcXATest.java
+++ b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/JmsJdbcXATest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.activemq;
 
+import java.nio.file.Path;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Map;
@@ -40,6 +41,7 @@ import org.apache.camel.component.activemq.support.ActiveMQSpringTestSupport;
 import org.apache.camel.test.infra.activemq.services.ActiveMQEmbeddedService;
 import org.apache.camel.test.infra.activemq.services.ActiveMQEmbeddedServiceBuilder;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.support.AbstractXmlApplicationContext;
@@ -56,6 +58,9 @@ public class JmsJdbcXATest extends ActiveMQSpringTestSupport {
     BrokerService broker;
     int messageCount;
 
+    @TempDir
+    Path dataDirectory;
+
     public java.sql.Connection initDb() throws Exception {
         String createStatement = "CREATE TABLE SCP_INPUT_MESSAGES (" + "id int NOT NULL GENERATED ALWAYS AS IDENTITY, "
                                  + "messageId varchar(96) NOT NULL, " + "messageCorrelationId varchar(96) NOT NULL, "
@@ -110,7 +115,7 @@ public class JmsJdbcXATest extends ActiveMQSpringTestSupport {
                 .defaultBroker()
                 .withDeleteAllMessagesOnStartup(false)
                 .withBrokerName(JmsJdbcXATest.class)
-                .withDataDirectory(testDirectory().toString())
+                .withDataDirectory(dataDirectory)
                 .build()
                 .getBrokerService();
 
@@ -181,7 +186,7 @@ public class JmsJdbcXATest extends ActiveMQSpringTestSupport {
                     .defaultBroker()
                     .withBrokerName(JmsJdbcXATest.class)
                     .withTcpTransport()
-                    .withDataDirectory(testDirectory().toString())
+                    .withDataDirectory(dataDirectory)
                     .build()
                     .getBrokerService();
 
diff --git a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQSpringTestSupport.java b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQSpringTestSupport.java
index 823fae8938b..4b16d4ad02c 100644
--- a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQSpringTestSupport.java
+++ b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQSpringTestSupport.java
@@ -16,9 +16,6 @@
  */
 package org.apache.camel.component.activemq.support;
 
-import java.nio.file.Path;
-
-import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
@@ -29,10 +26,6 @@ public abstract class ActiveMQSpringTestSupport extends CamelSpringTestSupport i
         return newAppContext(getClass().getSimpleName() + "-context.xml");
     }
 
-    public Path testDirectory() {
-        return CamelTestSupport.testDirectory(getClass(), false);
-    }
-
     protected int getShutdownTimeout() {
         return 1;
     }
diff --git a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQSupport.java b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQSupport.java
index f2471d456fd..efb2f23a1c5 100644
--- a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQSupport.java
+++ b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQSupport.java
@@ -16,10 +16,6 @@
  */
 package org.apache.camel.component.activemq.support;
 
-import java.nio.file.Path;
-
-import org.apache.camel.test.junit5.CamelTestSupport;
-
 public interface ActiveMQSupport {
 
     default String vmUri() {
@@ -29,8 +25,4 @@ public interface ActiveMQSupport {
     default String vmUri(String query) {
         return "vm://" + getClass().getSimpleName() + (query.startsWith("?") ? "" : "-") + query;
     }
-
-    default Path testDirectory() {
-        return CamelTestSupport.testDirectory(getClass(), false);
-    }
 }
diff --git a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQTestSupport.java b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQTestSupport.java
index 35c03135e0b..be3bac740e1 100644
--- a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQTestSupport.java
+++ b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/support/ActiveMQTestSupport.java
@@ -16,13 +16,8 @@
  */
 package org.apache.camel.component.activemq.support;
 
-import java.nio.file.Path;
-
 import org.apache.camel.test.junit5.CamelTestSupport;
 
 public class ActiveMQTestSupport extends CamelTestSupport implements ActiveMQSupport {
 
-    public Path testDirectory() {
-        return CamelTestSupport.testDirectory(getClass(), false);
-    }
 }


[camel] 03/11: CAMEL-18575: use JUnit's 5 TempDir annotation camel-barcode

Posted by or...@apache.org.
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 9acb1e0bacb5dfabaf53504c432950c2065f011b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 3 12:13:41 2022 +0200

    CAMEL-18575: use JUnit's 5 TempDir annotation camel-barcode
---
 .../dataformat/barcode/BarcodeDataFormatCamelTest.java  | 17 +++++++++++------
 .../camel/dataformat/barcode/BarcodeUnmarshalTest.java  |  7 ++++++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
index ac89bdbd6e1..20dddceabae 100644
--- a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
@@ -16,18 +16,23 @@
  */
 package org.apache.camel.dataformat.barcode;
 
+import java.nio.file.Path;
 import java.util.concurrent.TimeUnit;
 
 import com.google.zxing.BarcodeFormat;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spi.DataFormat;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 /**
  * This class tests all Camel dependend cases for {@link BarcodeDataFormat}.
  */
 public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
 
+    @TempDir
+    Path testDirectory;
+
     /**
      * tests barcode (QR-Code) generation and reading.
      * 
@@ -125,40 +130,40 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
 
                 from("direct:code1")
                         .marshal(code1)
-                        .to(fileUri());
+                        .to(fileUri(testDirectory));
 
                 // QR-Code with modified size
                 DataFormat code2 = new BarcodeDataFormat(200, 200);
 
                 from("direct:code2")
                         .marshal(code2)
-                        .to(fileUri());
+                        .to(fileUri(testDirectory));
 
                 // QR-Code with JPEG type
                 DataFormat code3 = new BarcodeDataFormat(BarcodeImageType.JPG);
 
                 from("direct:code3")
                         .marshal(code3)
-                        .to(fileUri());
+                        .to(fileUri(testDirectory));
 
                 // PDF-417 code with modified size and image type
                 DataFormat code4 = new BarcodeDataFormat(200, 200, BarcodeImageType.JPG, BarcodeFormat.PDF_417);
 
                 from("direct:code4")
                         .marshal(code4)
-                        .to(fileUri());
+                        .to(fileUri(testDirectory));
 
                 // AZTEC with modified size and PNG type
                 DataFormat code5 = new BarcodeDataFormat(200, 200, BarcodeImageType.PNG, BarcodeFormat.AZTEC);
 
                 from("direct:code5")
                         .marshal(code5)
-                        .to(fileUri());
+                        .to(fileUri(testDirectory));
 
                 // generic file read --->
                 // 
                 // read file and route it
-                from(fileUri("?noop=true&initialDelay=0&delay=10"))
+                from(fileUri(testDirectory, "?noop=true&initialDelay=0&delay=10"))
                         .multicast().to("direct:unmarshall", "mock:image");
 
                 // get the message from code
diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeUnmarshalTest.java b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeUnmarshalTest.java
index fec6d63c5c1..7f347072848 100644
--- a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeUnmarshalTest.java
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeUnmarshalTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.dataformat.barcode;
 
 import java.io.*;
+import java.nio.file.Path;
 
 import javax.imageio.ImageIO;
 
@@ -31,11 +32,15 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spi.DataFormat;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class BarcodeUnmarshalTest extends BarcodeTestBase {
 
+    @TempDir
+    Path testDirectory;
+
     @Test
     void testOrientation() {
 
@@ -68,7 +73,7 @@ public class BarcodeUnmarshalTest extends BarcodeTestBase {
                                         new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(bis))));
                                 BitMatrix blackMatrix = bitmap.getBlackMatrix();
                                 blackMatrix.rotate180();
-                                File file = testDirectory(true).resolve("TestImage.png").toFile();
+                                File file = testDirectory.resolve("TestImage.png").toFile();
                                 FileOutputStream outputStream = new FileOutputStream(file);
                                 MatrixToImageWriter.writeToStream(blackMatrix, "png", outputStream);
                                 exchange.getIn().setBody(file);