Index: trunk/test/unit/org/openstreetmap/josm/TestUtils.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 14403)
+++ trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 14410)
@@ -204,4 +204,41 @@
 
     /**
+     * Sets a private field value.
+     * @param obj object
+     * @param fieldName private field name
+     * @param value replacement value
+     * @throws ReflectiveOperationException if a reflection operation error occurs
+     */
+    public static void setPrivateField(
+        final Object obj,
+        final String fieldName,
+        final Object value
+    ) throws ReflectiveOperationException {
+        setPrivateField(obj.getClass(), obj, fieldName, value);
+    }
+
+    /**
+     * Sets a private field value.
+     * @param cls object class
+     * @param obj object
+     * @param fieldName private field name
+     * @param value replacement value
+     * @throws ReflectiveOperationException if a reflection operation error occurs
+     */
+    public static void setPrivateField(
+        final Class<?> cls,
+        final Object obj,
+        final String fieldName,
+        final Object value
+    ) throws ReflectiveOperationException {
+        Field f = cls.getDeclaredField(fieldName);
+        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+            f.setAccessible(true);
+            return null;
+        });
+        f.set(obj, value);
+    }
+
+    /**
      * Returns a private static field value.
      * @param cls object class
Index: trunk/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java	(revision 14403)
+++ trunk/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java	(revision 14410)
@@ -2,5 +2,12 @@
 package org.openstreetmap.josm.gui.dialogs.changeset;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.awt.GraphicsEnvironment;
+import java.awt.event.ActionEvent;
+import javax.swing.JButton;
+import javax.swing.JDialog;
 
 import java.util.Collections;
@@ -9,4 +16,5 @@
 import org.junit.Rule;
 import org.junit.Test;
+import org.openstreetmap.josm.TestUtils;
 import org.openstreetmap.josm.data.osm.Changeset;
 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.CancelAction;
@@ -19,5 +27,14 @@
 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.RemoveFromCacheAction;
 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.ShowDetailAction;
+import org.openstreetmap.josm.gui.dialogs.changeset.query.ChangesetQueryDialog;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
+import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker;
+import org.openstreetmap.josm.testutils.mockers.WindowMocker;
+
+import com.google.common.collect.ImmutableMap;
+
+import mockit.Invocation;
+import mockit.Mock;
+import mockit.MockUp;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -103,5 +120,20 @@
     @Test
     public void testDownloadMyChangesets() {
+        TestUtils.assumeWorkingJMockit();
+        final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(
+            ImmutableMap.<String, Object>of(
+                "<html>JOSM is currently running with an anonymous user. It cannot download<br>"
+                + "your changesets from the OSM server unless you enter your OSM user name<br>"
+                + "in the JOSM preferences.</html>",
+                "OK"
+            )
+        );
+
         new DownloadMyChangesets().actionPerformed(null);
+
+        assertEquals(1, haMocker.getInvocationLog().size());
+        Object[] invocationLogEntry = haMocker.getInvocationLog().get(0);
+        assertEquals(0, (int) invocationLogEntry[0]);
+        assertEquals("Warning", invocationLogEntry[2]);
     }
 
@@ -111,7 +143,13 @@
     @Test
     public void testDownloadSelectedChangesetContentAction() {
+        if (GraphicsEnvironment.isHeadless()) {
+            TestUtils.assumeWorkingJMockit();
+            // to allow us to construct a JDialog
+            new WindowMocker();
+        }
+
         DownloadSelectedChangesetContentAction action = new DownloadSelectedChangesetContentAction(ChangesetCacheManager.buildModel());
         action.valueChanged(null);
-        action.actionPerformed(null);
+        action.actionPerformed(new ActionEvent(new JDialog().getComponent(0), ActionEvent.ACTION_PERFORMED, "foo"));
     }
 
@@ -121,7 +159,13 @@
     @Test
     public void testDownloadSelectedChangesetsAction() {
+        if (GraphicsEnvironment.isHeadless()) {
+            TestUtils.assumeWorkingJMockit();
+            // to allow us to construct a JDialog
+            new WindowMocker();
+        }
+
         DownloadSelectedChangesetsAction action = new DownloadSelectedChangesetsAction(ChangesetCacheManager.buildModel());
         action.valueChanged(null);
-        action.actionPerformed(null);
+        action.actionPerformed(new ActionEvent(new JDialog().getComponent(0), ActionEvent.ACTION_PERFORMED, "foo"));
     }
 
@@ -131,5 +175,42 @@
     @Test
     public void testQueryAction() {
+        TestUtils.assumeWorkingJMockit();
+
+        // set up mockers to simulate the dialog being cancelled
+        final boolean[] dialogShown = new boolean[] {false};
+        if (GraphicsEnvironment.isHeadless()) {
+            new WindowMocker();
+        }
+        new MockUp<JDialog>() {
+            @Mock
+            void setVisible(final Invocation invocation, final boolean visible) throws Exception {
+                if (visible) {
+                    ((JButton) TestUtils.getComponentByName((JDialog) invocation.getInvokedInstance(), "cancelButton")).doClick();
+                    dialogShown[0] = true;
+                }
+                // critically, don't proceed into implementation
+            }
+        };
+        new MockUp<ChangesetQueryDialog>() {
+            @Mock
+            void setVisible(final Invocation invocation, final boolean visible) throws Exception {
+                if (GraphicsEnvironment.isHeadless()) {
+                    // we have to mock the behaviour quite coarsely as much of ChangesetQueryDialog will
+                    // raise a HeadlessException
+                    if (visible) {
+                        TestUtils.setPrivateField(ChangesetQueryDialog.class, invocation.getInvokedInstance(), "canceled", true);
+                        dialogShown[0] = true;
+                    }
+                } else {
+                    // proceeding into the implementation allows a bit more of the target code to be
+                    // covered, actual mocking is performed on JDialog's setVisible()
+                    invocation.proceed(visible);
+                }
+            }
+        };
+
         new QueryAction().actionPerformed(null);
+
+        assertTrue(dialogShown[0]);
     }
 
