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

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f82e7b77c HDDS-10073. Remove unused code from GenericTestUtils and 
LambdaTestUtils (#7849)
6f82e7b77c is described below

commit 6f82e7b77c6463d3f9d2c9c967dc988b6e208066
Author: Peter Lee <[email protected]>
AuthorDate: Tue Feb 11 03:08:42 2025 +0800

    HDDS-10073. Remove unused code from GenericTestUtils and LambdaTestUtils 
(#7849)
---
 .../org/apache/ozone/test/GenericTestUtils.java    | 86 ----------------------
 .../org/apache/ozone/test/LambdaTestUtils.java     | 36 ---------
 2 files changed, 122 deletions(-)

diff --git 
a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
 
b/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
index 959326e210..80be26ef67 100644
--- 
a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
+++ 
b/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
@@ -52,8 +52,6 @@
 import java.util.stream.Collectors;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;
-import static org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass;
 
 /**
  * Provides some very generic helpers which might be used across the tests.
@@ -93,51 +91,6 @@ public static Instant getTestStartTime() {
     return Instant.ofEpochMilli(System.currentTimeMillis());
   }
 
-  /**
-   * Get the (created) base directory for tests.
-   *
-   * @return the absolute directory
-   *
-   * @deprecated use {@link org.junit.jupiter.api.io.TempDir} instead.
-   */
-  @Deprecated
-  public static File getTestDir() {
-    String prop =
-        System.getProperty(SYSPROP_TEST_DATA_DIR, DEFAULT_TEST_DATA_DIR);
-    if (prop.isEmpty()) {
-      // corner case: property is there but empty
-      prop = DEFAULT_TEST_DATA_DIR;
-    }
-    File dir = new File(prop).getAbsoluteFile();
-    assertDirCreation(dir);
-    return dir;
-  }
-
-  /**
-   * Get an uncreated directory for tests.
-   *
-   * @return the absolute directory for tests. Caller is expected to create it.
-   *
-   * @deprecated use {@link org.junit.jupiter.api.io.TempDir} instead.
-   */
-  @Deprecated
-  public static File getTestDir(String subdir) {
-    return new File(getTestDir(), subdir).getAbsoluteFile();
-  }
-
-  /**
-   * Get an uncreated directory for tests with a randomized alphanumeric
-   * name. This is likely to provide a unique path for tests run in parallel
-   *
-   * @return the absolute directory for tests. Caller is expected to create it.
-   *
-   * @deprecated use {@link org.junit.jupiter.api.io.TempDir} instead.
-   */
-  @Deprecated
-  public static File getRandomizedTestDir() {
-    return new File(getRandomizedTempPath());
-  }
-
   /**
    * Get a temp path. This may or may not be relative; it depends on what the
    * {@link #SYSPROP_TEST_DATA_DIR} is set to. If unset, it returns a path
@@ -163,30 +116,6 @@ public static String getTempPath(String subpath) {
     return prop + subpath;
   }
 
-  /**
-   * Get a temp path. This may or may not be relative; it depends on what the
-   * {@link #SYSPROP_TEST_DATA_DIR} is set to. If unset, it returns a path
-   * under the relative path {@link #DEFAULT_TEST_DATA_PATH}
-   *
-   * @return a string to use in paths
-   *
-   * @deprecated use {@link org.junit.jupiter.api.io.TempDir} instead.
-   */
-  @SuppressWarnings("java:S2245") // no need for secure random
-  @Deprecated
-  public static String getRandomizedTempPath() {
-    return getTempPath(getCallerClass(GenericTestUtils.class).getSimpleName()
-        + "-" + randomAlphanumeric(10));
-  }
-
-  /**
-   * Assert that a given dir can be created or it already exists.
-   */
-  public static void assertDirCreation(File f) {
-    Assertions.assertTrue(f.mkdirs() || f.exists(),
-        "Could not create dir " + f + ", nor does it exist");
-  }
-
   /**
    * Wait for the specified test to return true. The test will be performed
    * initially and then every {@code checkEveryMillis} until at least
@@ -296,21 +225,6 @@ public static <K, V> Map<V, K> getReverseMap(Map<K, 
List<V>> map) {
             .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
   }
 
-  /***
-   * Removed all files and dirs in the given dir recursively.
-   */
-  public static boolean deleteDirectory(File dir) {
-    File[] allContents = dir.listFiles();
-    if (allContents != null) {
-      for (File content : allContents) {
-        if (!deleteDirectory(content)) {
-          return false;
-        }
-      }
-    }
-    return dir.delete();
-  }
-
   /**
    * Class to capture logs for doing assertions.
    */
diff --git 
a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/LambdaTestUtils.java
 
b/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/LambdaTestUtils.java
index d6b028c815..927cd31acb 100644
--- 
a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/LambdaTestUtils.java
+++ 
b/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/LambdaTestUtils.java
@@ -226,42 +226,6 @@ private static String robustToString(Object o) {
     }
   }
 
-  /**
-   * Invoke a callable; wrap all checked exceptions with an
-   * AssertionError.
-   * @param closure closure to execute
-   * @param <T> return type of closure
-   * @return the value of the closure
-   * @throws AssertionError if the operation raised an IOE or
-   * other checked exception.
-   */
-  public static <T> T eval(Callable<T> closure) {
-    try {
-      return closure.call();
-    } catch (RuntimeException e) {
-      throw e;
-    } catch (Exception e) {
-      throw new AssertionError(e.toString(), e);
-    }
-  }
-
-  /**
-   * Invoke a callable; wrap all checked exceptions with an
-   * AssertionError.
-   * @param closure closure to execute
-   * @throws AssertionError if the operation raised an IOE or
-   * other checked exception.
-   */
-  public static void eval(VoidCallable closure) {
-    try {
-      closure.call();
-    } catch (RuntimeException e) {
-      throw e;
-    } catch (Exception e) {
-      throw new AssertionError(e.toString(), e);
-    }
-  }
-
   /**
    * Returns {@code TimeoutException} on a timeout. If
    * there was a inner class passed in, includes it as the


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to