Index: /trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java	(revision 9844)
+++ /trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java	(revision 9845)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.GraphicsEnvironment;
 import java.awt.event.ActionEvent;
 import java.io.File;
@@ -55,6 +56,8 @@
         }
         if (keys.isEmpty()) {
-            JOptionPane.showMessageDialog(Main.parent,
-                    tr("All the preferences of this group are default, nothing to save"), tr("Warning"), JOptionPane.WARNING_MESSAGE);
+            if (!GraphicsEnvironment.isHeadless()) {
+                JOptionPane.showMessageDialog(Main.parent,
+                        tr("All the preferences of this group are default, nothing to save"), tr("Warning"), JOptionPane.WARNING_MESSAGE);
+            }
             return;
         }
@@ -78,13 +81,16 @@
             }
         };
-        AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(false, false, title, filter,
-                JFileChooser.FILES_ONLY, "customsettings.lastDirectory");
-        if (fc != null) {
-            File sel = fc.getSelectedFile();
-            if (!sel.getName().endsWith(".xml")) sel = new File(sel.getAbsolutePath()+".xml");
-            if (!sel.getName().startsWith(schemaKey)) {
-                sel = new File(sel.getParentFile().getAbsolutePath()+'/'+schemaKey+'_'+sel.getName());
+        if (!GraphicsEnvironment.isHeadless()) {
+            AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(false, false, title, filter,
+                    JFileChooser.FILES_ONLY, "customsettings.lastDirectory");
+            if (fc != null) {
+                File sel = fc.getSelectedFile();
+                if (!sel.getName().endsWith(".xml"))
+                    sel = new File(sel.getAbsolutePath()+".xml");
+                if (!sel.getName().startsWith(schemaKey)) {
+                    sel = new File(sel.getParentFile().getAbsolutePath()+'/'+schemaKey+'_'+sel.getName());
+                }
+                return sel;
             }
-            return sel;
         }
         return null;
Index: /trunk/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java	(revision 9844)
+++ /trunk/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java	(revision 9845)
@@ -1,9 +1,24 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.actions.upload;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collection;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.command.PseudoCommand;
+import org.openstreetmap.josm.command.SequenceCommand;
 import org.openstreetmap.josm.data.APIDataSet;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.Way;
 
 /**
@@ -17,5 +32,5 @@
     @BeforeClass
     public static void setUpBeforeClass() {
-        JOSMFixture.createUnitTestFixture().init();
+        JOSMFixture.createUnitTestFixture().init(true);
     }
 
@@ -25,5 +40,90 @@
     @Test
     public void testCheckUpload() {
+        // Empty data set
+        Main.main.undoRedo.commands.clear();
         new FixDataHook().checkUpload(new APIDataSet());
+        assertTrue(Main.main.undoRedo.commands.isEmpty());
+
+        // Complete data set
+        Node emptyNode = new Node();
+        Way emptyWay = new Way();
+        Relation emptyRelation = new Relation();
+        Way w1 = new Way();
+        w1.put("color", "test");
+        Way w2 = new Way();
+        w2.put("highway", "ford");
+        Way w3 = new Way();
+        w3.put("oneway", "false");
+        Way w4 = new Way();
+        w4.put("oneway", "0");
+        Way w5 = new Way();
+        w5.put("oneway", "true");
+        Way w6 = new Way();
+        w6.put("oneway", "1");
+        Way w7 = new Way();
+        w7.put("highway", "stile");
+        Relation r1 = new Relation();
+        r1.put("type", "multipolygon");
+        r1.put("boundary", "administrative");
+        Relation r2 = new Relation();
+        r2.put("foo", "space_end ");
+        r2.put("bar", " space_begin ");
+        r2.put("baz", " space_both ");
+        r2.put(" space_begin", "test");
+        r2.put("space_end ", "test");
+        r2.put(" space_both ", "test");
+        APIDataSet ads = new APIDataSet();
+        ads.init(Arrays.asList(emptyNode, emptyWay, emptyRelation, w1, w2, w3, w4, w5, w6, w7, r1, r2));
+
+        Main.main.undoRedo.commands.clear();
+        new FixDataHook().checkUpload(ads);
+        assertEquals(1, Main.main.undoRedo.commands.size());
+
+        SequenceCommand seq = (SequenceCommand) Main.main.undoRedo.commands.iterator().next();
+        Collection<? extends OsmPrimitive> prims = seq.getParticipatingPrimitives();
+        assertNotNull(prims);
+        assertEquals(9, prims.size());
+        for (OsmPrimitive o : Arrays.asList(w1, w2, w3, w4, w5, w6, w7, r1, r2)) {
+            assertTrue(o.toString(), prims.contains(o));
+        }
+        Collection<PseudoCommand> cmds = seq.getChildren();
+        assertNotNull(cmds);
+        assertEquals(9, cmds.size());
+
+        assertTrue(seq.executeCommand());
+
+        assertFalse(w1.hasKey("color"));
+        assertTrue(w1.hasKey("colour"));
+
+        assertFalse(w2.hasKey("highway"));
+        assertTrue(w2.hasKey("ford"));
+
+        assertFalse("false".equals(w3.get("oneway")));
+        assertTrue("no".equals(w3.get("oneway")));
+
+        assertFalse("0".equals(w4.get("oneway")));
+        assertTrue("no".equals(w4.get("oneway")));
+
+        assertFalse("true".equals(w5.get("oneway")));
+        assertTrue("yes".equals(w5.get("oneway")));
+
+        assertFalse("1".equals(w6.get("oneway")));
+        assertTrue("yes".equals(w6.get("oneway")));
+
+        assertFalse(w7.hasKey("highway"));
+        assertTrue(w7.hasKey("barrier"));
+
+        assertFalse("multipolygon".equals(r1.get("type")));
+        assertTrue("boundary".equals(r1.get("type")));
+
+        assertTrue("space_end".equals(r2.get("foo")));
+        assertTrue("space_begin".equals(r2.get("bar")));
+        assertTrue("space_both".equals(r2.get("baz")));
+        assertFalse(r2.hasKey(" space_begin"));
+        assertFalse(r2.hasKey("space_end "));
+        assertFalse(r2.hasKey(" space_both "));
+        assertTrue(r2.hasKey("space_begin"));
+        assertTrue(r2.hasKey("space_end"));
+        assertTrue(r2.hasKey("space_both"));
     }
 }
Index: /trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java	(revision 9845)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java	(revision 9845)
@@ -0,0 +1,30 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.preferences.advanced;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.Main;
+
+/**
+ * Unit tests of {@link ExportProfileAction} class.
+ */
+public class ExportProfileActionTest {
+
+    /**
+     * Setup test.
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Unit test of {@link ExportProfileAction#actionPerformed}.
+     */
+    @Test
+    public void testAction()  {
+        new ExportProfileAction(Main.pref, "foo", "bar").actionPerformed(null);
+        new ExportProfileAction(Main.pref, "expert", "expert").actionPerformed(null);
+    }
+}
