From ac5a1d50862578e09d1d7e7c6c7d6d44ac414735 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Mon, 26 Jan 2015 21:00:28 +0100 Subject: fix #4634: export GPX for unknown crashes without crash --- main/res/values/changelog_release.xml | 4 ++++ main/src/cgeo/geocaching/connector/UnknownConnector.java | 2 +- tests/src/cgeo/geocaching/export/ExportTest.java | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/main/res/values/changelog_release.xml b/main/res/values/changelog_release.xml index 9a8472f..b0a7286 100644 --- a/main/res/values/changelog_release.xml +++ b/main/res/values/changelog_release.xml @@ -2,6 +2,10 @@ \n + Next release\n + · Fix: Crash exporting GPX for lab caches\n + \n + \n 2015.01.20:\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 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/tests/src/cgeo/geocaching/export/ExportTest.java b/tests/src/cgeo/geocaching/export/ExportTest.java index edbf413..bec676f 100644 --- a/tests/src/cgeo/geocaching/export/ExportTest.java +++ b/tests/src/cgeo/geocaching/export/ExportTest.java @@ -6,6 +6,7 @@ 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; @@ -39,6 +40,16 @@ public class ExportTest extends CGeoTestCase { 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); -- cgit v1.1