aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/cgeo/CGeoTestCase.java7
-rw-r--r--tests/src/cgeo/geocaching/cgeoApplicationTest.java5
-rw-r--r--tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java22
3 files changed, 28 insertions, 6 deletions
diff --git a/tests/src/cgeo/CGeoTestCase.java b/tests/src/cgeo/CGeoTestCase.java
index 31fde34..6a63cbc 100644
--- a/tests/src/cgeo/CGeoTestCase.java
+++ b/tests/src/cgeo/CGeoTestCase.java
@@ -1,6 +1,8 @@
package cgeo;
+import cgeo.geocaching.cgData;
import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.enumerations.LoadFlags;
import android.test.ApplicationTestCase;
@@ -16,4 +18,9 @@ public abstract class CGeoTestCase extends ApplicationTestCase<cgeoapplication>
createApplication();
}
+ /** Remove cache from DB and cache to ensure that the cache is not loaded from the database */
+ protected static void deleteCacheFromDB(String geocode) {
+ cgData.removeCache(geocode, LoadFlags.REMOVE_ALL);
+ }
+
}
diff --git a/tests/src/cgeo/geocaching/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
index c1b01e7..9c882a5 100644
--- a/tests/src/cgeo/geocaching/cgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
@@ -406,11 +406,6 @@ public class cgeoApplicationTest extends CGeoTestCase {
}
/** Remove cache from DB and cache to ensure that the cache is not loaded from the database */
- private static void deleteCacheFromDB(String geocode) {
- cgData.removeCache(geocode, LoadFlags.REMOVE_ALL);
- }
-
- /** Remove cache from DB and cache to ensure that the cache is not loaded from the database */
private static void deleteCacheFromDBAndLogout(String geocode) {
deleteCacheFromDB(geocode);
diff --git a/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
index a1992bd..46c3fd1 100644
--- a/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
+++ b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
@@ -3,7 +3,6 @@ package cgeo.geocaching.connector.oc;
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.Settings;
-import cgeo.geocaching.connector.oc.OCXMLClient;
import cgeo.geocaching.enumerations.CacheType;
import java.util.Collection;
@@ -80,4 +79,25 @@ public class OCXMLTest extends CGeoTestCase {
Settings.setExcludeMine(oldExcludeMine);
}
}
+
+ public static void testFetchTwiceDuplicatesDescription() {
+ final String geoCode = "OCEFBA";
+ final String description = "<p><span>Bei dem Cache kannst du einen kleinen Schatz bergen. Bitte lege aber einen ander Schatz in das Döschen. Achtung vor Automuggels.</span></p>";
+
+ deleteCacheFromDB(geoCode);
+ Geocache cache = OCXMLClient.getCache(geoCode);
+ assertNotNull(cache);
+ try {
+ assertEquals(geoCode, cache.getGeocode());
+ assertEquals(description, cache.getDescription());
+ cache.store(null);
+
+ // reload, make sure description is not duplicated
+ cache = OCXMLClient.getCache(geoCode);
+ assertNotNull(cache);
+ assertEquals(description, cache.getDescription());
+ } finally {
+ deleteCacheFromDB(geoCode);
+ }
+ }
}