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 2023/11/16 13:12:39 UTC

(camel) 05/05: Revert timeout values in FileConsumerFailureHandledTest, revert deleted methods and mark them as deprecated

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 20644e05dad0626bd94c9f25586df2097619ebec
Author: Anton Goncharov <go...@gmail.com>
AuthorDate: Wed Nov 15 21:00:49 2023 +0100

    Revert timeout values in FileConsumerFailureHandledTest, revert deleted methods and mark them as deprecated
---
 .../test/java/org/apache/camel/TestSupport.java    | 56 ++++++++++++++++++++++
 .../file/FileConsumerFailureHandledTest.java       |  6 +--
 2 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/TestSupport.java b/core/camel-core/src/test/java/org/apache/camel/TestSupport.java
index 29604c205f3..986b6fae3a0 100644
--- a/core/camel-core/src/test/java/org/apache/camel/TestSupport.java
+++ b/core/camel-core/src/test/java/org/apache/camel/TestSupport.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.lang.reflect.Method;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
@@ -86,6 +87,10 @@ public abstract class TestSupport {
         Assumptions.assumeTrue(canRunOnThisPlatform());
     }
 
+    @Deprecated
+    public void deleteTestDirectory() {
+    }
+
     @AfterEach
     public void tearDown() throws Exception {
         // make sure we cleanup the platform mbean server
@@ -104,6 +109,24 @@ public abstract class TestSupport {
         return testDirectory(path, false);
     }
 
+    @Deprecated
+    protected Path testDirectory(boolean create) {
+        return testDirectory();
+    }
+
+    @Deprecated
+    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 testDirectory(String path, boolean create) {
         Path resolvedPath = testDirectory().resolve(path);
         if (create) {
@@ -422,6 +445,39 @@ public abstract class TestSupport {
         }
     }
 
+    /**
+     * Recursively delete a directory, useful to zapping test data
+     *
+     * @param      file the directory to be deleted
+     * @deprecated      since updating the class to use junit5 @TempDir, it no longer should control temp directory
+     *                  lifecycle
+     */
+    @Deprecated
+    public static void deleteDirectory(String file) {
+        deleteDirectory(new File(file));
+    }
+
+    /**
+     * Recursively delete a directory, useful to zapping test data
+     *
+     * @param      file the directory to be deleted
+     * @deprecated      since updating the class to use junit5 @TempDir, it no longer should control temp directory
+     *                  lifecycle
+     */
+    @Deprecated
+    public static void deleteDirectory(File file) {
+        if (file.isDirectory()) {
+            File[] files = file.listFiles();
+            if (files != null) {
+                for (File child : files) {
+                    deleteDirectory(child);
+                }
+            }
+        }
+
+        file.delete();
+    }
+
     /**
      * To be used for folder/directory comparison that works across different platforms such as Window, Mac and Linux.
      */
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
index 70d79372256..d8d4cbd3778 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
@@ -57,7 +57,7 @@ public class FileConsumerFailureHandledTest extends ContextTestSupport {
         mock.expectedBodiesReceived("London");
 
         template.sendBodyAndHeader(fileUri(), "London", Exchange.FILE_NAME, "london.txt");
-        mock.assertIsSatisfied(3000);
+        mock.assertIsSatisfied(1000);
 
         oneExchangeDone.matchesWaitTime();
 
@@ -72,7 +72,7 @@ public class FileConsumerFailureHandledTest extends ContextTestSupport {
         mock.expectedBodiesReceived("Dublin");
 
         template.sendBodyAndHeader(fileUri(), "Dublin", Exchange.FILE_NAME, "dublin.txt");
-        mock.assertIsSatisfied(3000);
+        mock.assertIsSatisfied(1000);
 
         oneExchangeDone.matchesWaitTime();
 
@@ -87,7 +87,7 @@ public class FileConsumerFailureHandledTest extends ContextTestSupport {
         mock.expectedBodiesReceived("Madrid");
 
         template.sendBodyAndHeader(fileUri(), "Madrid", Exchange.FILE_NAME, "madrid.txt");
-        mock.assertIsSatisfied(3000);
+        mock.assertIsSatisfied(1000);
 
         oneExchangeDone.matchesWaitTime();