aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2015-01-26 21:02:17 +0100
committerBananeweizen <bananeweizen@gmx.de>2015-01-26 21:02:17 +0100
commit5b13edd584f70ed5651549080437fb4fcbfd3eac (patch)
tree561c2e70de6da311e56ebf5d18836d3461a5cf46 /tests
parente58bd231a1b1be9a21ca043305794a6661d0b3ac (diff)
parentac5a1d50862578e09d1d7e7c6c7d6d44ac414735 (diff)
downloadcgeo-5b13edd584f70ed5651549080437fb4fcbfd3eac.zip
cgeo-5b13edd584f70ed5651549080437fb4fcbfd3eac.tar.gz
cgeo-5b13edd584f70ed5651549080437fb4fcbfd3eac.tar.bz2
Merge branch 'release'
Diffstat (limited to 'tests')
-rw-r--r--tests/src/cgeo/geocaching/export/ExportTest.java30
1 files changed, 27 insertions, 3 deletions
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);
}