aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/cgDataTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching/cgDataTest.java')
-rw-r--r--tests/src/cgeo/geocaching/cgDataTest.java37
1 files changed, 33 insertions, 4 deletions
diff --git a/tests/src/cgeo/geocaching/cgDataTest.java b/tests/src/cgeo/geocaching/cgDataTest.java
index e175603..cacf061 100644
--- a/tests/src/cgeo/geocaching/cgDataTest.java
+++ b/tests/src/cgeo/geocaching/cgDataTest.java
@@ -9,6 +9,8 @@ import cgeo.geocaching.enumerations.LoadFlags.SaveFlag;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.Viewport;
+import org.apache.commons.lang3.StringUtils;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
@@ -125,6 +127,35 @@ public class cgDataTest extends CGeoTestCase {
}
}
+ // Check that loading a cache by case insensitive geo code works correctly (see #3139)
+ public static void testGeocodeCaseInsensitive() {
+
+ final String GEOCODE_CACHE = "TEST";
+ final String upperCase = GEOCODE_CACHE;
+ final String lowerCase = StringUtils.lowerCase(upperCase);
+ assertFalse(upperCase.equals(lowerCase));
+
+ // create cache and trackable
+ final Geocache cache = new Geocache();
+ cache.setGeocode(upperCase);
+ cache.setDetailed(true);
+
+ try {
+ final Geocache oldCache = cgData.loadCache(upperCase, LoadFlags.LOAD_ALL_DB_ONLY);
+ assertNull("Database contained old cache!", oldCache);
+
+ cgData.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
+ final Geocache cacheWithOriginalCode = cgData.loadCache(upperCase, LoadFlags.LOAD_ALL_DB_ONLY);
+ assertNotNull("Cache was not saved correctly!", cacheWithOriginalCode);
+
+ final Geocache cacheLowerCase = cgData.loadCache(lowerCase, LoadFlags.LOAD_ALL_DB_ONLY);
+ assertNotNull("Could not find cache by case insensitive geocode", cacheLowerCase);
+
+ } finally {
+ cgData.removeCache(upperCase, LoadFlags.REMOVE_ALL);
+ }
+ }
+
// Loading logs for an empty geocode should return an empty list, not null!
public static void testLoadLogsFromEmptyGeocode() {
@@ -165,8 +196,7 @@ public class cgDataTest extends CGeoTestCase {
main.setCoords(new Geopoint("N49 44.0 E8 37.0"));
final Geocache inTileLowZoom = new Geocache();
inTileLowZoom.setGeocode("GC12346");
- inTileLowZoom.setCoords(new Geopoint("N49 44.001 E8 37.001"));
- inTileLowZoom.setZoomlevel(Tile.ZOOMLEVEL_MIN_PERSONALIZED - 5);
+ inTileLowZoom.setCoords(new Geopoint("N49 44.001 E8 37.001"), Tile.ZOOMLEVEL_MIN_PERSONALIZED - 5);
final Geocache outTile = new Geocache();
outTile.setGeocode("GC12347");
outTile.setCoords(new Geopoint(tile.getViewport().getLatitudeMin() - 0.1, tile.getViewport().getLongitudeMin() - 0.1));
@@ -175,8 +205,7 @@ public class cgDataTest extends CGeoTestCase {
otherConnector.setCoords(new Geopoint("N49 44.0 E8 37.0"));
final Geocache inTileHighZoom = new Geocache();
inTileHighZoom.setGeocode("GC12348");
- inTileHighZoom.setCoords(new Geopoint("N49 44.001 E8 37.001"));
- inTileHighZoom.setZoomlevel(Tile.ZOOMLEVEL_MIN_PERSONALIZED + 1);
+ inTileHighZoom.setCoords(new Geopoint("N49 44.001 E8 37.001"), Tile.ZOOMLEVEL_MIN_PERSONALIZED + 1);
// put in cache
cgData.saveCache(main, EnumSet.of(SaveFlag.SAVE_CACHE));