changeset 459:66414517e25e

Make tests based on the http action, not the object type. This is to... * ... ensure that parent objects exist while creating an object. - To create a Messung object a Probe object exist. * ... ensure all objects created while testing the services are deleted.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 16 Feb 2015 15:24:35 +0100
parents 2f42128de67b
children 855b761fac0e
files src/test/java/de/intevation/lada/LadaTest.java src/test/java/de/intevation/lada/test/CreateTests.java src/test/java/de/intevation/lada/test/DeleteTests.java src/test/java/de/intevation/lada/test/GetTests.java src/test/java/de/intevation/lada/test/ProbeServiceTest.java src/test/java/de/intevation/lada/test/QueryServiceTest.java src/test/java/de/intevation/lada/test/UpdateTests.java
diffstat 7 files changed, 720 insertions(+), 354 deletions(-) [+]
line wrap: on
line diff
--- a/src/test/java/de/intevation/lada/LadaTest.java	Mon Feb 16 15:15:27 2015 +0100
+++ b/src/test/java/de/intevation/lada/LadaTest.java	Mon Feb 16 15:24:35 2015 +0100
@@ -14,13 +14,18 @@
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.arquillian.test.api.ArquillianResource;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.junit.Assert;
+import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
 
-import de.intevation.lada.test.ProbeServiceTest;
-import de.intevation.lada.test.QueryServiceTest;
+import de.intevation.lada.test.CreateTests;
+import de.intevation.lada.test.DeleteTests;
+import de.intevation.lada.test.GetTests;
+import de.intevation.lada.test.UpdateTests;
 
 
 /**
@@ -29,43 +34,83 @@
  * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
  */
 @RunWith(Arquillian.class)
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class LadaTest {
 
+    private GetTests get;
+
+    private CreateTests create;
+
+    private UpdateTests update;
+
+    private DeleteTests delete;
+
+    public LadaTest() {
+        get = new GetTests();
+        create = new CreateTests();
+        update = new UpdateTests();
+        delete = new DeleteTests();
+    }
+
     /**
      * Create a deployable WAR archive.
-     * */
-    @Deployment
+     */
+    @Deployment(testable=true)
     public static WebArchive createDeployment() throws Exception {
         return ShrinkWrap.create(WebArchive.class, "lada-basis-test.war")
             .addPackages(true, Package.getPackage("de.intevation.lada"))
-            .addClass(QueryServiceTest.class)
             .addAsResource("log4j.properties", "log4j.properties")
             .addAsResource("queryconf.json", "queryconf.json")
+            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
             .addAsResource("META-INF/test-persistence.xml",
                 "META-INF/persistence.xml");
     }
 
     /**
-     * Testing the QueryService.
+     * Testing GET Services.
      */
     @Test
     @RunAsClient
-    public final void testQueryService(@ArquillianResource URL baseUrl)
+    public final void testA_GetServices(@ArquillianResource URL baseUrl)
     throws Exception {
-        Assert.assertNotNull(baseUrl);
-        QueryServiceTest queryServiceTest = new QueryServiceTest();
-        queryServiceTest.test(baseUrl);
+        this.get.test(baseUrl);
     }
 
     /**
-     * Testing the ProbeService.
+     * Testing CREATE services.
      */
     @Test
     @RunAsClient
-    public final void testProbeService(@ArquillianResource URL baseUrl)
+    public final void testB_CreateServices(@ArquillianResource URL baseUrl)
     throws Exception {
-        Assert.assertNotNull(baseUrl);
-        ProbeServiceTest test = new ProbeServiceTest();
-        test.test(baseUrl);
+        this.create.test(baseUrl);
+    }
+
+    /**
+     * Testing UPDATE services.
+     */
+    @Test
+    @RunAsClient
+    public final void testC_UpdateServices(@ArquillianResource URL baseUrl)
+    throws Exception {
+        Assert.assertNotNull(this.create.getCreatedProbeId());
+        this.update.test(
+            baseUrl,
+            this.create.getCreatedProbeId(),
+            this.create.getCreatedMessungId());
+    }
+
+    /**
+     * Testing DELETE services.
+     */
+    @Test
+    @RunAsClient
+    public final void testD_DeleteServices(@ArquillianResource URL baseUrl)
+    throws Exception {
+        Assert.assertNotNull(this.create.getCreatedProbeId());
+        this.delete.test(
+            baseUrl,
+            this.create.getCreatedProbeId(),
+            this.create.getCreatedMessungId());
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/CreateTests.java	Mon Feb 16 15:24:35 2015 +0100
@@ -0,0 +1,138 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3) 
+ * and comes with ABSOLUTELY NO WARRANTY! Check out 
+ * the documentation coming with IMIS-Labordaten-Application for details. 
+ */
+package de.intevation.lada.test;
+
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.junit.Assert;
+
+/**
+ * Class to test all CREATE services.
+ *
+ * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
+ */
+public class CreateTests {
+
+    private static final String CREATE_PROBE =
+        "{\"baId\":\"1\",\"datenbasisId\":2,\"erzeugerId\":\"\"," +
+        "\"hauptprobenNr\":\"1234567890\",\"media\":\"\",\"mediaDesk\":" +
+        "\"\",\"mittelungsdauer\":\"\",\"mpKat\":\"\",\"mplId\":\"\"," +
+        "\"mprId\":\"\",\"mstId\":\"11010\",\"netzbetreiberId\":\"11\"," +
+        "\"probeNehmerId\":3,\"probenartId\":1,\"test\":true,\"umwId\":" +
+        "\"A1\",\"letzteAenderung\":\"2015-02-09T10:58:36\"" +
+        ",\"probeentnahmeBeginn\":\"2015-02-08T10:58:36\"," +
+        "\"probeentnahmeEnde\":\"2015-02-09T10:58:36\",\"solldatumBeginn\":" +
+        "\"2015-02-09T10:58:36\",\"solldatumEnde\":\"2015-02-09T10:58:36\"}";
+
+    private static final String CREATE_MESSUNG =
+        "{\"probeId\":\"PID\",\"mmtId\":\"A4\",\"nebenprobenNr\":\"10R1\"," +
+        "\"messdauer\":10,\"fertig\":false,\"letzteAenderung\":null," +
+        "\"geplant\":true,\"messzeitpunkt\":\"2015-02-09T10:58:36\"}";
+
+
+    private static Integer createdProbeId;
+    private static Integer createdMessungId;
+
+    public Integer getCreatedProbeId() {
+        return createdProbeId;
+    }
+
+    public Integer getCreatedMessungId() {
+        return createdMessungId;
+    }
+
+    /**
+     * Main entry point in this class to start the tests.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    public final void test(URL baseUrl) throws Exception {
+        System.out.println("\nStarting test on CREATE Services:");
+        probeCreateService(baseUrl);
+        messungCreateService(baseUrl);
+    }
+
+    /**
+     * Test the CREATE Service.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void probeCreateService(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing ProbeService: ");
+        try {
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target = client.target(baseUrl + "probe");
+            /* Send a post request containing a new probe*/
+            Response response = target.request().post(
+                    Entity.entity(CREATE_PROBE, MediaType.APPLICATION_JSON));
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader fromServiceReader =
+                Json.createReader(new StringReader(entity));
+            JsonObject content = fromServiceReader.readObject();
+            /* Save the probeid*/
+            createdProbeId =
+                content.getJsonObject("data").getJsonNumber("id").intValue();
+            /* Verify the response*/
+            Assert.assertTrue(content.getBoolean("success"));
+            Assert.assertEquals("200", content.getString("message"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+    /**
+     * Test the messung CREATE Service.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void messungCreateService(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing MessungService: ");
+        try {
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target = client.target(baseUrl + "messung");
+            /* Send a post request containing a new probe*/
+            String mess = CREATE_MESSUNG.replace("PID", createdProbeId.toString());
+            Response response = target.request().post(
+                    Entity.entity(mess, MediaType.APPLICATION_JSON));
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader fromServiceReader =
+                Json.createReader(new StringReader(entity));
+            JsonObject content = fromServiceReader.readObject();
+            /* Save the probeid*/
+            createdMessungId =
+                content.getJsonObject("data").getJsonNumber("id").intValue();
+            /* Verify the response*/
+            Assert.assertTrue(content.getBoolean("success"));
+            Assert.assertEquals("200", content.getString("message"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/DeleteTests.java	Mon Feb 16 15:24:35 2015 +0100
@@ -0,0 +1,107 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3) 
+ * and comes with ABSOLUTELY NO WARRANTY! Check out 
+ * the documentation coming with IMIS-Labordaten-Application for details. 
+ */
+package de.intevation.lada.test;
+
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
+import org.junit.Assert;
+
+/**
+ * Class to test all DELETE services.
+ *
+ * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
+ */
+public class DeleteTests {
+
+    private Integer probeId;
+
+    private Integer messungId;
+
+    /**
+     * Main entry point in this class to start the tests.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    public final void test(
+        URL baseUrl,
+        Integer probeId,
+        Integer messungId)
+    throws Exception {
+        System.out.println("\nStarting test on DELETE Services:");
+        this.probeId = probeId;
+        this.messungId = messungId;
+        messungDeleteService(baseUrl);
+        probeDeleteService(baseUrl);
+    }
+
+    /**
+     * Test the DELETE Service.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void probeDeleteService(URL baseUrl) {
+        System.out.println("Testing delete: ");
+        try {
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target =
+                client.target(baseUrl + "probe/" + this.probeId);
+            /* Delete a probe with the id saved when created a probe*/
+            Response response = target.request().delete();
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject respObj = reader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(respObj.getBoolean("success"));
+            Assert.assertEquals("200", respObj.getString("message"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+    /**
+     * Test the messung DELETE Service.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void messungDeleteService(URL baseUrl) {
+        System.out.println("Testing Messung: ");
+        try {
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target =
+                client.target(baseUrl + "messung/" + this.messungId);
+            /* Delete a probe with the id saved when created a probe*/
+            Response response = target.request().delete();
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject respObj = reader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(respObj.getBoolean("success"));
+            Assert.assertEquals("200", respObj.getString("message"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/GetTests.java	Mon Feb 16 15:24:35 2015 +0100
@@ -0,0 +1,280 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3) 
+ * and comes with ABSOLUTELY NO WARRANTY! Check out 
+ * the documentation coming with IMIS-Labordaten-Application for details. 
+ */
+package de.intevation.lada.test;
+
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
+import org.junit.Assert;
+
+/**
+ * Class to test all GET services.
+ *
+ * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
+ */
+public class GetTests {
+
+    private static final String COMPARE_PROBE =
+        "{\"id\":1,\"baId\":\"1\",\"datenbasisId\":2," +
+        "\"letzteAenderung\":1339570306000,\"media\":\"Trinkwasser " +
+        "Zentralversorgung Oberflächenwasser aufbereitet\",\"mediaDesk\":" +
+        "\"D: 59 04 01 00 05 05 01 02 00 00 00 00\",\"mittelungsdauer\":" +
+        "null,\"mstId\":\"06010\",\"netzbetreiberId\":\"06\"," +
+        "\"probeentnahmeBeginn\":1336467600000,\"probeentnahmeEnde\":" +
+        "null,\"probenartId\":1,\"test\":false,\"umwId\":\"N72\"," +
+        "\"erzeugerId\":null,\"mpKat\":\"1\",\"mplId\":null,\"mprId\":3749," +
+        "\"probeNehmerId\":726,\"solldatumBeginn\":1336341600000," +
+        "\"solldatumEnde\":1336939199000,\"probeIdAlt\":\"000007581034X\"," +
+        "\"hauptprobenNr\":\"120510002\"}";
+
+    private static final String COMPARE_MESSUNG =
+        "{\"id\":1,\"fertig\":true,\"letzteAenderung\":1331536340000," +
+        "\"messdauer\":73929,\"messzeitpunkt\":1329139620000,\"mmtId\":" +
+        "\"G1\",\"probeId\":575,\"nebenprobenNr\":\"01G1\",\"geplant\":true," +
+        "\"messungsIdAlt\":1}";
+
+    /**
+     * Main entry point in this class to start the tests.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    public final void test(URL baseUrl) throws Exception {
+        System.out.println("\nStarting test on GET Services:");
+        queryGetService(baseUrl);
+        probeGetAllService(baseUrl);
+        probeGetByIdService(baseUrl);
+        probeFilterService(baseUrl);
+        messungGetAllService(baseUrl);
+        messungGetByIdService(baseUrl);
+        messungFilterService(baseUrl);
+    }
+
+    /**
+     * Test the GET Service by requesting all queries.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void queryGetService(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing QueryService: ");
+        /* Create a client*/
+        Client client = ClientBuilder.newClient();
+        WebTarget target = client.target(baseUrl + "query");
+        /* Request all queries*/
+        Response response = target.request().get();
+        String entity = response.readEntity(String.class);
+        try{
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject content = reader.readObject();
+            /* Verfiy the response*/
+            Assert.assertTrue(content.getBoolean("success"));
+            Assert.assertEquals("200", content.getString("message"));
+            Assert.assertNotNull(content.getJsonArray("data"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+    /**
+     * Test the GET Service by requesting all probe objects.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void probeGetAllService(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing ProbeService (All): ");
+        /* Create a client*/
+        Client client = ClientBuilder.newClient();
+        WebTarget target = client.target(baseUrl + "probe");
+        /* Request all probe objects*/
+        Response response = target.request().get();
+        String entity = response.readEntity(String.class);
+        try{
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject content = reader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(content.getBoolean("success"));
+            Assert.assertEquals("200", content.getString("message"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+    /**
+     * Test the GET Service by requesting a single probe object by id.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void probeGetByIdService(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing ProbeService (byId): ");
+        try {
+            /* Create a json object from static probe string*/
+            JsonReader fromStringRreader =
+                Json.createReader(new StringReader(COMPARE_PROBE));
+            JsonObject staticProbe = fromStringRreader.readObject();
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target = client.target(baseUrl + "probe/1");
+            /* Request a probe object by id*/
+            Response response = target.request().get();
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader fromServiceReader =
+                Json.createReader(new StringReader(entity));
+            JsonObject content = fromServiceReader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(content.getBoolean("success"));
+            Assert.assertEquals("200", content.getString("message"));
+            Assert.assertEquals(staticProbe,
+                content.getJsonObject("data"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+    /**
+     * Test the GET probe service using filters.
+     *
+     * @param baseUrl The url poining to the test deployment.
+     */
+    private final void probeFilterService(URL baseUrl) {
+        System.out.println("Testing ProbeService (filter): ");
+        try {
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target =
+                client.target(baseUrl + "probe?qid=2&mst_id=11010&umw_id=N24");
+            /* Request the probe objects using the filter*/
+            Response response = target.request().get();
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject respObj = reader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(respObj.getBoolean("success"));
+            Assert.assertEquals("200", respObj.getString("message"));
+            Assert.assertNotNull(respObj.getJsonArray("data"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+
+    /**
+     * Test the GET Service by requesting all messung objects.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void messungGetAllService(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing MessungService (All): ");
+        /* Create a client*/
+        Client client = ClientBuilder.newClient();
+        WebTarget target = client.target(baseUrl + "messung");
+        /* Request all probe objects*/
+        Response response = target.request().get();
+        String entity = response.readEntity(String.class);
+        try{
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject content = reader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(content.getBoolean("success"));
+            Assert.assertEquals("200", content.getString("message"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+    /**
+     * Test the GET Service by requesting a single messung object by id.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void messungGetByIdService(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing MessungService (byId): ");
+        try {
+            /* Create a json object from static messung string*/
+            JsonReader fromStringRreader =
+                Json.createReader(new StringReader(COMPARE_MESSUNG));
+            JsonObject staticMessung = fromStringRreader.readObject();
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target = client.target(baseUrl + "messung/1");
+            /* Request a probe object by id*/
+            Response response = target.request().get();
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader fromServiceReader =
+                Json.createReader(new StringReader(entity));
+            JsonObject content = fromServiceReader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(content.getBoolean("success"));
+            Assert.assertEquals("200", content.getString("message"));
+            Assert.assertEquals(staticMessung,
+                content.getJsonObject("data"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+    /**
+     * Test the GET messung service using filters.
+     *
+     * @param baseUrl The url poining to the test deployment.
+     */
+    private final void messungFilterService(URL baseUrl) {
+        System.out.println("Testing MessungService (filter): ");
+        try {
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target =
+                client.target(baseUrl + "messung?probeId=1");
+            /* Request the probe objects using the filter*/
+            Response response = target.request().get();
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject respObj = reader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(respObj.getBoolean("success"));
+            Assert.assertEquals("200", respObj.getString("message"));
+            Assert.assertNotNull(respObj.getJsonArray("data"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+}
--- a/src/test/java/de/intevation/lada/test/ProbeServiceTest.java	Mon Feb 16 15:15:27 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,269 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3) 
- * and comes with ABSOLUTELY NO WARRANTY! Check out 
- * the documentation coming with IMIS-Labordaten-Application for details. 
- */
-package de.intevation.lada.test;
-
-import java.io.StringReader;
-import java.net.URL;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-/**
- * Class to test the Lada probe REST service.
- *
- * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
- */
-public class ProbeServiceTest {
-
-    private static final String COMPARE_PROBE =
-        "{\"id\":1,\"baId\":\"1\",\"datenbasisId\":2," +
-        "\"letzteAenderung\":1339570306000,\"media\":\"Trinkwasser " +
-        "Zentralversorgung Oberflächenwasser aufbereitet\",\"mediaDesk\":" +
-        "\"D: 59 04 01 00 05 05 01 02 00 00 00 00\",\"mittelungsdauer\":" +
-        "null,\"mstId\":\"06010\",\"netzbetreiberId\":\"06\"," +
-        "\"probeentnahmeBeginn\":1336467600000,\"probeentnahmeEnde\":" +
-        "null,\"probenartId\":1,\"test\":false,\"umwId\":\"N72\"," +
-        "\"erzeugerId\":null,\"mpKat\":\"1\",\"mplId\":null,\"mprId\":3749," +
-        "\"probeNehmerId\":726,\"solldatumBeginn\":1336341600000," +
-        "\"solldatumEnde\":1336939199000,\"probeIdAlt\":\"000007581034X\"," +
-        "\"hauptprobenNr\":\"120510002\"}";
-
-    private static final String CREATE_PROBE =
-        "{\"baId\":\"1\",\"datenbasisId\":2,\"erzeugerId\":\"\"," +
-        "\"hauptprobenNr\":\"1234567890\",\"media\":\"\",\"mediaDesk\":" +
-        "\"\",\"mittelungsdauer\":\"\",\"mpKat\":\"\",\"mplId\":\"\"," +
-        "\"mprId\":\"\",\"mstId\":\"11010\",\"netzbetreiberId\":\"11\"," +
-        "\"probeNehmerId\":3,\"probenartId\":1,\"test\":true,\"umwId\":" +
-        "\"A1\",\"letzteAenderung\":\"2015-02-09T10:58:36\"" +
-        ",\"probeentnahmeBeginn\":\"2015-02-08T10:58:36\"," +
-        "\"probeentnahmeEnde\":\"2015-02-09T10:58:36\",\"solldatumBeginn\":" +
-        "\"2015-02-09T10:58:36\",\"solldatumEnde\":\"2015-02-09T10:58:36\"}";
-
-
-    private Integer createdProbeId;
-
-    /**
-     * Main entry point in this class to start the tests.
-     *
-     * @param baseUrl The url pointing to the test deployment.
-     */
-    public final void test(URL baseUrl) throws Exception {
-        System.out.println("\nStarting test (2) on Probe-Service:");
-        probeGetAllService(baseUrl);
-        probeGetByIdService(baseUrl);
-        probeCreate(baseUrl);
-        probeUpdate(baseUrl);
-        probeDelete(baseUrl);
-        probeFilter(baseUrl);
-    }
-
-    /**
-     * Test the GET Service by requesting all probe objects.
-     *
-     * @param baseUrl The url pointing to the test deployment.
-     */
-    private final void probeGetAllService(URL baseUrl)
-    throws Exception {
-        System.out.println("Testing get: ");
-        /* Create a client*/
-        Client client = ClientBuilder.newClient();
-        WebTarget target = client.target(baseUrl + "probe");
-        /* Request all probe objects*/
-        Response response = target.request().get();
-        String entity = response.readEntity(String.class);
-        try{
-            /* Try to parse the response*/
-            JsonReader reader = Json.createReader(new StringReader(entity));
-            JsonObject content = reader.readObject();
-            /* Verify the response*/
-            Assert.assertTrue(content.getBoolean("success"));
-            Assert.assertEquals("200", content.getString("message"));
-        }
-        catch(JsonException je) {
-            Assert.fail(je.getMessage());
-        }
-        System.out.println("passed");
-    }
-
-    /**
-     * Test the GET Service by requesting a single probe object by id.
-     *
-     * @param baseUrl The url pointing to the test deployment.
-     */
-    private final void probeGetByIdService(URL baseUrl)
-    throws Exception {
-        System.out.println("Testing getById: ");
-        try {
-            /* Create a json object from static probe string*/
-            JsonReader fromStringRreader =
-                Json.createReader(new StringReader(COMPARE_PROBE));
-            JsonObject staticProbe = fromStringRreader.readObject();
-            /* Create a client*/
-            Client client = ClientBuilder.newClient();
-            WebTarget target = client.target(baseUrl + "probe/1");
-            /* Request a probe object by id*/
-            Response response = target.request().get();
-            String entity = response.readEntity(String.class);
-            /* Try to parse the response*/
-            JsonReader fromServiceReader =
-                Json.createReader(new StringReader(entity));
-            JsonObject content = fromServiceReader.readObject();
-            /* Verify the response*/
-            Assert.assertTrue(content.getBoolean("success"));
-            Assert.assertEquals("200", content.getString("message"));
-            Assert.assertEquals(staticProbe,
-                content.getJsonObject("data"));
-        }
-        catch(JsonException je) {
-            Assert.fail(je.getMessage());
-        }
-        System.out.println("passed");
-    }
-
-    /**
-     * Test the CREATE Service.
-     *
-     * @param baseUrl The url pointing to the test deployment.
-     */
-    private final void probeCreate(URL baseUrl)
-    throws Exception {
-        System.out.println("Testing create: ");
-        try {
-            /* Create a client*/
-            Client client = ClientBuilder.newClient();
-            WebTarget target = client.target(baseUrl + "probe");
-            /* Send a post request containing a new probe*/
-            Response response = target.request().post(
-                    Entity.entity(CREATE_PROBE, MediaType.APPLICATION_JSON));
-            String entity = response.readEntity(String.class);
-            /* Try to parse the response*/
-            JsonReader fromServiceReader =
-                Json.createReader(new StringReader(entity));
-            JsonObject content = fromServiceReader.readObject();
-            /* Save the probeid*/
-            this.createdProbeId =
-                content.getJsonObject("data").getJsonNumber("id").intValue();
-            /* Verify the response*/
-            Assert.assertTrue(content.getBoolean("success"));
-            Assert.assertEquals("200", content.getString("message"));
-        }
-        catch(JsonException je) {
-            Assert.fail(je.getMessage());
-        }
-        System.out.println("passed");
-    }
-
-    /**
-     * Test the UPDATE Service.
-     *
-     * @param baseUrl The url pointing to the test deployment.
-     */
-    private final void probeUpdate(URL baseUrl)
-    throws Exception {
-        System.out.println("Testing update: ");
-        try {
-            /* Create a client*/
-            Client client = ClientBuilder.newClient();
-            WebTarget target =
-                client.target(baseUrl + "probe/" + this.createdProbeId);
-            /* Request a probe with the id saved when created a probe*/
-            Response response = target.request().get();
-            String entity = response.readEntity(String.class);
-            /* Try to parse the response*/
-            JsonReader reader = Json.createReader(new StringReader(entity));
-            JsonObject oldProbe = reader.readObject().getJsonObject("data");
-            /* Change the hauptprobenNr*/
-            String updatedEntity =
-                oldProbe.toString().replace("1234567890", "2345678901");
-            /* Send the updated probe via put reauest*/
-            WebTarget putTarget = client.target(baseUrl + "probe");
-            Response updated = putTarget.request().put(
-                Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
-            /* Try to parse the response*/
-            JsonReader updatedReader = Json.createReader(
-                new StringReader(updated.readEntity(String.class)));
-            JsonObject updatedProbe = updatedReader.readObject();
-            /* Verify the response*/
-            Assert.assertTrue(updatedProbe.getBoolean("success"));
-            Assert.assertEquals("200", updatedProbe.getString("message"));
-            Assert.assertEquals("2345678901",
-                updatedProbe.getJsonObject("data").getString("hauptprobenNr"));
-        }
-        catch(JsonException je) {
-            Assert.fail(je.getMessage());
-        }
-        System.out.println("passed");
-    }
-
-    /**
-     * Test the DELETE Service.
-     *
-     * @param baseUrl The url pointing to the test deployment.
-     */
-    private final void probeDelete(URL baseUrl) {
-        System.out.println("Testing delete: ");
-        try {
-            /* Create a client*/
-            Client client = ClientBuilder.newClient();
-            WebTarget target =
-                client.target(baseUrl + "probe/" + this.createdProbeId);
-            /* Delete a probe with the id saved when created a probe*/
-            Response response = target.request().delete();
-            String entity = response.readEntity(String.class);
-            /* Try to parse the response*/
-            JsonReader reader = Json.createReader(new StringReader(entity));
-            JsonObject respObj = reader.readObject();
-            /* Verify the response*/
-            Assert.assertTrue(respObj.getBoolean("success"));
-            Assert.assertEquals("200", respObj.getString("message"));
-        }
-        catch(JsonException je) {
-            Assert.fail(je.getMessage());
-        }
-        System.out.println("passed");
-    }
-
-    /**
-     * Test the GET service using filters.
-     *
-     * @param baseUrl The url poining to the test deployment.
-     */
-    private final void probeFilter(URL baseUrl) {
-        System.out.println("Testing filter: ");
-        try {
-            /* Create a client*/
-            Client client = ClientBuilder.newClient();
-            WebTarget target =
-                client.target(baseUrl + "probe?qid=2&mst_id=11010&umw_id=N24");
-            /* Request the probe objects using the filter*/
-            Response response = target.request().get();
-            String entity = response.readEntity(String.class);
-            /* Try to parse the response*/
-            JsonReader reader = Json.createReader(new StringReader(entity));
-            JsonObject respObj = reader.readObject();
-            /* Verify the response*/
-            Assert.assertTrue(respObj.getBoolean("success"));
-            Assert.assertEquals("200", respObj.getString("message"));
-            Assert.assertNotNull(respObj.getJsonArray("data"));
-        }
-        catch(JsonException je) {
-            Assert.fail(je.getMessage());
-        }
-        System.out.println("passed");
-    }
-}
--- a/src/test/java/de/intevation/lada/test/QueryServiceTest.java	Mon Feb 16 15:15:27 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3) 
- * and comes with ABSOLUTELY NO WARRANTY! Check out 
- * the documentation coming with IMIS-Labordaten-Application for details. 
- */
-package de.intevation.lada.test;
-
-import java.io.StringReader;
-import java.net.URL;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-/**
- * Class to test the Lada query REST service.
- *
- * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
- */
-public class QueryServiceTest {
-
-    /**
-     * Main entry point in this class to start the tests.
-     *
-     * @param baseUrl The url pointing to the test deployment.
-     */
-    public final void test(URL baseUrl) throws Exception {
-        queryService(baseUrl);
-    }
-
-    /**
-     * Test the GET Service by requesting all queries.
-     *
-     * @param baseUrl The url pointing to the test deployment.
-     */
-    private final void queryService(URL baseUrl)
-    throws Exception {
-        System.out.println("Starting test (1) on Query-Service:");
-        System.out.println("Testing get: ");
-        /* Create a client*/
-        Client client = ClientBuilder.newClient();
-        WebTarget target = client.target(baseUrl + "query");
-        /* Request all queries*/
-        Response response = target.request().get();
-        String entity = response.readEntity(String.class);
-        try{
-            /* Try to parse the response*/
-            JsonReader reader = Json.createReader(new StringReader(entity));
-            JsonObject content = reader.readObject();
-            /* Verfiy the response*/
-            Assert.assertTrue(content.getBoolean("success"));
-            Assert.assertEquals("200", content.getString("message"));
-            Assert.assertNotNull(content.getJsonArray("data"));
-        }
-        catch(JsonException je) {
-            Assert.fail(je.getMessage());
-        }
-        System.out.println("passed");
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/UpdateTests.java	Mon Feb 16 15:24:35 2015 +0100
@@ -0,0 +1,135 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3) 
+ * and comes with ABSOLUTELY NO WARRANTY! Check out 
+ * the documentation coming with IMIS-Labordaten-Application for details. 
+ */
+package de.intevation.lada.test;
+
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.junit.Assert;
+
+/**
+ * Class to test all UPDATE services.
+ *
+ * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
+ */
+public class UpdateTests {
+
+    private Integer probeId;
+
+    private Integer messungId;
+
+    /**
+     * Main entry point in this class to start the tests.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    public final void test(URL baseUrl, Integer probeId, Integer messungId)
+    throws Exception {
+        System.out.println("\nStarting test on UPDATE Services:");
+        this.probeId = probeId;
+        this.messungId = messungId;
+        probeUpdateService(baseUrl);
+        messungUpdate(baseUrl);
+    }
+
+    /**
+     * Test the probe update service.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void probeUpdateService(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing ProbeService: ");
+        try {
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target =
+                client.target(baseUrl + "probe/" + this.probeId);
+            /* Request a probe with the id saved when created a probe*/
+            Response response = target.request().get();
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject oldProbe = reader.readObject().getJsonObject("data");
+            /* Change the hauptprobenNr*/
+            String updatedEntity =
+                oldProbe.toString().replace("1234567890", "2345678901");
+            /* Send the updated probe via put reauest*/
+            WebTarget putTarget = client.target(baseUrl + "probe");
+            Response updated = putTarget.request().put(
+                Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
+            /* Try to parse the response*/
+            JsonReader updatedReader = Json.createReader(
+                new StringReader(updated.readEntity(String.class)));
+            JsonObject updatedProbe = updatedReader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(updatedProbe.getBoolean("success"));
+            Assert.assertEquals("200", updatedProbe.getString("message"));
+            Assert.assertEquals("2345678901",
+                updatedProbe.getJsonObject("data").getString("hauptprobenNr"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+    /**
+     * Test the messung UPDATE Service.
+     *
+     * @param baseUrl The url pointing to the test deployment.
+     */
+    private final void messungUpdate(URL baseUrl)
+    throws Exception {
+        System.out.println("Testing MessungService: ");
+        try {
+            /* Create a client*/
+            Client client = ClientBuilder.newClient();
+            WebTarget target =
+                client.target(baseUrl + "messung/" + this.messungId);
+            /* Request a probe with the id saved when created a probe*/
+            Response response = target.request().get();
+            String entity = response.readEntity(String.class);
+            /* Try to parse the response*/
+            JsonReader reader = Json.createReader(new StringReader(entity));
+            JsonObject oldProbe = reader.readObject().getJsonObject("data");
+            /* Change the hauptprobenNr*/
+            String updatedEntity =
+                oldProbe.toString().replace("A4", "G1");
+            /* Send the updated probe via put reauest*/
+            WebTarget putTarget = client.target(baseUrl + "messung");
+            Response updated = putTarget.request().put(
+                Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
+            /* Try to parse the response*/
+            JsonReader updatedReader = Json.createReader(
+                new StringReader(updated.readEntity(String.class)));
+            JsonObject updatedProbe = updatedReader.readObject();
+            /* Verify the response*/
+            Assert.assertTrue(updatedProbe.getBoolean("success"));
+            Assert.assertEquals("200", updatedProbe.getString("message"));
+            Assert.assertEquals("G1",
+                updatedProbe.getJsonObject("data").getString("mmtId"));
+        }
+        catch(JsonException je) {
+            Assert.fail(je.getMessage());
+        }
+        System.out.println("passed");
+    }
+
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)