Index: trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java	(revision 14337)
+++ trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java	(revision 14338)
@@ -8,4 +8,5 @@
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -28,6 +29,8 @@
 import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener;
 import org.openstreetmap.josm.data.projection.ProjectionRegistry;
+import org.openstreetmap.josm.io.GpxReaderTest;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
 import org.openstreetmap.josm.tools.ListenerList;
+import org.xml.sax.SAXException;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -55,5 +58,4 @@
         data = new GpxData();
     }
-
 
     /**
@@ -83,4 +85,27 @@
         assertTrue(data.getWaypoints().contains(newWP));
         assertTrue(data.getWaypoints().contains(existingWP));
+    }
+
+    /**
+     * Test method for {@link GpxData#mergeFrom(GpxData, boolean, boolean)} including cutting/connecting tracks using actual files.
+     * @throws Exception if the track cannot be parsed
+     */
+    @Test
+    public void testMergeFromFiles() throws Exception {
+        testMerge(false, false, "Merged-all"); // regular merging
+        testMerge(true, false, "Merged-cut"); // cut overlapping tracks, but do not connect them
+        testMerge(true, true, "Merged-cut-connect"); // cut overlapping tracks and connect them
+    }
+
+    private static void testMerge(boolean cut, boolean connect, String exp) throws IOException, SAXException {
+        final GpxData own = getGpx("Layer1");
+        final GpxData other = getGpx("Layer2");
+        final GpxData expected = getGpx(exp);
+        own.mergeFrom(other, cut, connect);
+        assertEquals(expected, own);
+    }
+
+    private static GpxData getGpx(String file) throws IOException, SAXException {
+        return GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + "mergelayers/" + file + ".gpx");
     }
 
@@ -449,5 +474,5 @@
         TestUtils.assumeWorkingEqualsVerifier();
         EqualsVerifier.forClass(GpxData.class).usingGetClass()
-            .withIgnoredFields("attr", "creator", "fromServer", "storageFile", "listeners", "tracks", "routes", "waypoints", "proxy")
+            .withIgnoredFields("attr", "creator", "fromServer", "storageFile", "listeners", "tracks", "routes", "waypoints", "proxy", "segSpans")
             .withPrefabValues(WayPoint.class, new WayPoint(LatLon.NORTH_POLE), new WayPoint(LatLon.SOUTH_POLE))
             .withPrefabValues(ListenerList.class, ListenerList.create(), ListenerList.create())
