aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/export/GpxSerializer.java6
-rw-r--r--tests/src/cgeo/geocaching/export/ExportTest.java17
2 files changed, 12 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/export/GpxSerializer.java b/main/src/cgeo/geocaching/export/GpxSerializer.java
index f7c0602..6755798 100644
--- a/main/src/cgeo/geocaching/export/GpxSerializer.java
+++ b/main/src/cgeo/geocaching/export/GpxSerializer.java
@@ -110,11 +110,7 @@ public final class GpxSerializer {
XmlUtils.multipleTexts(gpx, PREFIX_GPX,
"name", cache.getGeocode(),
- "desc", cache.getName());
- if (StringUtils.isNotEmpty(cache.getUrl())) {
- gpx.attribute(PREFIX_GPX, "url", cache.getUrl());
- }
- XmlUtils.multipleTexts(gpx, PREFIX_GPX,
+ "desc", cache.getName(),
"url", cache.getUrl(),
"urlname", cache.getName(),
"sym", cache.isFound() ? "Geocache Found" : "Geocache",
diff --git a/tests/src/cgeo/geocaching/export/ExportTest.java b/tests/src/cgeo/geocaching/export/ExportTest.java
index bec676f..21c45a0 100644
--- a/tests/src/cgeo/geocaching/export/ExportTest.java
+++ b/tests/src/cgeo/geocaching/export/ExportTest.java
@@ -25,7 +25,7 @@ public class ExportTest extends CGeoTestCase {
final Geocache cache = new Geocache();
cache.setGeocode("GCX1234");
final LogEntry log = new LogEntry(1353244820000L, LogType.FOUND_IT, "Hidden in a tree");
- FieldNotes fieldNotes = new FieldNotes();
+ final FieldNotes fieldNotes = new FieldNotes();
fieldNotes.add(cache, log);
assertEquals("Non matching export " + fieldNotes.getContent(), "GCX1234,2012-11-18T13:20:20Z,Found it,\"Hidden in a tree\"\n", fieldNotes.getContent());
}
@@ -55,8 +55,8 @@ public class ExportTest extends CGeoTestCase {
cache.setDetailed(true);
DataStore.saveCache(cache, LoadFlags.SAVE_ALL);
- List<Geocache> exportList = Collections.singletonList(cache);
- GpxExportTester gpxExport = new GpxExportTester();
+ final List<Geocache> exportList = Collections.singletonList(cache);
+ final GpxExportTester gpxExport = new GpxExportTester();
File result = null;
try {
result = gpxExport.testExportSync(exportList);
@@ -67,17 +67,22 @@ public class ExportTest extends CGeoTestCase {
assertThat(result).isNotNull();
// make sure we actually exported waypoints
- String gpx = org.apache.commons.io.FileUtils.readFileToString(result);
+ final String gpx = org.apache.commons.io.FileUtils.readFileToString(result);
assertThat(gpx).contains("<wpt");
assertThat(gpx).contains(cache.getGeocode());
+ if (cache.getUrl() != null) {
+ assertThat(gpx).contains("<url>");
+ } else {
+ assertThat(gpx).doesNotContain("<url>");
+ }
FileUtils.deleteIgnoringFailure(result);
}
private static class GpxExportTester extends GpxExport {
- public File testExportSync(List<Geocache> caches) throws InterruptedException, ExecutionException {
- final ArrayList<String> geocodes = new ArrayList<String>(caches.size());
+ public File testExportSync(final List<Geocache> caches) throws InterruptedException, ExecutionException {
+ final ArrayList<String> geocodes = new ArrayList<>(caches.size());
for (final Geocache cache : caches) {
geocodes.add(cache.getGeocode());
}