Index: trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java	(revision 9732)
+++ trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java	(revision 9732)
@@ -0,0 +1,104 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.io.remotecontrol.handler;
+
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
+
+/**
+ * Unit tests of {@link AddNodeHandler} class.
+ */
+public class AddNodeHandlerTest {
+
+    /**
+     * Rule used for tests throwing exceptions.
+     */
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    /**
+     * Setup test.
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init(true);
+    }
+
+    private static AddNodeHandler newHandler(String url) {
+        AddNodeHandler req = new AddNodeHandler();
+        if (url != null)
+            req.setUrl(url);
+        return req;
+    }
+
+    /**
+     * Unit test for bad request - no layer.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestNoLayer() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("There is no layer opened to add node");
+        newHandler("https://localhost?lat=0&lon=0").handle();
+    }
+
+    /**
+     * Unit test for bad request - no param.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestNoParam() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("NumberFormatException (empty String)");
+        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
+        try {
+            Main.main.addLayer(layer);
+            newHandler(null).handle();
+        } finally {
+            Main.main.removeLayer(layer);
+        }
+    }
+
+    /**
+     * Unit test for bad request - invalid URL.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestInvalidUrl() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("The following keys are mandatory, but have not been provided: lat, lon");
+        newHandler("invalid_url").handle();
+    }
+
+    /**
+     * Unit test for bad request - incomplete URL.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestIncompleteUrl() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("The following keys are mandatory, but have not been provided: lat, lon");
+        newHandler("https://localhost").handle();
+    }
+
+    /**
+     * Unit test for nominal request - local data file.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testNominalRequest() throws Exception {
+        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
+        try {
+            Main.main.addLayer(layer);
+            newHandler("https://localhost?lat=0&lon=0").handle();
+        } finally {
+            Main.main.removeLayer(layer);
+        }
+    }
+}
Index: trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java	(revision 9728)
+++ trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java	(revision 9732)
@@ -4,5 +4,16 @@
 import static org.junit.Assert.assertEquals;
 
+import java.io.File;
+
+import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.TestUtils;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -12,11 +23,80 @@
 
     /**
+     * Rule used for tests throwing exceptions.
+     */
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    /**
+     * Setup test.
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init(true);
+    }
+
+    private static ImportHandler newHandler(String url) {
+        ImportHandler req = new ImportHandler();
+        if (url != null)
+            req.setUrl(url);
+        return req;
+    }
+
+    /**
      * Non-regression test for bug #7434.
      */
     @Test
     public void testTicket7434() {
-        final ImportHandler req = new ImportHandler();
-        req.setUrl("http://localhost:8111/import?url=http://localhost:8888/relations?relations=19711&mode=recursive");
+        ImportHandler req = newHandler("http://localhost:8111/import?url=http://localhost:8888/relations?relations=19711&mode=recursive");
         assertEquals("http://localhost:8888/relations?relations=19711&mode=recursive", req.args.get("url"));
     }
+
+    /**
+     * Unit test for bad request - no param.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestNoParam() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("MalformedURLException: null");
+        newHandler(null).handle();
+    }
+
+    /**
+     * Unit test for bad request - invalid URL.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestInvalidUrl() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("MalformedURLException: no protocol: invalid_url");
+        newHandler("https://localhost?url=invalid_url").handle();
+    }
+
+    /**
+     * Unit test for bad request - incomplete URL.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestIncompleteUrl() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("The following keys are mandatory, but have not been provided: url");
+        newHandler("https://localhost").handle();
+    }
+
+    /**
+     * Unit test for nominal request - local data file.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testNominalRequest() throws Exception {
+        String url = new File(TestUtils.getRegressionDataFile(11957, "data.osm")).toURI().toURL().toExternalForm();
+        try {
+            newHandler("https://localhost?url=" + Utils.encodeUrl(url)).handle();
+        } finally {
+            for (OsmDataLayer layer : Main.map.mapView.getLayersOfType(OsmDataLayer.class)) {
+                Main.main.removeLayer(layer);
+            }
+        }
+    }
 }
