[Lada-commits] [PATCH 2 of 5] Improved test logging

Wald Commits scm-commit at wald.intevation.org
Tue Feb 17 13:43:51 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1424176968 -3600
# Node ID f6b206b2bdac5270c2cd0ededfc7ab20d284dd0b
# Parent  9be4f6f7c050e388dfed6bac24edc4f6ffa31d76
Improved test logging.

diff -r 9be4f6f7c050 -r f6b206b2bdac src/test/java/de/intevation/lada/LadaTest.java
--- a/src/test/java/de/intevation/lada/LadaTest.java	Tue Feb 17 13:40:28 2015 +0100
+++ b/src/test/java/de/intevation/lada/LadaTest.java	Tue Feb 17 13:42:48 2015 +0100
@@ -8,7 +8,10 @@
 package de.intevation.lada;
 
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.container.test.api.RunAsClient;
 import org.jboss.arquillian.junit.Arquillian;
@@ -37,6 +40,12 @@
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class LadaTest {
 
+    private static String ARCHIVE_NAME = "lada-basis-test.war";
+
+    private static Logger logger = Logger.getLogger(LadaTest.class);
+
+    private boolean verboseLogging = false;
+
     private GetTests get;
 
     private CreateTests create;
@@ -45,11 +54,14 @@
 
     private DeleteTests delete;
 
+    private List<Protocol> testProtocol;
+
     public LadaTest() {
         get = new GetTests();
         create = new CreateTests();
         update = new UpdateTests();
         delete = new DeleteTests();
+        testProtocol = new ArrayList<Protocol>();
     }
 
     /**
@@ -57,13 +69,15 @@
      */
     @Deployment(testable=true)
     public static WebArchive createDeployment() throws Exception {
-        return ShrinkWrap.create(WebArchive.class, "lada-basis-test.war")
+        logger.info("Create and deploy: " + ARCHIVE_NAME);
+        WebArchive archive = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME)
             .addPackages(true, Package.getPackage("de.intevation.lada"))
             .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");
+        return archive;
     }
 
     /**
@@ -74,6 +88,11 @@
     public final void testA_GetServices(@ArquillianResource URL baseUrl)
     throws Exception {
         this.get.test(baseUrl);
+        logger.info("---------- Testprotocol -----------");
+        testProtocol.addAll(this.get.getProtocol());
+        for (Protocol p : testProtocol) {
+            logger.info(p.toString(verboseLogging));
+        }
     }
 
     /**
@@ -84,6 +103,10 @@
     public final void testB_CreateServices(@ArquillianResource URL baseUrl)
     throws Exception {
         this.create.test(baseUrl);
+        testProtocol.addAll(this.create.getProtocol());
+        for (Protocol p : testProtocol) {
+            logger.info(p.toString(verboseLogging));
+        }
     }
 
     /**
@@ -98,6 +121,10 @@
             baseUrl,
             this.create.getCreatedProbeId(),
             this.create.getCreatedMessungId());
+        testProtocol.addAll(this.update.getProtocol());
+        for (Protocol p : testProtocol) {
+            logger.info(p.toString(verboseLogging));
+        }
     }
 
     /**
@@ -112,5 +139,9 @@
             baseUrl,
             this.create.getCreatedProbeId(),
             this.create.getCreatedMessungId());
+        testProtocol.addAll(this.delete.getProtocol());
+        for (Protocol p : testProtocol) {
+            logger.info(p.toString(verboseLogging));
+        }
     }
 }
diff -r 9be4f6f7c050 -r f6b206b2bdac src/test/java/de/intevation/lada/test/CreateTests.java
--- a/src/test/java/de/intevation/lada/test/CreateTests.java	Tue Feb 17 13:40:28 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/CreateTests.java	Tue Feb 17 13:42:48 2015 +0100
@@ -9,6 +9,8 @@
 
 import java.io.StringReader;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.json.Json;
 import javax.json.JsonException;
@@ -23,6 +25,8 @@
 
 import org.junit.Assert;
 
+import de.intevation.lada.Protocol;
+
 /**
  * Class to test all CREATE services.
  *
@@ -50,6 +54,8 @@
     private static Integer createdProbeId;
     private static Integer createdMessungId;
 
+    private List<Protocol> protocol;
+
     public Integer getCreatedProbeId() {
         return createdProbeId;
     }
@@ -59,12 +65,19 @@
     }
 
     /**
+     * @return the protocol
+     */
+    public List<Protocol> getProtocol() {
+        return protocol;
+    }
+
+    /**
      * 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:");
+        protocol = new ArrayList<Protocol>();
         probeCreateService(baseUrl);
         messungCreateService(baseUrl);
     }
@@ -76,7 +89,12 @@
      */
     private final void probeCreateService(URL baseUrl)
     throws Exception {
-        System.out.println("Testing ProbeService: ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("ProbeService");
+        prot.setType("create");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
@@ -92,14 +110,18 @@
             /* Save the probeid*/
             createdProbeId =
                 content.getJsonObject("data").getJsonNumber("id").intValue();
+            prot.addInfo("probeId", createdProbeId);
             /* Verify the response*/
             Assert.assertTrue(content.getBoolean("success"));
+            prot.addInfo("success", content.getBoolean("success"));
             Assert.assertEquals("200", content.getString("message"));
+            prot.addInfo("messung", content.getString("message"));
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
     /**
@@ -109,7 +131,12 @@
      */
     private final void messungCreateService(URL baseUrl)
     throws Exception {
-        System.out.println("Testing MessungService: ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("MessungService");
+        prot.setType("create");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
@@ -126,13 +153,17 @@
             /* Save the probeid*/
             createdMessungId =
                 content.getJsonObject("data").getJsonNumber("id").intValue();
+            prot.addInfo("messungId", createdMessungId);
             /* Verify the response*/
             Assert.assertTrue(content.getBoolean("success"));
+            prot.addInfo("success", content.getBoolean("success"));
             Assert.assertEquals("200", content.getString("message"));
+            prot.addInfo("messung", content.getString("message"));
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 }
diff -r 9be4f6f7c050 -r f6b206b2bdac src/test/java/de/intevation/lada/test/DeleteTests.java
--- a/src/test/java/de/intevation/lada/test/DeleteTests.java	Tue Feb 17 13:40:28 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/DeleteTests.java	Tue Feb 17 13:42:48 2015 +0100
@@ -9,6 +9,8 @@
 
 import java.io.StringReader;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.json.Json;
 import javax.json.JsonException;
@@ -21,6 +23,8 @@
 
 import org.junit.Assert;
 
+import de.intevation.lada.Protocol;
+
 /**
  * Class to test all DELETE services.
  *
@@ -28,11 +32,20 @@
  */
 public class DeleteTests {
 
+    private static List<Protocol> protocol;
+
     private Integer probeId;
 
     private Integer messungId;
 
     /**
+     * @return the protocol
+     */
+    public static List<Protocol> getProtocol() {
+        return protocol;
+    }
+
+    /**
      * Main entry point in this class to start the tests.
      *
      * @param baseUrl The url pointing to the test deployment.
@@ -42,7 +55,7 @@
         Integer probeId,
         Integer messungId)
     throws Exception {
-        System.out.println("\nStarting test on DELETE Services:");
+        protocol = new ArrayList<Protocol>();
         this.probeId = probeId;
         this.messungId = messungId;
         messungDeleteService(baseUrl);
@@ -55,12 +68,18 @@
      * @param baseUrl The url pointing to the test deployment.
      */
     private final void probeDeleteService(URL baseUrl) {
-        System.out.println("Testing delete: ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("ProbeService");
+        prot.setType("delete");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
             WebTarget target =
                 client.target(baseUrl + "probe/" + this.probeId);
+            prot.addInfo("probeId", this.probeId);
             /* Delete a probe with the id saved when created a probe*/
             Response response = target.request().delete();
             String entity = response.readEntity(String.class);
@@ -69,12 +88,16 @@
             JsonObject respObj = reader.readObject();
             /* Verify the response*/
             Assert.assertTrue(respObj.getBoolean("success"));
+            prot.addInfo("success", respObj.getBoolean("success"));
             Assert.assertEquals("200", respObj.getString("message"));
+            prot.addInfo("message", respObj.getString("message"));
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
+        System.out.print("\n");
     }
 
     /**
@@ -83,12 +106,18 @@
      * @param baseUrl The url pointing to the test deployment.
      */
     private final void messungDeleteService(URL baseUrl) {
-        System.out.println("Testing Messung: ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("MessungService");
+        prot.setType("delete");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
             WebTarget target =
                 client.target(baseUrl + "messung/" + this.messungId);
+            prot.addInfo("messungId", this.messungId);
             /* Delete a probe with the id saved when created a probe*/
             Response response = target.request().delete();
             String entity = response.readEntity(String.class);
@@ -97,11 +126,15 @@
             JsonObject respObj = reader.readObject();
             /* Verify the response*/
             Assert.assertTrue(respObj.getBoolean("success"));
+            prot.addInfo("success", respObj.getBoolean("success"));
             Assert.assertEquals("200", respObj.getString("message"));
+            prot.addInfo("message", respObj.getString("message"));
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
+
 }
diff -r 9be4f6f7c050 -r f6b206b2bdac src/test/java/de/intevation/lada/test/GetTests.java
--- a/src/test/java/de/intevation/lada/test/GetTests.java	Tue Feb 17 13:40:28 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/GetTests.java	Tue Feb 17 13:42:48 2015 +0100
@@ -9,6 +9,8 @@
 
 import java.io.StringReader;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.json.Json;
 import javax.json.JsonException;
@@ -21,6 +23,8 @@
 
 import org.junit.Assert;
 
+import de.intevation.lada.Protocol;
+
 /**
  * Class to test all GET services.
  *
@@ -28,6 +32,8 @@
  */
 public class GetTests {
 
+    private static List<Protocol> protocol;
+
     private static final String COMPARE_PROBE =
         "{\"id\":1,\"baId\":\"1\",\"datenbasisId\":2," +
         "\"letzteAenderung\":1339570306000,\"media\":\"Trinkwasser " +
@@ -47,13 +53,22 @@
         "\"G1\",\"probeId\":575,\"nebenprobenNr\":\"01G1\",\"geplant\":true," +
         "\"messungsIdAlt\":1}";
 
+    private static final String COMPARE_KOMMENTARP = "";
+
+    /**
+     * @return the protocol
+     */
+    public static List<Protocol> getProtocol() {
+        return protocol;
+    }
+
     /**
      * 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:");
+        protocol = new ArrayList<Protocol>();
         queryGetService(baseUrl);
         probeGetAllService(baseUrl);
         probeGetByIdService(baseUrl);
@@ -61,6 +76,8 @@
         messungGetAllService(baseUrl);
         messungGetByIdService(baseUrl);
         messungFilterService(baseUrl);
+        pkommentarGetAllService(baseUrl);
+        //pkommentarGetByIdService(baseUrl);
     }
 
     /**
@@ -70,7 +87,12 @@
      */
     private final void queryGetService(URL baseUrl)
     throws Exception {
-        System.out.println("Testing QueryService: ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("QueryService");
+        prot.setType("get all");
+        prot.setPassed(false);
+        protocol.add(prot);
         /* Create a client*/
         Client client = ClientBuilder.newClient();
         WebTarget target = client.target(baseUrl + "query");
@@ -83,13 +105,17 @@
             JsonObject content = reader.readObject();
             /* Verfiy the response*/
             Assert.assertTrue(content.getBoolean("success"));
+            prot.addInfo("success", content.getBoolean("success"));
             Assert.assertEquals("200", content.getString("message"));
+            prot.addInfo("message", content.getString("message"));
             Assert.assertNotNull(content.getJsonArray("data"));
+            prot.addInfo("objects", content.getJsonArray("data").size());
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
     /**
@@ -99,7 +125,12 @@
      */
     private final void probeGetAllService(URL baseUrl)
     throws Exception {
-        System.out.println("Testing ProbeService (All): ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("ProbeService");
+        prot.setType("get all");
+        prot.setPassed(false);
+        protocol.add(prot);
         /* Create a client*/
         Client client = ClientBuilder.newClient();
         WebTarget target = client.target(baseUrl + "probe");
@@ -112,12 +143,17 @@
             JsonObject content = reader.readObject();
             /* Verify the response*/
             Assert.assertTrue(content.getBoolean("success"));
+            prot.addInfo("success", content.getBoolean("success"));
             Assert.assertEquals("200", content.getString("message"));
+            prot.addInfo("message", content.getString("message"));
+            Assert.assertNotNull(content.getJsonArray("data"));
+            prot.addInfo("objects", content.getJsonArray("data").size());
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
     /**
@@ -127,7 +163,12 @@
      */
     private final void probeGetByIdService(URL baseUrl)
     throws Exception {
-        System.out.println("Testing ProbeService (byId): ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("ProbeService");
+        prot.setType("get by Id");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a json object from static probe string*/
             JsonReader fromStringRreader =
@@ -136,6 +177,7 @@
             /* Create a client*/
             Client client = ClientBuilder.newClient();
             WebTarget target = client.target(baseUrl + "probe/1");
+            prot.addInfo("probeId", 1);
             /* Request a probe object by id*/
             Response response = target.request().get();
             String entity = response.readEntity(String.class);
@@ -145,14 +187,18 @@
             JsonObject content = fromServiceReader.readObject();
             /* Verify the response*/
             Assert.assertTrue(content.getBoolean("success"));
+            prot.addInfo("success", content.getBoolean("success"));
             Assert.assertEquals("200", content.getString("message"));
+            prot.addInfo("message", content.getString("message"));
             Assert.assertEquals(staticProbe,
                 content.getJsonObject("data"));
+            prot.addInfo("object", "equals");
         }
         catch(JsonException je) {
+            prot.addInfo("exception",je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
     /**
@@ -161,12 +207,18 @@
      * @param baseUrl The url poining to the test deployment.
      */
     private final void probeFilterService(URL baseUrl) {
-        System.out.println("Testing ProbeService (filter): ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("ProbeService");
+        prot.setType("get by filter");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
             WebTarget target =
                 client.target(baseUrl + "probe?qid=2&mst_id=11010&umw_id=N24");
+            prot.addInfo("filter", "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);
@@ -175,13 +227,17 @@
             JsonObject respObj = reader.readObject();
             /* Verify the response*/
             Assert.assertTrue(respObj.getBoolean("success"));
+            prot.addInfo("success", respObj.getBoolean("success"));
             Assert.assertEquals("200", respObj.getString("message"));
+            prot.addInfo("message", respObj.getString("message"));
             Assert.assertNotNull(respObj.getJsonArray("data"));
+            prot.addInfo("objects", respObj.getJsonArray("data").size());
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
 
@@ -192,7 +248,12 @@
      */
     private final void messungGetAllService(URL baseUrl)
     throws Exception {
-        System.out.println("Testing MessungService (All): ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("MessungService");
+        prot.setType("get all");
+        prot.setPassed(false);
+        protocol.add(prot);
         /* Create a client*/
         Client client = ClientBuilder.newClient();
         WebTarget target = client.target(baseUrl + "messung");
@@ -205,12 +266,17 @@
             JsonObject content = reader.readObject();
             /* Verify the response*/
             Assert.assertTrue(content.getBoolean("success"));
+            prot.addInfo("success", content.getBoolean("success"));
             Assert.assertEquals("200", content.getString("message"));
+            prot.addInfo("message", content.getString("message"));
+            Assert.assertNotNull(content.getJsonArray("data"));
+            prot.addInfo("objects", content.getJsonArray("data").size());
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
     /**
@@ -220,7 +286,12 @@
      */
     private final void messungGetByIdService(URL baseUrl)
     throws Exception {
-        System.out.println("Testing MessungService (byId): ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("MessungService");
+        prot.setType("get by Id");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a json object from static messung string*/
             JsonReader fromStringRreader =
@@ -229,6 +300,7 @@
             /* Create a client*/
             Client client = ClientBuilder.newClient();
             WebTarget target = client.target(baseUrl + "messung/1");
+            prot.addInfo("messungId", 1);
             /* Request a probe object by id*/
             Response response = target.request().get();
             String entity = response.readEntity(String.class);
@@ -238,14 +310,18 @@
             JsonObject content = fromServiceReader.readObject();
             /* Verify the response*/
             Assert.assertTrue(content.getBoolean("success"));
+            prot.addInfo("success", content.getBoolean("success"));
             Assert.assertEquals("200", content.getString("message"));
+            prot.addInfo("message", content.getString("message"));
             Assert.assertEquals(staticMessung,
                 content.getJsonObject("data"));
+            prot.addInfo("object", "equals");
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
     /**
@@ -254,12 +330,18 @@
      * @param baseUrl The url poining to the test deployment.
      */
     private final void messungFilterService(URL baseUrl) {
-        System.out.println("Testing MessungService (filter): ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("MessungService");
+        prot.setType("get by filter");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
             WebTarget target =
                 client.target(baseUrl + "messung?probeId=1");
+            prot.addInfo("filter", "probeId=1");
             /* Request the probe objects using the filter*/
             Response response = target.request().get();
             String entity = response.readEntity(String.class);
@@ -268,13 +350,17 @@
             JsonObject respObj = reader.readObject();
             /* Verify the response*/
             Assert.assertTrue(respObj.getBoolean("success"));
+            prot.addInfo("success", respObj.getBoolean("success"));
             Assert.assertEquals("200", respObj.getString("message"));
+            prot.addInfo("message", respObj.getString("message"));
             Assert.assertNotNull(respObj.getJsonArray("data"));
+            prot.addInfo("objects", respObj.getJsonArray("data").size());
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
 }
diff -r 9be4f6f7c050 -r f6b206b2bdac src/test/java/de/intevation/lada/test/UpdateTests.java
--- a/src/test/java/de/intevation/lada/test/UpdateTests.java	Tue Feb 17 13:40:28 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/UpdateTests.java	Tue Feb 17 13:42:48 2015 +0100
@@ -9,6 +9,8 @@
 
 import java.io.StringReader;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.json.Json;
 import javax.json.JsonException;
@@ -23,6 +25,8 @@
 
 import org.junit.Assert;
 
+import de.intevation.lada.Protocol;
+
 /**
  * Class to test all UPDATE services.
  *
@@ -30,18 +34,27 @@
  */
 public class UpdateTests {
 
+    private static List<Protocol> protocol;
+
     private Integer probeId;
 
     private Integer messungId;
 
     /**
+     * @return the protocol
+     */
+    public static List<Protocol> getProtocol() {
+        return protocol;
+    }
+
+    /**
      * 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:");
+        protocol = new ArrayList<Protocol>();
         this.probeId = probeId;
         this.messungId = messungId;
         probeUpdateService(baseUrl);
@@ -55,12 +68,18 @@
      */
     private final void probeUpdateService(URL baseUrl)
     throws Exception {
-        System.out.println("Testing ProbeService: ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("ProbeService");
+        prot.setType("update");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
             WebTarget target =
                 client.target(baseUrl + "probe/" + this.probeId);
+            prot.addInfo("probeId", this.probeId);
             /* Request a probe with the id saved when created a probe*/
             Response response = target.request().get();
             String entity = response.readEntity(String.class);
@@ -70,6 +89,9 @@
             /* Change the hauptprobenNr*/
             String updatedEntity =
                 oldProbe.toString().replace("1234567890", "2345678901");
+            prot.addInfo("updated datafield", "hauptprobenNr");
+            prot.addInfo("updated value", "1234567890");
+            prot.addInfo("updated to", "1234567890");
             /* Send the updated probe via put reauest*/
             WebTarget putTarget = client.target(baseUrl + "probe");
             Response updated = putTarget.request().put(
@@ -80,14 +102,17 @@
             JsonObject updatedProbe = updatedReader.readObject();
             /* Verify the response*/
             Assert.assertTrue(updatedProbe.getBoolean("success"));
+            prot.addInfo("success", updatedProbe.getBoolean("success"));
             Assert.assertEquals("200", updatedProbe.getString("message"));
+            prot.addInfo("message", updatedProbe.getString("message"));
             Assert.assertEquals("2345678901",
                 updatedProbe.getJsonObject("data").getString("hauptprobenNr"));
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
     /**
@@ -97,21 +122,30 @@
      */
     private final void messungUpdate(URL baseUrl)
     throws Exception {
-        System.out.println("Testing MessungService: ");
+        System.out.print(".");
+        Protocol prot = new Protocol();
+        prot.setName("ProbeService");
+        prot.setType("update");
+        prot.setPassed(false);
+        protocol.add(prot);
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
             WebTarget target =
                 client.target(baseUrl + "messung/" + this.messungId);
+            prot.addInfo("messungId", 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");
+            JsonObject oldMessung = reader.readObject().getJsonObject("data");
             /* Change the hauptprobenNr*/
             String updatedEntity =
-                oldProbe.toString().replace("A4", "G1");
+                oldMessung.toString().replace("A4", "G1");
+            prot.addInfo("updated field", "mmtId");
+            prot.addInfo("updated value", "A4");
+            prot.addInfo("updated to", "G1");
             /* Send the updated probe via put reauest*/
             WebTarget putTarget = client.target(baseUrl + "messung");
             Response updated = putTarget.request().put(
@@ -119,17 +153,20 @@
             /* Try to parse the response*/
             JsonReader updatedReader = Json.createReader(
                 new StringReader(updated.readEntity(String.class)));
-            JsonObject updatedProbe = updatedReader.readObject();
+            JsonObject updatedMessung = updatedReader.readObject();
             /* Verify the response*/
-            Assert.assertTrue(updatedProbe.getBoolean("success"));
-            Assert.assertEquals("200", updatedProbe.getString("message"));
+            Assert.assertTrue(updatedMessung.getBoolean("success"));
+            prot.addInfo("success", updatedMessung.getBoolean("success"));
+            Assert.assertEquals("200", updatedMessung.getString("message"));
+            prot.addInfo("message", updatedMessung.getString("message"));
             Assert.assertEquals("G1",
-                updatedProbe.getJsonObject("data").getString("mmtId"));
+                updatedMessung.getJsonObject("data").getString("mmtId"));
         }
         catch(JsonException je) {
+            prot.addInfo("exception", je.getMessage());
             Assert.fail(je.getMessage());
         }
-        System.out.println("passed");
+        prot.setPassed(true);
     }
 
 }
diff -r 9be4f6f7c050 -r f6b206b2bdac src/test/resources/log4j.properties
--- a/src/test/resources/log4j.properties	Tue Feb 17 13:40:28 2015 +0100
+++ b/src/test/resources/log4j.properties	Tue Feb 17 13:42:48 2015 +0100
@@ -1,8 +1,10 @@
-log4j.rootLogger=DEBUG, lada
+log4j.rootLogger=INFO, lada
+log4j.logger.org.apache.http=INFO
+log4j.logger.org.xnio=WARN
 log4j.logger.org.hibernate=INFO
 log4j.appender.lada=org.apache.log4j.RollingFileAppender
 log4j.appender.lada.File=../log/lada-server-test.log
 log4j.appender.lada.MaxFileSize=5MB
 log4j.appender.lada.MaxBackupIndex=5
 log4j.appender.lada.layout=org.apache.log4j.PatternLayout
-log4j.appender.lada.layout.ConversionPattern=%d %p %l: %m%n
+log4j.appender.lada.layout.ConversionPattern=%d: %m%n


More information about the Lada-commits mailing list