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:40 UTC

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

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;
     }