From 0f0fd3e75d6cfeffd8ba0a3e26e269b0db2b17c7 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Mon, 26 Jan 2015 20:55:25 +0100 Subject: GPX export test doesn't recognize failure We exported empty GPX file from that test. Therefore verify they actually contain the cache. --- tests/src/cgeo/geocaching/export/ExportTest.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/src/cgeo/geocaching/export/ExportTest.java b/tests/src/cgeo/geocaching/export/ExportTest.java index 965abdd..edbf413 100644 --- a/tests/src/cgeo/geocaching/export/ExportTest.java +++ b/tests/src/cgeo/geocaching/export/ExportTest.java @@ -12,6 +12,7 @@ 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 +29,22 @@ 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 exportList = new ArrayList(); - exportList.add(cache); + 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 exportList = Collections.singletonList(cache); GpxExportTester gpxExport = new GpxExportTester(); File result = null; try { @@ -47,6 +55,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(" Date: Mon, 26 Jan 2015 21:00:28 +0100 Subject: fix #4634: export GPX for unknown crashes without crash --- tests/src/cgeo/geocaching/export/ExportTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') 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