aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/res/values/changelog_release.xml9
-rw-r--r--main/src/cgeo/geocaching/connector/UnknownConnector.java2
-rw-r--r--main/src/cgeo/geocaching/settings/Settings.java2
-rw-r--r--tests/src/cgeo/geocaching/export/ExportTest.java30
4 files changed, 36 insertions, 7 deletions
diff --git a/main/res/values/changelog_release.xml b/main/res/values/changelog_release.xml
index 6017bc9..b0a7286 100644
--- a/main/res/values/changelog_release.xml
+++ b/main/res/values/changelog_release.xml
@@ -2,12 +2,17 @@
<resources>
<!-- changelog for the release branch -->
<string name="changelog_release" translatable="false">\n
- <b>Next bugfix release:</b>\n
- · Fix: On change of OSM map it was not centered to the current location\n
+ <b>Next release</b>\n
+ · Fix: Crash exporting GPX for lab caches\n
+ \n
+ \n
+ <b>2015.01.20:</b>\n
· Fix: Nearby search for basic members not working in some cases\n
+ · Fix: On change of OSM map it was not centered to the current location\n
· Fix: Better handling for caches with high amount of pictures\n
· Fix: Rare crash if TB can not be found\n
· Fix: Possible crash in case GooglePlay location services are not working as expected\n
+ · Fictitious: This app will auto-solve all Mysterys\n
\n
\n
<b>2015.01.12:</b>\n
diff --git a/main/src/cgeo/geocaching/connector/UnknownConnector.java b/main/src/cgeo/geocaching/connector/UnknownConnector.java
index 8ed1da4..fcf1152 100644
--- a/main/src/cgeo/geocaching/connector/UnknownConnector.java
+++ b/main/src/cgeo/geocaching/connector/UnknownConnector.java
@@ -16,7 +16,7 @@ class UnknownConnector extends AbstractConnector {
@Override
@NonNull
public String getCacheUrl(@NonNull final Geocache cache) {
- throw new IllegalStateException("getCacheUrl cannot be called on unknown caches");
+ return StringUtils.EMPTY;
}
@Override
diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java
index ad15d81..0b54fe1 100644
--- a/main/src/cgeo/geocaching/settings/Settings.java
+++ b/main/src/cgeo/geocaching/settings/Settings.java
@@ -337,7 +337,7 @@ public class Settings {
}
public static String getUsername() {
- return getString(R.string.pref_username, null);
+ return getString(R.string.pref_username, StringUtils.EMPTY);
}
public static boolean isGCConnectorActive() {
diff --git a/tests/src/cgeo/geocaching/export/ExportTest.java b/tests/src/cgeo/geocaching/export/ExportTest.java
index 965abdd..bec676f 100644
--- a/tests/src/cgeo/geocaching/export/ExportTest.java
+++ b/tests/src/cgeo/geocaching/export/ExportTest.java
@@ -6,12 +6,14 @@ import cgeo.CGeoTestCase;
import cgeo.geocaching.DataStore;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.LogEntry;
+import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.utils.FileUtils;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -28,15 +30,32 @@ public class ExportTest extends CGeoTestCase {
assertEquals("Non matching export " + fieldNotes.getContent(), "GCX1234,2012-11-18T13:20:20Z,Found it,\"Hidden in a tree\"\n", fieldNotes.getContent());
}
- public static void testGpxExportSmilies() throws InterruptedException, ExecutionException {
+ public static void testGpxExportSmilies() throws InterruptedException, ExecutionException, IOException {
final Geocache cache = new Geocache();
cache.setGeocode("GCX1234");
cache.setCoords(new Geopoint("N 49 44.000 E 8 37.000"));
final LogEntry log = new LogEntry(1353244820000L, LogType.FOUND_IT, "Smile: \ud83d\ude0a");
DataStore.saveCache(cache, LoadFlags.SAVE_ALL);
DataStore.saveLogs(cache.getGeocode(), Collections.singletonList(log));
- ArrayList<Geocache> exportList = new ArrayList<Geocache>();
- exportList.add(cache);
+ assertCanExport(cache);
+ }
+
+ public static void testGpxExportUnknownConnector() throws InterruptedException, ExecutionException, IOException {
+ final Geocache cache = new Geocache();
+ cache.setGeocode("ABC123");
+ cache.setCoords(new Geopoint("N 49 44.000 E 8 37.000"));
+ DataStore.saveCache(cache, LoadFlags.SAVE_ALL);
+
+ assertThat(ConnectorFactory.getConnector(cache).getName()).isEqualTo("Unknown caches");
+ assertCanExport(cache);
+ }
+
+ private static void assertCanExport(final Geocache cache) throws InterruptedException, ExecutionException, IOException {
+ // enforce storing in database, as GPX will not take information from cache
+ cache.setDetailed(true);
+ DataStore.saveCache(cache, LoadFlags.SAVE_ALL);
+
+ List<Geocache> exportList = Collections.singletonList(cache);
GpxExportTester gpxExport = new GpxExportTester();
File result = null;
try {
@@ -47,6 +66,11 @@ public class ExportTest extends CGeoTestCase {
assertThat(result).isNotNull();
+ // make sure we actually exported waypoints
+ String gpx = org.apache.commons.io.FileUtils.readFileToString(result);
+ assertThat(gpx).contains("<wpt");
+ assertThat(gpx).contains(cache.getGeocode());
+
FileUtils.deleteIgnoringFailure(result);
}