Skip to content

Commit 206dfdb

Browse files
committed
Don't use the Maven "target" directory as a test fixture.
Use a directory that we know always exists for a test fixture.
1 parent a6e417f commit 206dfdb

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/test/java/org/apache/commons/io/FileSystemUtilsTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
@SuppressWarnings("deprecation") // testing deprecated class
3030
class FileSystemUtilsTest {
3131

32+
private static final String NON_EMPTY_DIR = "src/test/resources/dir-equals-tests";
33+
3234
static char[] getIllegalFileNameChars() {
3335
return FileSystem.getCurrent().getIllegalFileNameChars();
3436
}
@@ -50,7 +52,7 @@ void testGetFreeSpace_String() throws Exception {
5052
assertThrows(IllegalArgumentException.class, () -> FileSystemUtils.freeSpace("this directory does not exist, at all."));
5153
// "" means current dir.
5254
assertTrue(FileSystemUtils.freeSpace("") > 0);
53-
assertTrue(FileSystemUtils.freeSpace("target") > 0);
55+
assertTrue(FileSystemUtils.freeSpace(NON_EMPTY_DIR) > 0);
5456
// files worked as well in previous versions.
5557
assertTrue(FileSystemUtils.freeSpace("pom.xml") > 0);
5658
}
@@ -71,7 +73,7 @@ void testGetFreeSpaceKb_String() throws Exception {
7173
assertThrows(IllegalArgumentException.class, () -> FileSystemUtils.freeSpaceKb("this directory does not exist, at all."));
7274
// "" means current dir.
7375
assertTrue(FileSystemUtils.freeSpaceKb("") > 0);
74-
assertTrue(FileSystemUtils.freeSpaceKb("target") > 0);
76+
assertTrue(FileSystemUtils.freeSpaceKb(NON_EMPTY_DIR) > 0);
7577
// files worked as well in previous versions.
7678
assertTrue(FileSystemUtils.freeSpaceKb("pom.xml") > 0);
7779
}
@@ -82,7 +84,7 @@ void testGetFreeSpaceKb_String_long() throws Exception {
8284
assertThrows(IllegalArgumentException.class, () -> FileSystemUtils.freeSpaceKb("this directory does not exist, at all.", 0));
8385
// "" means current dir.
8486
assertTrue(FileSystemUtils.freeSpaceKb("", 0) > 0);
85-
assertTrue(FileSystemUtils.freeSpaceKb("target", 0) > 0);
87+
assertTrue(FileSystemUtils.freeSpaceKb(NON_EMPTY_DIR, 0) > 0);
8688
// files worked as well in previous versions.
8789
assertTrue(FileSystemUtils.freeSpaceKb("pom.xml", 0) > 0);
8890
}

0 commit comments

Comments
 (0)