diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-05-24 08:03:38 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-05-24 08:03:38 +0200 |
| commit | 04f1bf0386776de8ca6e3eb95c2d6bfde5401ed2 (patch) | |
| tree | 40008e89acd5d2739e9561e228b018b907be1a73 /tests/src/cgeo/geocaching/test | |
| parent | f6ed7c0e2cee57503de2c2582dd29536e6cfdf0a (diff) | |
| download | cgeo-04f1bf0386776de8ca6e3eb95c2d6bfde5401ed2.zip cgeo-04f1bf0386776de8ca6e3eb95c2d6bfde5401ed2.tar.gz cgeo-04f1bf0386776de8ca6e3eb95c2d6bfde5401ed2.tar.bz2 | |
fix #2764: remove temporary caches after test
Diffstat (limited to 'tests/src/cgeo/geocaching/test')
| -rw-r--r-- | tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java index cd8b5e7..304f98d 100644 --- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java +++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java @@ -1,6 +1,9 @@ package cgeo.geocaching.test; +import cgeo.geocaching.SearchResult; +import cgeo.geocaching.StoredList; import cgeo.geocaching.cgData; +import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag; @@ -15,6 +18,8 @@ import java.util.EnumSet; import java.util.Scanner; public abstract class AbstractResourceInstrumentationTestCase extends InstrumentationTestCase { + private int temporaryListId; + protected static void removeCacheCompletely(final String geocode) { final EnumSet<RemoveFlag> flags = EnumSet.copyOf(LoadFlags.REMOVE_ALL); flags.add(RemoveFlag.REMOVE_OWN_WAYPOINTS_ONLY_FOR_TESTING); @@ -52,4 +57,25 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument is.close(); } } + + @Override + protected void setUp() throws Exception { + super.setUp(); + temporaryListId = cgData.createList("Temporary unit testing"); + assertTrue(temporaryListId != StoredList.TEMPORARY_LIST_ID); + assertTrue(temporaryListId != StoredList.STANDARD_LIST_ID); + } + + @Override + protected void tearDown() throws Exception { + final SearchResult search = cgData.getBatchOfStoredCaches(null, CacheType.ALL, temporaryListId); + assertNotNull(search); + cgData.removeCaches(search.getGeocodes(), LoadFlags.REMOVE_ALL); + cgData.removeList(temporaryListId); + super.tearDown(); + } + + protected final int getTemporaryListId() { + return temporaryListId; + } } |
