Index: trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 14348)
+++ trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 14349)
@@ -11,5 +11,4 @@
 import java.awt.Composite;
 import java.awt.Graphics2D;
-import java.awt.GraphicsEnvironment;
 import java.awt.GridBagLayout;
 import java.awt.Rectangle;
@@ -1103,7 +1102,4 @@
     public boolean checkSaveConditions() {
         if (isDataSetEmpty() && 1 != GuiHelper.runInEDTAndWaitAndReturn(() -> {
-            if (GraphicsEnvironment.isHeadless()) {
-                return 2;
-            }
             return new ExtendedDialog(
                     MainApplication.getMainFrame(),
Index: trunk/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java	(revision 14348)
+++ trunk/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java	(revision 14349)
@@ -35,5 +35,8 @@
 import org.openstreetmap.josm.io.OsmReader;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
+import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
 import org.openstreetmap.josm.tools.date.DateUtils;
+
+import com.google.common.collect.ImmutableMap;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -280,9 +283,22 @@
     @Test
     public void testCheckSaveConditions() {
+        TestUtils.assumeWorkingJMockit();
+        final ExtendedDialogMocker edMocker = new ExtendedDialogMocker(
+            ImmutableMap.<String, Object>of("The document contains no data.", "Cancel")
+        );
+
         assertFalse(layer.checkSaveConditions());
         fillDataSet(ds);
         assertTrue(layer.checkSaveConditions());
-    }
-
+
+        assertEquals(1, edMocker.getInvocationLog().size());
+        Object[] invocationLogEntry = edMocker.getInvocationLog().get(0);
+        assertEquals(2, (int) invocationLogEntry[0]);
+        assertEquals("Empty document", invocationLogEntry[2]);
+    }
+
+    /**
+     * Checks that unnamed layer number increases
+     */
     @Test
     public void testLayerNameIncreases() throws Exception {
@@ -293,4 +309,7 @@
     }
 
+    /**
+     * Checks that named layer got no number
+     */
     @Test
     public void testLayerUnnumberedName() {
Index: trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityActionTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityActionTest.java	(revision 14348)
+++ trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityActionTest.java	(revision 14349)
@@ -9,4 +9,5 @@
 import org.junit.Rule;
 import org.junit.Test;
+import org.openstreetmap.josm.TestUtils;
 import org.openstreetmap.josm.gui.ExtendedDialog;
 import org.openstreetmap.josm.gui.layer.GpxLayerTest;
@@ -34,5 +35,7 @@
     @Test
     public void testAction() throws Exception {
+        TestUtils.assumeWorkingJMockit();
         final ExtendedDialogMocker edMocker = new ExtendedDialogMocker() {
+            @Override
             protected String getString(final ExtendedDialog instance) {
                 return ((JLabel) ((JPanel) this.getContent(instance)).getComponent(2)).getText();
