Index: /trunk/.classpath
===================================================================
--- /trunk/.classpath	(revision 11100)
+++ /trunk/.classpath	(revision 11101)
@@ -19,4 +19,5 @@
 	<classpathentry kind="lib" path="test/lib/reflections/guava-19.0.jar"/>
 	<classpathentry kind="lib" path="test/lib/reflections/javassist-3.20.0-GA.jar"/>
+	<classpathentry kind="lib" path="test/lib/system-rules-1.16.0.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_102"/>
 	<classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
Index: /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java	(revision 11100)
+++ /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java	(revision 11101)
@@ -102,26 +102,28 @@
      */
     public static boolean saveUnsavedModifications(Iterable<? extends Layer> selectedLayers, Reason reason) {
-        SaveLayersDialog dialog = new SaveLayersDialog(Main.parent);
-        List<AbstractModifiableLayer> layersWithUnmodifiedChanges = new ArrayList<>();
-        for (Layer l: selectedLayers) {
-            if (!(l instanceof AbstractModifiableLayer)) {
-                continue;
-            }
-            AbstractModifiableLayer odl = (AbstractModifiableLayer) l;
-            if (odl.isModified() &&
-                    ((!odl.isSavable() && !odl.isUploadable()) ||
-                            odl.requiresSaveToFile() ||
-                            (odl.requiresUploadToServer() && !odl.isUploadDiscouraged()))) {
-                layersWithUnmodifiedChanges.add(odl);
-            }
-        }
-        dialog.prepareForSavingAndUpdatingLayers(reason);
-        if (!layersWithUnmodifiedChanges.isEmpty()) {
-            dialog.getModel().populate(layersWithUnmodifiedChanges);
-            dialog.setVisible(true);
-            switch(dialog.getUserAction()) {
-                case PROCEED: return true;
-                case CANCEL:
-                default: return false;
+        if (!GraphicsEnvironment.isHeadless()) {
+            SaveLayersDialog dialog = new SaveLayersDialog(Main.parent);
+            List<AbstractModifiableLayer> layersWithUnmodifiedChanges = new ArrayList<>();
+            for (Layer l: selectedLayers) {
+                if (!(l instanceof AbstractModifiableLayer)) {
+                    continue;
+                }
+                AbstractModifiableLayer odl = (AbstractModifiableLayer) l;
+                if (odl.isModified() &&
+                        ((!odl.isSavable() && !odl.isUploadable()) ||
+                                odl.requiresSaveToFile() ||
+                                (odl.requiresUploadToServer() && !odl.isUploadDiscouraged()))) {
+                    layersWithUnmodifiedChanges.add(odl);
+                }
+            }
+            dialog.prepareForSavingAndUpdatingLayers(reason);
+            if (!layersWithUnmodifiedChanges.isEmpty()) {
+                dialog.getModel().populate(layersWithUnmodifiedChanges);
+                dialog.setVisible(true);
+                switch(dialog.getUserAction()) {
+                    case PROCEED: return true;
+                    case CANCEL:
+                    default: return false;
+                }
             }
         }
Index: /trunk/test/unit/org/openstreetmap/josm/actions/DeleteLayerActionTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/actions/DeleteLayerActionTest.java	(revision 11101)
+++ /trunk/test/unit/org/openstreetmap/josm/actions/DeleteLayerActionTest.java	(revision 11101)
@@ -0,0 +1,43 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.testutils.JOSMTestRules;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+/**
+ * Unit tests for class {@link DeleteLayerAction}.
+ */
+public final class DeleteLayerActionTest {
+
+    /**
+     * Setup test.
+     */
+    @Rule
+    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+    public JOSMTestRules test = new JOSMTestRules().platform();
+
+    /**
+     * Unit test of {@link DeleteLayerAction#actionPerformed}
+     */
+    @Test
+    public void testActionPerformed() {
+        DeleteLayerAction action = new DeleteLayerAction();
+        // No layer
+        action.actionPerformed(null);
+        // OsmDataLayer
+        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
+        Main.getLayerManager().addLayer(layer);
+        assertNotNull(Main.getLayerManager().getActiveLayer());
+        action.actionPerformed(null);
+        assertNull(Main.getLayerManager().getActiveLayer());
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java	(revision 11101)
+++ /trunk/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java	(revision 11101)
@@ -0,0 +1,38 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.ExpectedSystemExit;
+import org.openstreetmap.josm.testutils.JOSMTestRules;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+/**
+ * Unit tests for class {@link ExitAction}.
+ */
+public final class ExitActionTest {
+
+    /**
+     * Setup test.
+     */
+    @Rule
+    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+    public JOSMTestRules test = new JOSMTestRules().platform();
+
+    /**
+     * System.exit rule
+     */
+    @Rule
+    public final ExpectedSystemExit exit = ExpectedSystemExit.none();
+
+    /**
+     * Unit test of {@link ExitAction#actionPerformed}
+     */
+    @Test
+    public void testActionPerformed() {
+        exit.expectSystemExitWithStatus(0);
+        // No layer
+        new ExitAction().actionPerformed(null);
+    }
+}
