From c05fb9699b70ec7d9800bf1e7264235dcf621294 Mon Sep 17 00:00:00 2001
From: Bananeweizen
Date: Sat, 2 Mar 2013 11:08:57 +0100
Subject: refactoring: use same package in test as in production
---
.../cgeo/geocaching/connector/oc/OCXMLTest.java | 83 ++++++++++++++++++++++
.../geocaching/connector/oc/OkapiClientTest.java | 26 +++++++
.../connector/opencaching/OCXMLTest.java | 83 ----------------------
.../connector/opencaching/OkapiClientTest.java | 26 -------
4 files changed, 109 insertions(+), 109 deletions(-)
create mode 100644 tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
create mode 100644 tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
delete mode 100644 tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java
delete mode 100644 tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java
(limited to 'tests')
diff --git a/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
new file mode 100644
index 0000000..a1992bd
--- /dev/null
+++ b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
@@ -0,0 +1,83 @@
+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;
+
+public class OCXMLTest extends CGeoTestCase {
+
+ public static void testOCGetCache() {
+ final String geoCode = "OCDE76";
+
+ final Geocache cache = OCXMLClient.getCache(geoCode);
+ assertNotNull(cache);
+ assertEquals(geoCode, cache.getGeocode());
+ assertEquals("Gitarrenspielplatz", cache.getName());
+ assertEquals(CacheType.TRADITIONAL, cache.getType());
+ assertEquals(2.0, cache.getDifficulty(), 0.1);
+ assertEquals(2.0, cache.getTerrain(), 0.1);
+ }
+
+ public static void testOCLogAttendedAsFound() {
+
+ final String oldOCName = Settings.getOCConnectorUserName();
+ try {
+ Settings.setOCConnectorUserName("ra_sch");
+ final String geoCode = "OCD541";
+ final Geocache cache = OCXMLClient.getCache(geoCode);
+ assertNotNull(cache);
+
+ assertTrue(cache.isFound());
+ } finally {
+ Settings.setOCConnectorUserName(oldOCName);
+ }
+ }
+
+ public static void testOCOwner() {
+ final String oldOCName = Settings.getOCConnectorUserName();
+ try {
+ Settings.setOCConnectorUserName("andi12.2");
+ final String geoCode = "OCC9BE";
+ final Geocache cache = OCXMLClient.getCache(geoCode);
+ assertNotNull(cache);
+
+ assertTrue(cache.isOwner());
+ assertEquals("180571", cache.getOwnerUserId());
+ } finally {
+ Settings.setOCConnectorUserName(oldOCName);
+ }
+ }
+
+ public static void testOC0537Description() {
+ final String geoCode = "OC0537";
+ final Geocache cache = OCXMLClient.getCache(geoCode);
+ assertNotNull(cache);
+
+ assertFalse(cache.getDescription().length() < 100);
+ }
+
+ public static void testNoArchivedInNearby() {
+
+ final boolean oldExcludeDisabled = Settings.isExcludeDisabledCaches();
+ final boolean oldExcludeMine = Settings.isExcludeMyCaches();
+ try {
+ Settings.setExcludeDisabledCaches(false);
+ Settings.setExcludeMine(false);
+ // get an archived cache
+ final Geocache cache = OCXMLClient.getCache("OCD541");
+ assertNotNull(cache);
+ assertTrue(cache.isArchived());
+ // Get nearby for this cache
+ final Collection caches = OCXMLClient.getCachesAround(cache.getCoords(), 0.5);
+ // Should not be in the result!
+ assertFalse(caches.contains(cache));
+ } finally {
+ Settings.setExcludeDisabledCaches(oldExcludeDisabled);
+ Settings.setExcludeMine(oldExcludeMine);
+ }
+ }
+}
diff --git a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
new file mode 100644
index 0000000..690cd4c
--- /dev/null
+++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
@@ -0,0 +1,26 @@
+package cgeo.geocaching.connector.oc;
+
+import cgeo.CGeoTestCase;
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.cgData;
+import cgeo.geocaching.connector.oc.OkapiClient;
+import cgeo.geocaching.enumerations.LoadFlags;
+
+public class OkapiClientTest extends CGeoTestCase {
+
+ public static void testGetOCCache() {
+ final String geoCode = "OU0331";
+ Geocache cache = OkapiClient.getCache(geoCode);
+ assertNotNull(cache);
+ assertEquals(geoCode, cache.getGeocode());
+ assertEquals("Oshkosh Municipal Tank", cache.getName());
+ assertTrue(cache.isDetailed());
+ // cache should be stored to DB (to listID 0) when loaded above
+ cache = cgData.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
+ assertNotNull(cache);
+ assertEquals(geoCode, cache.getGeocode());
+ assertEquals("Oshkosh Municipal Tank", cache.getName());
+ assertTrue(cache.isDetailed());
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java
deleted file mode 100644
index ca2e302..0000000
--- a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package cgeo.geocaching.connector.opencaching;
-
-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;
-
-public class OCXMLTest extends CGeoTestCase {
-
- public static void testOCGetCache() {
- final String geoCode = "OCDE76";
-
- final Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
- assertEquals(geoCode, cache.getGeocode());
- assertEquals("Gitarrenspielplatz", cache.getName());
- assertEquals(CacheType.TRADITIONAL, cache.getType());
- assertEquals(2.0, cache.getDifficulty(), 0.1);
- assertEquals(2.0, cache.getTerrain(), 0.1);
- }
-
- public static void testOCLogAttendedAsFound() {
-
- final String oldOCName = Settings.getOCConnectorUserName();
- try {
- Settings.setOCConnectorUserName("ra_sch");
- final String geoCode = "OCD541";
- final Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
-
- assertTrue(cache.isFound());
- } finally {
- Settings.setOCConnectorUserName(oldOCName);
- }
- }
-
- public static void testOCOwner() {
- final String oldOCName = Settings.getOCConnectorUserName();
- try {
- Settings.setOCConnectorUserName("andi12.2");
- final String geoCode = "OCC9BE";
- final Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
-
- assertTrue(cache.isOwner());
- assertEquals("180571", cache.getOwnerUserId());
- } finally {
- Settings.setOCConnectorUserName(oldOCName);
- }
- }
-
- public static void testOC0537Description() {
- final String geoCode = "OC0537";
- final Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
-
- assertFalse(cache.getDescription().length() < 100);
- }
-
- public static void testNoArchivedInNearby() {
-
- final boolean oldExcludeDisabled = Settings.isExcludeDisabledCaches();
- final boolean oldExcludeMine = Settings.isExcludeMyCaches();
- try {
- Settings.setExcludeDisabledCaches(false);
- Settings.setExcludeMine(false);
- // get an archived cache
- final Geocache cache = OCXMLClient.getCache("OCD541");
- assertNotNull(cache);
- assertTrue(cache.isArchived());
- // Get nearby for this cache
- final Collection caches = OCXMLClient.getCachesAround(cache.getCoords(), 0.5);
- // Should not be in the result!
- assertFalse(caches.contains(cache));
- } finally {
- Settings.setExcludeDisabledCaches(oldExcludeDisabled);
- Settings.setExcludeMine(oldExcludeMine);
- }
- }
-}
diff --git a/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java
deleted file mode 100644
index 9173c6a..0000000
--- a/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package cgeo.geocaching.connector.opencaching;
-
-import cgeo.CGeoTestCase;
-import cgeo.geocaching.Geocache;
-import cgeo.geocaching.cgData;
-import cgeo.geocaching.connector.oc.OkapiClient;
-import cgeo.geocaching.enumerations.LoadFlags;
-
-public class OkapiClientTest extends CGeoTestCase {
-
- public static void testGetOCCache() {
- final String geoCode = "OU0331";
- Geocache cache = OkapiClient.getCache(geoCode);
- assertNotNull(cache);
- assertEquals(geoCode, cache.getGeocode());
- assertEquals("Oshkosh Municipal Tank", cache.getName());
- assertTrue(cache.isDetailed());
- // cache should be stored to DB (to listID 0) when loaded above
- cache = cgData.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
- assertNotNull(cache);
- assertEquals(geoCode, cache.getGeocode());
- assertEquals("Oshkosh Municipal Tank", cache.getName());
- assertTrue(cache.isDetailed());
- }
-
-}
--
cgit v1.1
From 40765f11f49f15dd9a0a040b631228b45c7211a5 Mon Sep 17 00:00:00 2001
From: Bananeweizen
Date: Sat, 2 Mar 2013 12:13:56 +0100
Subject: fix #2534: Updating a OC.de cache doubles the cache description
---
tests/src/cgeo/CGeoTestCase.java | 7 +++++++
tests/src/cgeo/geocaching/cgeoApplicationTest.java | 5 -----
.../cgeo/geocaching/connector/oc/OCXMLTest.java | 22 +++++++++++++++++++++-
3 files changed, 28 insertions(+), 6 deletions(-)
(limited to 'tests')
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
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 = "Bei dem Cache kannst du einen kleinen Schatz bergen. Bitte lege aber einen ander Schatz in das Döschen. Achtung vor Automuggels.
";
+
+ 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);
+ }
+ }
}
--
cgit v1.1
From 710d3b5e41ad920519902f828f5a6ccc0a1c3c34 Mon Sep 17 00:00:00 2001
From: Bananeweizen
Date: Sat, 2 Mar 2013 13:05:12 +0100
Subject: new: strip unneeded markup from OC descriptions
---
.../cgeo/geocaching/connector/oc/OCXMLTest.java | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
(limited to 'tests')
diff --git a/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
index 46c3fd1..b12823a 100644
--- a/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
+++ b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
@@ -82,7 +82,7 @@ public class OCXMLTest extends CGeoTestCase {
public static void testFetchTwiceDuplicatesDescription() {
final String geoCode = "OCEFBA";
- final String description = "Bei dem Cache kannst du einen kleinen Schatz bergen. Bitte lege aber einen ander Schatz in das Döschen. Achtung vor Automuggels.
";
+ final String description = "Bei dem Cache kannst du einen kleinen Schatz bergen. Bitte lege aber einen ander Schatz in das Döschen. Achtung vor Automuggels.";
deleteCacheFromDB(geoCode);
Geocache cache = OCXMLClient.getCache(geoCode);
@@ -100,4 +100,24 @@ public class OCXMLTest extends CGeoTestCase {
deleteCacheFromDB(geoCode);
}
}
+
+ public static void testRemoveMarkupCache() {
+ final String geoCode = "OCEFBA";
+ final String description = "Bei dem Cache kannst du einen kleinen Schatz bergen. Bitte lege aber einen ander Schatz in das Döschen. Achtung vor Automuggels.";
+
+ Geocache cache = OCXMLClient.getCache(geoCode);
+ assertNotNull(cache);
+ assertEquals(description, cache.getDescription());
+ }
+
+ public static void testRemoveMarkup() {
+ assertEquals("", OC11XMLParser.stripMarkup(""));
+ assertEquals("Test", OC11XMLParser.stripMarkup("Test"));
+ assertEquals("bold and others not removed", OC11XMLParser.stripMarkup("bold and others not removed"));
+ assertEquals("unnecessary paragraph", OC11XMLParser.stripMarkup("unnecessary paragraph
"));
+ assertEquals("unnecessary span", OC11XMLParser.stripMarkup("unnecessary span"));
+ assertEquals("nested", OC11XMLParser.stripMarkup("nested"));
+ assertEquals("mixed", OC11XMLParser.stripMarkup(" mixed
"));
+ assertEquals("not
removable
", OC11XMLParser.stripMarkup("not
removable
"));
+ }
}
--
cgit v1.1
From f3fb143bd25eb546228936913fcef87eecd2a3ea Mon Sep 17 00:00:00 2001
From: SammysHP
Date: Fri, 8 Mar 2013 11:12:31 +0100
Subject: Apply patch to mocked data
This is NO full update, but only to fix one test.
---
tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html | 7 ++-----
tests/src/cgeo/geocaching/test/mock/GC2CJPF.html | 7 ++-----
tests/src/cgeo/geocaching/test/mock/GC2JVEH.html | 7 ++-----
tests/src/cgeo/geocaching/test/mock/GC3XX5J.html | 7 ++-----
4 files changed, 8 insertions(+), 20 deletions(-)
(limited to 'tests')
diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html
index 33364ef..69eb0a1 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html
+++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html
@@ -1050,11 +1050,8 @@ Man weiß hier Bescheid. Dieser Cache ist rund um die Uhr zu finden, ohne ein Ge
-
- ...other caches
- hidden
- or
- found
- by this user
+
+ ...other caches hidden or found by this user
-
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html
index b06215d..bfa932f 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html
+++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html
@@ -1394,11 +1394,8 @@ P.S. An warmen Tagen Badesachen und Handtuch mitnehmen.
-
- ...other caches
- hidden
- or
- found
- by this user
+
+ ...other caches hidden or found by this user
-
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.html b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.html
index 9e1a44f..8b974b5 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.html
+++ b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.html
@@ -1062,11 +1062,8 @@ Sys.WebForms.PageRequestManager._initialize('ctl00$uxMainScriptManager', 'aspnet
-
- ...other caches
- hidden
- or
- found
- by this user
+
+ ...other caches hidden or found by this user
-
diff --git a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html
index c4740f0..30bb9ac 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html
+++ b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html
@@ -943,11 +943,8 @@ PRINESI SVOJE PISALO / BRING YOUR OWN PEN
-
- ...other caches
- hidden
- or
- found
- by this user
+
+ ...other caches hidden or found by this user
-
--
cgit v1.1