aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2015-02-11 19:06:09 +0100
committerSamuel Tardieu <sam@rfc1149.net>2015-02-11 19:06:09 +0100
commitd52022cf435e8ba509901d9ad0a573c1f46b89ab (patch)
tree96387c06ff84c19ed076ee5eacde469031a8714d /tests
parenteac13a5843d2e46d62b1c72aee0916aeb3030b3a (diff)
downloadcgeo-d52022cf435e8ba509901d9ad0a573c1f46b89ab.zip
cgeo-d52022cf435e8ba509901d9ad0a573c1f46b89ab.tar.gz
cgeo-d52022cf435e8ba509901d9ad0a573c1f46b89ab.tar.bz2
More FileUtils tests
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();
+ }
}