Index: /trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java	(revision 9778)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java	(revision 9779)
@@ -4,4 +4,5 @@
 import java.awt.BorderLayout;
 import java.awt.Cursor;
+import java.awt.GraphicsEnvironment;
 import java.awt.Image;
 import java.awt.event.ActionEvent;
@@ -68,8 +69,10 @@
         scale.setSelected(true);
         JOptionPane pane = new JOptionPane(p, JOptionPane.PLAIN_MESSAGE);
-        JDialog dlg = pane.createDialog(Main.parent, imageUrl.toString());
-        dlg.setModal(false);
-        dlg.toFront();
-        dlg.setVisible(true);
+        if (!GraphicsEnvironment.isHeadless()) {
+            JDialog dlg = pane.createDialog(Main.parent, imageUrl.toString());
+            dlg.setModal(false);
+            dlg.toFront();
+            dlg.setVisible(true);
+        }
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java	(revision 9778)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java	(revision 9779)
@@ -54,4 +54,5 @@
                 playHead = new PlayHeadMarker();
             } catch (Exception ex) {
+                Main.error(ex);
                 return null;
             }
@@ -67,20 +68,22 @@
         if (!enabled) return;
         dropTolerance = Main.pref.getInteger("marker.playHeadDropTolerance", 50);
-        Main.map.mapView.addMouseListener(new MouseAdapter() {
-            @Override public void mousePressed(MouseEvent ev) {
-                Point p = ev.getPoint();
-                if (ev.getButton() != MouseEvent.BUTTON1 || p == null)
-                    return;
-                if (playHead.containsPoint(p)) {
-                    /* when we get a click on the marker, we need to switch mode to avoid
-                     * getting confused with other drag operations (like select) */
-                    oldMode = Main.map.mapMode;
-                    oldCoor = getCoor();
-                    PlayHeadDragMode playHeadDragMode = new PlayHeadDragMode(playHead);
-                    Main.map.selectMapMode(playHeadDragMode);
-                    playHeadDragMode.mousePressed(ev);
-                }
-            }
-        });
+        if (Main.isDisplayingMapView()) {
+            Main.map.mapView.addMouseListener(new MouseAdapter() {
+                @Override public void mousePressed(MouseEvent ev) {
+                    Point p = ev.getPoint();
+                    if (ev.getButton() != MouseEvent.BUTTON1 || p == null)
+                        return;
+                    if (playHead.containsPoint(p)) {
+                        /* when we get a click on the marker, we need to switch mode to avoid
+                         * getting confused with other drag operations (like select) */
+                        oldMode = Main.map.mapMode;
+                        oldCoor = getCoor();
+                        PlayHeadDragMode playHeadDragMode = new PlayHeadDragMode(playHead);
+                        Main.map.selectMapMode(playHeadDragMode);
+                        playHeadDragMode.mousePressed(ev);
+                    }
+                }
+            });
+        }
     }
 
Index: /trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java	(revision 9778)
+++ /trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java	(revision 9779)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.GraphicsEnvironment;
 import java.io.IOException;
 import java.net.URL;
@@ -377,7 +378,10 @@
         else
             msg = tr(msg);
-        JOptionPane.showMessageDialog(Main.parent,
-                "<html><p>" + msg + "</p></html>",
-                tr("Error playing sound"), JOptionPane.ERROR_MESSAGE);
+        Main.error(msg);
+        if (!GraphicsEnvironment.isHeadless()) {
+            JOptionPane.showMessageDialog(Main.parent,
+                    "<html><p>" + msg + "</p></html>",
+                    tr("Error playing sound"), JOptionPane.ERROR_MESSAGE);
+        }
     }
 }
Index: /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarkerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarkerTest.java	(revision 9779)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarkerTest.java	(revision 9779)
@@ -0,0 +1,50 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.layer.markerlayer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.Extensions;
+import org.openstreetmap.josm.data.gpx.GpxConstants;
+import org.openstreetmap.josm.data.gpx.GpxData;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+
+/**
+ * Unit tests of {@link AudioMarker} class.
+ */
+public class AudioMarkerTest {
+
+    /**
+     * Setup tests
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Unit test of {@link AudioMarker#AudioMarker}.
+     * @throws MalformedURLException never
+     */
+    @Test
+    public void testAudioMarker() throws MalformedURLException {
+        AudioMarker marker = new AudioMarker(
+                LatLon.ZERO,
+                null,
+                new URL("file://something.wav"),
+                new MarkerLayer(new GpxData(), null, null, null),
+                1d, 2d);
+        marker.actionPerformed(null);
+        assertEquals("2", marker.getText());
+        WayPoint wpt = marker.convertToWayPoint();
+        assertEquals(LatLon.ZERO, wpt.getCoor());
+        Extensions ext = (Extensions) wpt.get(GpxConstants.META_EXTENSIONS);
+        assertEquals("2.0", ext.get("offset"));
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java	(revision 9779)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java	(revision 9779)
@@ -0,0 +1,45 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.layer.markerlayer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.GpxData;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+
+/**
+ * Unit tests of {@link ImageMarker} class.
+ */
+public class ImageMarkerTest {
+
+    /**
+     * Setup tests
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Unit test of {@link ImageMarker#ImageMarker}.
+     * @throws MalformedURLException never
+     */
+    @Test
+    public void testImageMarker() throws MalformedURLException {
+        ImageMarker marker = new ImageMarker(
+                LatLon.ZERO,
+                new URL("file://something.jpg"),
+                new MarkerLayer(new GpxData(), null, null, null),
+                1d, 2d);
+        marker.actionPerformed(null);
+        assertEquals("", marker.getText());
+        WayPoint wpt = marker.convertToWayPoint();
+        assertEquals(LatLon.ZERO, wpt.getCoor());
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarkerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarkerTest.java	(revision 9779)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarkerTest.java	(revision 9779)
@@ -0,0 +1,38 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.layer.markerlayer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+
+/**
+ * Unit tests of {@link PlayHeadMarker} class.
+ */
+public class PlayHeadMarkerTest {
+
+    /**
+     * Setup tests
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Unit test of {@link PlayHeadMarker#PlayHeadMarker}.
+     */
+    @Test
+    public void testPlayHeadMarker() {
+        PlayHeadMarker marker = PlayHeadMarker.create();
+        assertNotNull(marker);
+        marker.actionPerformed(null);
+        assertEquals("", marker.getText());
+        WayPoint wpt = marker.convertToWayPoint();
+        assertEquals(LatLon.ZERO, wpt.getCoor());
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java	(revision 9779)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java	(revision 9779)
@@ -0,0 +1,45 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.layer.markerlayer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.GpxData;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+
+/**
+ * Unit tests of {@link WebMarker} class.
+ */
+public class WebMarkerTest {
+
+    /**
+     * Setup tests
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Unit test of {@link WebMarker#WebMarker}.
+     * @throws MalformedURLException never
+     */
+    @Test
+    public void testWebMarker() throws MalformedURLException {
+        WebMarker marker = new WebMarker(
+                LatLon.ZERO,
+                new URL("http://something.com"),
+                new MarkerLayer(new GpxData(), null, null, null),
+                1d, 2d);
+        marker.actionPerformed(null);
+        assertEquals("", marker.getText());
+        WayPoint wpt = marker.convertToWayPoint();
+        assertEquals(LatLon.ZERO, wpt.getCoor());
+    }
+}
