annotate src/test/java/de/intevation/lada/test/ServiceTest.java @ 1239:59bdb52bac1c

Test output latitude and longitude against input geometry.
author Tom Gottfried <tom@intevation.de>
date Tue, 13 Dec 2016 20:34:36 +0100
parents 186d602e031a
children 95d04f56266d
rev   line source
849
d0a591b3eade Added missing file header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
d0a591b3eade Added missing file header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
2 * Software engineering by Intevation GmbH
d0a591b3eade Added missing file header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
3 *
d0a591b3eade Added missing file header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
d0a591b3eade Added missing file header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
d0a591b3eade Added missing file header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
d0a591b3eade Added missing file header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
7 */
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 package de.intevation.lada.test;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 import java.io.InputStream;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import java.io.StringReader;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 import java.net.URL;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 import java.sql.Timestamp;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import java.util.List;
1239
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
15 import java.util.ArrayList;
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import java.util.Map.Entry;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import java.util.Scanner;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 import javax.json.Json;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 import javax.json.JsonException;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 import javax.json.JsonObject;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 import javax.json.JsonObjectBuilder;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 import javax.json.JsonReader;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 import javax.json.JsonValue;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 import javax.ws.rs.client.Client;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 import javax.ws.rs.client.ClientBuilder;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 import javax.ws.rs.client.Entity;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 import javax.ws.rs.client.WebTarget;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 import javax.ws.rs.core.MediaType;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 import javax.ws.rs.core.Response;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 import org.apache.commons.lang.WordUtils;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 import org.junit.Assert;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34
1239
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
35 import com.vividsolutions.jts.io.ParseException;
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
36 import com.vividsolutions.jts.io.WKTReader;
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
37 import com.vividsolutions.jts.geom.Geometry;
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
38 import com.vividsolutions.jts.geom.Point;
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
39
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 import de.intevation.lada.BaseTest;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 import de.intevation.lada.Protocol;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 import de.intevation.lada.test.land.ProbeTest;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 public class ServiceTest {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45
1239
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
46 private static final String LAT_KEY = "latitude";
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
47 private static final String LONG_KEY = "longitude";
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
48
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 protected List<Protocol> protocol;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 protected List<String> timestampAttributes;
1239
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
52 protected List<String> geomPointAttributes = new ArrayList<String>();
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 protected URL baseUrl;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 public void init(URL baseUrl, List<Protocol> protocol) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 this.baseUrl = baseUrl;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 this.protocol = protocol;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 /**
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 * @return The test protocol
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 */
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 public List<Protocol> getProtocol() {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 return protocol;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 protected JsonObject readJsonResource(String resource) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 InputStream stream =
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 ProbeTest.class.getResourceAsStream(resource);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 Scanner scanner = new Scanner(stream, "UTF-8");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 scanner.useDelimiter("\\A");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 String raw = scanner.next();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 scanner.close();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 JsonReader reader = Json.createReader(new StringReader(raw));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 JsonObject content = reader.readObject();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 reader.close();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 return content;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 protected JsonObjectBuilder convertObject(JsonObject object) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 JsonObjectBuilder builder = Json.createObjectBuilder();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 for (Entry<String, JsonValue> entry : object.entrySet()) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 String key = WordUtils.capitalize(
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 entry.getKey(), new char[]{'_'}).replaceAll("_","");
1239
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
86 key = key.replaceFirst(
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
87 key.substring(0, 1), key.substring(0, 1).toLowerCase());
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 if (timestampAttributes.contains(key)) {
1239
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
89 Timestamp timestamp = Timestamp.valueOf(
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
90 entry.getValue().toString().replaceAll("\"", ""));
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 builder.add(key, timestamp.getTime());
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 }
1239
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
93 else if (geomPointAttributes.contains(key)) {
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
94 // Convert EWKT to latitude and longitude
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
95 String wkt = entry.getValue().toString().split(";")[1];
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
96 try {
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
97 Geometry geom = new WKTReader().read(wkt);
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
98 if (!(geom instanceof Point)) {
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
99 throw new IllegalArgumentException(
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
100 "WKT does not represent a point");
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
101 }
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
102 Point point = (Point)geom;
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
103 builder.add(LONG_KEY, point.getX());
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
104 builder.add(LAT_KEY, point.getY());
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
105 } catch (ParseException | IllegalArgumentException e) {
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
106 Protocol prot = new Protocol();
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
107 prot.addInfo("exception", e.getMessage());
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
108 protocol.add(prot);
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
109 Assert.fail("Exception while parsing WKT '"
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
110 + wkt + "':\n"
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
111 + e.getMessage());
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
112 }
59bdb52bac1c Test output latitude and longitude against input geometry.
Tom Gottfried <tom@intevation.de>
parents: 1097
diff changeset
113 }
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 else {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 builder.add(key, entry.getValue());
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 return builder;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 public JsonObject getAll(String name, String parameter) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 System.out.print(".");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 Protocol prot = new Protocol();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 prot.setName(name + " service");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 prot.setType("get all");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 prot.setPassed(false);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 protocol.add(prot);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 /* Create a client*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 Client client = ClientBuilder.newClient();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 WebTarget target = client.target(baseUrl + parameter);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 /* Request all objects*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 Response response = target.request()
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 .header("X-SHIB-user", BaseTest.TEST_USER)
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 .header("X-SHIB-roles", BaseTest.TEST_ROLES)
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 .get();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 String entity = response.readEntity(String.class);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 try{
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 /* Try to parse the response*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 JsonReader reader = Json.createReader(new StringReader(entity));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 JsonObject content = reader.readObject();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 /* Verify the response*/
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
142 Assert.assertTrue("Unsuccessful response object:\n" + content,
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
143 content.getBoolean("success"));
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 prot.addInfo("success", content.getBoolean("success"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 Assert.assertEquals("200", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 prot.addInfo("message", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 Assert.assertNotNull(content.getJsonArray("data"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 prot.addInfo("objects", content.getJsonArray("data").size());
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 prot.setPassed(true);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 return content;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 catch(JsonException je) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 prot.addInfo("exception", je.getMessage());
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
154 Assert.fail("Exception while parsing '" + entity + "':\n"
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
155 + je.getMessage());
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 return null;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159 /**
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 * Test the GET Service by requesting a single object by id.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 *
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162 * @param baseUrl The url pointing to the test deployment.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 */
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 public JsonObject getById(
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 String name,
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 String parameter,
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 JsonObject expected
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 ) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 System.out.print(".");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170 Protocol prot = new Protocol();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171 prot.setName(name + " service");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 prot.setType("get by Id");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
173 prot.setPassed(false);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174 protocol.add(prot);
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
175 /* Create a client*/
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
176 Client client = ClientBuilder.newClient();
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
177 WebTarget target = client.target(baseUrl + parameter);
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
178 prot.addInfo("parameter", parameter);
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
179 /* Request a object by id*/
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
180 Response response = target.request()
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
181 .header("X-SHIB-user", BaseTest.TEST_USER)
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
182 .header("X-SHIB-roles", BaseTest.TEST_ROLES)
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
183 .get();
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
184 String entity = response.readEntity(String.class);
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
185 try {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
186 /* Try to parse the response*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
187 JsonReader fromServiceReader =
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
188 Json.createReader(new StringReader(entity));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
189 JsonObject content = fromServiceReader.readObject();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 /* Verify the response*/
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
191 Assert.assertTrue("Unsuccessful response object:\n" + content,
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
192 content.getBoolean("success"));
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
193 prot.addInfo("success", content.getBoolean("success"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
194 Assert.assertEquals("200", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
195 prot.addInfo("message", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
196 Assert.assertFalse(content.getJsonObject("data").isEmpty());
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
197 JsonObject object = content.getJsonObject("data");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198 for (Entry<String, JsonValue> entry : expected.entrySet()) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199 if (entry.getKey().equals("parentModified") ||
1097
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 973
diff changeset
200 entry.getKey().equals("treeModified") ||
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 973
diff changeset
201 entry.getKey().equals("letzteAenderung")) {
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
202 continue;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
203 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
204 Assert.assertEquals(entry.getValue(), object.get(entry.getKey()));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
205 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 prot.addInfo("object", "equals");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
207 prot.setPassed(true);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
208 return content;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
209 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
210 catch(JsonException je) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
211 prot.addInfo("exception",je.getMessage());
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
212 Assert.fail("Exception while parsing '" + entity + "':\n"
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
213 + je.getMessage());
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
214 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
215 return null;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
216 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
217
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
218 /**
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
219 * Test the GET service using filters.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
220 *
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 * @param baseUrl The url poining to the test deployment.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222 */
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
223 public JsonObject filter(String name, String parameter) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 System.out.print(".");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225 Protocol prot = new Protocol();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226 prot.setName(name + " service");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 prot.setType("filter");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228 prot.setPassed(false);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 protocol.add(prot);
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
230 /* Create a client*/
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
231 Client client = ClientBuilder.newClient();
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
232 WebTarget target =
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
233 client.target(baseUrl + parameter);//"probe?qid=2&mst_id=11010&umw_id=N24");
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
234 prot.addInfo("filter", parameter);//"qid=2&mst_id=11010&umw_id=N24");
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
235 /* Request the objects using the filter*/
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
236 Response response = target.request()
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
237 .header("X-SHIB-user", BaseTest.TEST_USER)
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
238 .header("X-SHIB-roles", BaseTest.TEST_ROLES)
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
239 .get();
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
240 String entity = response.readEntity(String.class);
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241 try {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
242 /* Try to parse the response*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
243 JsonReader reader = Json.createReader(new StringReader(entity));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
244 JsonObject content = reader.readObject();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
245 /* Verify the response*/
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
246 Assert.assertTrue("Unsuccessful response object:\n" + content,
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
247 content.getBoolean("success"));
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 prot.addInfo("success", content.getBoolean("success"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
249 Assert.assertEquals("200", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
250 prot.addInfo("message", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
251 Assert.assertNotNull(content.getJsonArray("data"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
252 prot.addInfo("objects", content.getJsonArray("data").size());
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
253 prot.setPassed(true);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
254 return content;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
255 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
256 catch(JsonException je) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 prot.addInfo("exception", je.getMessage());
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
258 Assert.fail("Exception while parsing '" + entity + "':\n"
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
259 + je.getMessage());
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
260 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
261 return null;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
262 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
263
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264 /**
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
265 * Test the CREATE Service.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
266 *
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 * @param baseUrl The url pointing to the test deployment.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
268 */
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
269 public JsonObject create(String name, String parameter, JsonObject create) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
270 System.out.print(".");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
271 Protocol prot = new Protocol();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
272 prot.setName(name + " service");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
273 prot.setType("create");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
274 prot.setPassed(false);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
275 protocol.add(prot);
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
276 /* Create a client*/
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
277 Client client = ClientBuilder.newClient();
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
278 WebTarget target = client.target(baseUrl + parameter);
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
279 /* Send a post request containing a new probe*/
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
280 Response response = target.request()
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
281 .header("X-SHIB-user", BaseTest.TEST_USER)
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
282 .header("X-SHIB-roles", BaseTest.TEST_ROLES)
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
283 .post(Entity.entity(create.toString(), MediaType.APPLICATION_JSON));
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
284 String entity = response.readEntity(String.class);
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
285 try {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
286 /* Try to parse the response*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
287 JsonReader fromServiceReader =
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
288 Json.createReader(new StringReader(entity));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
289 JsonObject content = fromServiceReader.readObject();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
290 /* Verify the response*/
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
291 Assert.assertTrue("Unsuccessful response object:\n" + content,
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
292 content.getBoolean("success"));
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
293 prot.addInfo("success", content.getBoolean("success"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
294 Assert.assertEquals("200", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
295 prot.addInfo("message", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
296 prot.setPassed(true);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
297 return content;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
298 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
299 catch(JsonException je) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
300 prot.addInfo("exception", je.getMessage());
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
301 Assert.fail("Exception while parsing '" + entity + "':\n"
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
302 + je.getMessage());
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
303 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
304 return null;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
305 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
306
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
307 /**
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
308 * Test the probe update service.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
309 *
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
310 * @param baseUrl The url pointing to the test deployment.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
311 */
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
312 public JsonObject update(
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
313 String name,
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
314 String parameter,
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
315 String updateAttribute,
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
316 String oldValue,
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
317 String newValue
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
318 ) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
319 System.out.print(".");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
320 Protocol prot = new Protocol();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
321 prot.setName(name + " service");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
322 prot.setType("update");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
323 prot.setPassed(false);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
324 protocol.add(prot);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
325 try {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
326 /* Create a client*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
327 Client client = ClientBuilder.newClient();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
328 WebTarget target = client.target(baseUrl + parameter);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
329 /* Request a with the saved id*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
330 Response response = target.request()
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
331 .header("X-SHIB-user", BaseTest.TEST_USER)
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
332 .header("X-SHIB-roles", BaseTest.TEST_ROLES)
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
333 .get();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
334 String entity = response.readEntity(String.class);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
335 /* Try to parse the response*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
336 JsonReader reader = Json.createReader(new StringReader(entity));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
337 JsonObject oldObject = reader.readObject().getJsonObject("data");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
338 /* Change the hauptprobenNr*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
339 String updatedEntity =
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
340 oldObject.toString().replace(oldValue, newValue);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
341 prot.addInfo("updated datafield", updateAttribute);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
342 prot.addInfo("updated value", oldValue);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
343 prot.addInfo("updated to", newValue);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
344 /* Send the updated probe via put request*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
345 WebTarget putTarget = client.target(baseUrl + parameter);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
346 Response updated = putTarget.request()
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
347 .header("X-SHIB-user", BaseTest.TEST_USER)
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
348 .header("X-SHIB-roles", BaseTest.TEST_ROLES)
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
349 .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
350 /* Try to parse the response*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
351 JsonReader updatedReader = Json.createReader(
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
352 new StringReader(updated.readEntity(String.class)));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
353 JsonObject updatedObject = updatedReader.readObject();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
354 /* Verify the response*/
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
355 Assert.assertTrue("Unsuccessful response object:\n"
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
356 + updatedObject,
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
357 updatedObject.getBoolean("success"));
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
358 prot.addInfo("success", updatedObject.getBoolean("success"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
359 Assert.assertEquals("200", updatedObject.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
360 prot.addInfo("message", updatedObject.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
361 Assert.assertEquals(newValue,
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
362 updatedObject.getJsonObject("data").getString(updateAttribute));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
363 prot.setPassed(true);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
364 return updatedObject;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
365 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
366 catch(JsonException je) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
367 prot.addInfo("exception", je.getMessage());
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
368 Assert.fail(je.getMessage());
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
369 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
370 return null;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
371 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
372
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
373 /**
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
374 * Test the DELETE Service.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
375 *
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
376 * @param baseUrl The url pointing to the test deployment.
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
377 */
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
378 public JsonObject delete(String name, String parameter) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
379 System.out.print(".");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
380 Protocol prot = new Protocol();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
381 prot.setName(name + " service");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
382 prot.setType("delete");
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
383 prot.setPassed(false);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
384 protocol.add(prot);
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
385 /* Create a client*/
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
386 Client client = ClientBuilder.newClient();
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
387 WebTarget target =
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
388 client.target(baseUrl + parameter);
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
389 prot.addInfo("parameter", parameter);
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
390 /* Delete a probe with the id saved when created a probe*/
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
391 Response response = target.request()
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
392 .header("X-SHIB-user", BaseTest.TEST_USER)
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
393 .header("X-SHIB-roles", BaseTest.TEST_ROLES)
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
394 .delete();
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
395 String entity = response.readEntity(String.class);
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
396 try {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
397 /* Try to parse the response*/
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
398 JsonReader reader = Json.createReader(new StringReader(entity));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
399 JsonObject content = reader.readObject();
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
400 /* Verify the response*/
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
401 Assert.assertTrue("Unsuccessful response object:\n" + content,
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
402 content.getBoolean("success"));
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
403 prot.addInfo("success", content.getBoolean("success"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
404 Assert.assertEquals("200", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
405 prot.addInfo("message", content.getString("message"));
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
406 prot.setPassed(true);
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
407 return content;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
408 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
409 catch(JsonException je) {
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
410 prot.addInfo("exception", je.getMessage());
973
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
411 Assert.fail("Exception while parsing '" + entity + "':\n"
4b5f5e253cab Make tests more verbose on failure.
Tom Gottfried <tom@intevation.de>
parents: 851
diff changeset
412 + je.getMessage());
834
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
413 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
414 return null;
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
415 }
cb1cfc8c81ed Moved base class for tests to package 'test'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
416 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)