From 09fbbff695f511df7fa82a244483816d037c4898 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Tue, 29 May 2018 09:11:08 -0700 Subject: [PATCH] HADOOP-15497. TestTrash should use proper test path to avoid failing on Windows. Contributed by Anbang Hu. (cherry picked from commit 3c75f8e4933221fa60a87e86a3db5e4727530b6f) --- .../src/test/java/org/apache/hadoop/fs/TestTrash.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java index 7a5b25e583a..1a6d58028ba 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java @@ -48,9 +48,11 @@ import org.junit.Test; */ public class TestTrash extends TestCase { - private final static Path TEST_DIR = new Path(GenericTestUtils.getTempPath( + private final static File BASE_PATH = new File(GenericTestUtils.getTempPath( "testTrash")); + private final static Path TEST_DIR = new Path(BASE_PATH.getAbsolutePath()); + @Before public void setUp() throws IOException { // ensure each test initiates a FileSystem instance, @@ -680,7 +682,7 @@ public class TestTrash extends TestCase { static class TestLFS extends LocalFileSystem { Path home; TestLFS() { - this(new Path(TEST_DIR, "user/test")); + this(TEST_DIR); } TestLFS(final Path home) { super(new RawLocalFileSystem() { @@ -807,8 +809,8 @@ public class TestTrash extends TestCase { */ public static void verifyTrashPermission(FileSystem fs, Configuration conf) throws IOException { - Path caseRoot = new Path( - GenericTestUtils.getTempPath("testTrashPermission")); + Path caseRoot = new Path(BASE_PATH.getPath(), + "testTrashPermission"); try (FileSystem fileSystem = fs){ Trash trash = new Trash(fileSystem, conf); FileSystemTestWrapper wrapper =