diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/files')
| -rw-r--r-- | tests/src/cgeo/geocaching/files/GPXImporterTest.java | 23 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/files/GPXParserTest.java | 4 |
2 files changed, 8 insertions, 19 deletions
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java index ee42d23..6d7456c 100644 --- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java +++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java @@ -12,6 +12,7 @@ import cgeo.geocaching.test.R; import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.Log; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import android.net.Uri; @@ -50,8 +51,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { // the "real" method check assertEquals(wptsFileName, GPXImporter.getWaypointsFileNameForGpxFile(gpx)); // they also need to be deleted, because of case sensitive tests that will not work correct on case insensitive file systems - gpx.delete(); - wpts.delete(); + FileUtils.deleteQuietly(gpx); + FileUtils.deleteQuietly(wpts); } final File gpx1 = new File(tempDir, "abc.gpx"); assertNull(GPXImporter.getWaypointsFileNameForGpxFile(gpx1)); @@ -260,7 +261,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { msg1.copyFrom(msg); messages.add(msg1); lastMessage = System.currentTimeMillis(); - notify(); + notifyAll(); } public synchronized void waitForCompletion(final long milliseconds, final int maxMessages) { @@ -287,7 +288,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { assertTrue("java.io.tmpdir is not defined", StringUtils.isNotBlank(globalTempDir)); tempDir = new File(globalTempDir, "cgeogpxesTest"); - tempDir.mkdir(); + cgeo.geocaching.utils.FileUtils.mkdirs(tempDir); assertTrue("Could not create directory " + tempDir.getPath(), tempDir.exists()); // workaround to get storage initialized DataStore.getAllHistoryCachesCount(); @@ -306,21 +307,9 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { cachesInList.addAll(search.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB)); DataStore.markDropped(cachesInList); DataStore.removeList(listId); - deleteDirectory(tempDir); + FileUtils.deleteDirectory(tempDir); TestSettings.setStoreOfflineMaps(importCacheStaticMaps); TestSettings.setStoreOfflineWpMaps(importWpStaticMaps); super.tearDown(); } - - private static void deleteDirectory(File dir) { - for (File f : dir.listFiles()) { - if (f.isFile()) { - f.delete(); - } else if (f.isDirectory()) { - deleteDirectory(f); - } - } - dir.delete(); - } - } diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java index 9604519..dcaad22 100644 --- a/tests/src/cgeo/geocaching/files/GPXParserTest.java +++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java @@ -12,13 +12,13 @@ import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; import cgeo.geocaching.test.R; +import cgeo.geocaching.utils.SynchronizedDateFormat; import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; @@ -28,7 +28,7 @@ import java.util.Locale; import java.util.Set; public class GPXParserTest extends AbstractResourceInstrumentationTestCase { - private static final SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); // 2010-04-20T07:00:00Z + private static final SynchronizedDateFormat LOG_DATE_FORMAT = new SynchronizedDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); // 2010-04-20T07:00:00Z public void testGPXVersion100() throws Exception { testGPXVersion(R.raw.gc1bkp3_gpx100); |
