aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/src/cgeo/geocaching/utils/FileUtilsTest.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/src/cgeo/geocaching/utils/FileUtilsTest.java b/tests/src/cgeo/geocaching/utils/FileUtilsTest.java
index 0d7fab1..72554fa 100644
--- a/tests/src/cgeo/geocaching/utils/FileUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/FileUtilsTest.java
@@ -14,10 +14,10 @@ import java.io.IOException;
public class FileUtilsTest extends TestCase {
- final File cacheDir = LocalStorage.getStorageDir("automated-tests");
- final File baseFile = new File(cacheDir, "prefix.ext");
- final File alternative1 = new File(cacheDir, "prefix_1.ext");
- final File alternative2 = new File(cacheDir, "prefix_2.ext");
+ final File testDir = LocalStorage.getStorageDir("automated-tests");
+ final File baseFile = new File(testDir, "prefix.ext");
+ final File alternative1 = new File(testDir, "prefix_1.ext");
+ final File alternative2 = new File(testDir, "prefix_2.ext");
private Context getTestContext() {
try {
@@ -29,8 +29,8 @@ public class FileUtilsTest extends TestCase {
}
public void testGetUniqueNamedFile() throws IOException {
- FileUtils.deleteDirectory(cacheDir);
- cacheDir.mkdirs();
+ FileUtils.deleteDirectory(testDir);
+ testDir.mkdirs();
try {
assertThat(FileUtils.getUniqueNamedFile(baseFile)).isEqualTo(baseFile);
baseFile.createNewFile();
@@ -39,7 +39,7 @@ public class FileUtilsTest extends TestCase {
assertThat(FileUtils.getUniqueNamedFile(baseFile)).isEqualTo(alternative2);
assertThat(FileUtils.getUniqueNamedFile(baseFile)).isEqualTo(alternative2);
} finally {
- FileUtils.deleteDirectory(cacheDir);
+ FileUtils.deleteDirectory(testDir);
}
}
@@ -49,4 +49,13 @@ public class FileUtilsTest extends TestCase {
assertThat(FileUtils.fileToUrl(new File("/tmp/foo/bar"))).isEqualTo("file:///tmp/foo/bar");
assertThat(FileUtils.urlToFile("file:///tmp/foo/bar").getPath()).isEqualTo("/tmp/foo/bar");
}
+
+ public void testCreateRemoveDirectories() {
+ FileUtils.deleteDirectory(testDir);
+ assertThat(testDir.exists()).isFalse();
+ FileUtils.mkdirs(testDir);
+ assertThat(testDir.exists()).isTrue();
+ FileUtils.deleteDirectory(testDir);
+ assertThat(testDir.exists()).isFalse();
+ }
}