aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/files
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching/files')
-rw-r--r--tests/src/cgeo/geocaching/files/GPXImporterTest.java8
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java23
-rw-r--r--tests/src/cgeo/geocaching/files/LocParserTest.java2
3 files changed, 10 insertions, 23 deletions
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
index 86369a3..c064935 100644
--- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
@@ -11,6 +11,8 @@ import cgeo.geocaching.test.R;
import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.Log;
+import org.apache.commons.lang3.StringUtils;
+
import android.net.Uri;
import android.os.Message;
@@ -257,8 +259,12 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
protected void setUp() throws Exception {
super.setUp();
- tempDir = new File(System.getProperty("java.io.tmpdir"), "cgeogpxesTest");
+ final String globalTempDir = System.getProperty("java.io.tmpdir");
+ assertTrue("java.io.tmpdir is not defined", StringUtils.isNotBlank(globalTempDir));
+
+ tempDir = new File(globalTempDir, "cgeogpxesTest");
tempDir.mkdir();
+ assertTrue("Could not create directory " + tempDir.getPath(), tempDir.exists());
// workaround to get storage initialized
cgData.getAllHistoryCachesCount();
listId = cgData.createList("cgeogpxesTest");
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index f6c0b99..8fd962e 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -2,8 +2,6 @@ package cgeo.geocaching.files;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.LogEntry;
-import cgeo.geocaching.SearchResult;
-import cgeo.geocaching.StoredList;
import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgData;
import cgeo.geocaching.enumerations.CacheSize;
@@ -29,7 +27,6 @@ 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 int listId;
public void testGPXVersion100() throws Exception {
testGPXVersion(R.raw.gc1bkp3_gpx100);
@@ -189,12 +186,12 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
}
private List<Geocache> readGPX10(int... resourceIds) throws IOException, ParserException {
- final GPX10Parser parser = new GPX10Parser(listId);
+ final GPX10Parser parser = new GPX10Parser(getTemporaryListId());
return readVersionedGPX(parser, resourceIds);
}
private List<Geocache> readGPX11(int... resourceIds) throws IOException, ParserException {
- final GPX11Parser parser = new GPX11Parser(listId);
+ final GPX11Parser parser = new GPX11Parser(getTemporaryListId());
return readVersionedGPX(parser, resourceIds);
}
@@ -284,20 +281,4 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
removeCacheCompletely(geocode);
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- listId = cgData.createList("Temporary unit testing");
- assertTrue(listId != StoredList.TEMPORARY_LIST_ID);
- assertTrue(listId != StoredList.STANDARD_LIST_ID);
- }
-
- @Override
- protected void tearDown() throws Exception {
- final SearchResult search = cgData.getBatchOfStoredCaches(null, CacheType.ALL, listId);
- assertNotNull(search);
- cgData.removeCaches(search.getGeocodes(), LoadFlags.REMOVE_ALL);
- cgData.removeList(listId);
- super.tearDown();
- }
}
diff --git a/tests/src/cgeo/geocaching/files/LocParserTest.java b/tests/src/cgeo/geocaching/files/LocParserTest.java
index c95d860..bcc8e78 100644
--- a/tests/src/cgeo/geocaching/files/LocParserTest.java
+++ b/tests/src/cgeo/geocaching/files/LocParserTest.java
@@ -14,7 +14,7 @@ import java.util.List;
public class LocParserTest extends AbstractResourceInstrumentationTestCase {
private List<Geocache> readLoc(int resourceId) throws IOException, ParserException {
- final LocParser parser = new LocParser(1);
+ final LocParser parser = new LocParser(getTemporaryListId());
Collection<Geocache> caches = null;
final InputStream instream = getResourceStream(resourceId);
try {