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 959326e210f7..80be26ef6766 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 Map getReverseMap(Map> 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 d6b028c815f7..927cd31acb16 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 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 eval(Callable 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