changeset 274:2a8d816610c4

REST get test, check if the right (message 200) answer is given. For this use specific probeId and messungsId. Add a test for get findbyid proben.
author Ludwig Reiter <ludwig@intevation.de>
date Fri, 26 Jul 2013 12:23:18 +0200
parents cd78ec2f7d76
children 758a12cd0dd5
files src/main/java/de/intevation/lada/test/RestEasyClient.java
diffstat 1 files changed, 20 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/test/RestEasyClient.java	Thu Jul 25 15:50:42 2013 +0200
+++ b/src/main/java/de/intevation/lada/test/RestEasyClient.java	Fri Jul 26 12:23:18 2013 +0200
@@ -9,27 +9,7 @@
 public class RestEasyClient {
 
 	public static String baseURL = "https://bfs-lada.intevation.de/lada/server/rest/";
-/*	
-	@Test
-	public void test2() {
-		String url = "https://bfs-lada.intevation.de/lada/server/rest/proben?mstId=06010&umwId=N24";
-		ClientRequest request = new ClientRequest(url);
-		request.header("Authorization", "Basic dGVzdGVpbnM6TjVKOENmSm5iOA==");
-		request.accept(MediaType.WILDCARD_TYPE);
-		
-		ClientResponse<String> response;
-		boolean get_error = false;
-		try {
-			response = request.get(String.class);
-			Assert.assertEquals(200,response.getStatus());
-			System.out.println(response.getEntity(String.class));
-		} catch (Exception e) {
-			get_error = true;
-			e.printStackTrace();
-		}
-		Assert.assertEquals(false, get_error);
-	}
-*/
+
 public ClientResponse<String> getResponse(String url, boolean header){
 	ClientRequest request = new ClientRequest(url);
 	if(header)
@@ -44,10 +24,15 @@
 	return response;
 }
 
+public void checkResponse(ClientResponse<String> response){
+	Assert.assertEquals(true, response.getEntity().contains("\"message\":\"200\""));
+}
+
 public void testHttpOK(String url) {
 	ClientResponse<String> response = getResponse(url, true);
 	Assert.assertNotNull("Response shouldnot be null", response);
 	Assert.assertEquals(200, response.getStatus());
+	checkResponse(response);
 }
 
 public void testHttpForbidden(String url) {
@@ -58,27 +43,27 @@
 
 @Test
 public void testLOrtService(){
-	testHttpOK(baseURL + "ort");
+	testHttpOK(baseURL + "ort?probeId=000007587685X");
 	testHttpForbidden(baseURL + "ort");
 }
 @Test
 public void testLMessKommentarService() {
-	testHttpOK(baseURL + "messkommentare");
+	testHttpOK(baseURL + "messkommentare?probeId=000007587685X&messungsId=1");
 	testHttpForbidden(baseURL + "messkommentare");
 }
 @Test
 public void testLKommentarService() {
-	testHttpOK(baseURL + "kommentare");
+	testHttpOK(baseURL + "kommentare?probeId=000007587685X");
 	testHttpForbidden(baseURL + "kommentare");
 }
 @Test
 public void testMessungService() {
-	testHttpOK(baseURL + "messung");
+	testHttpOK(baseURL + "messung?probeId=000007587685X");
 	testHttpForbidden(baseURL + "messung");
 }
 @Test
 public void testLMesswertService() {
-	testHttpOK(baseURL + "messwert");
+	testHttpOK(baseURL + "messwert?probeId=000007587685X&messungsId=1");
 	testHttpForbidden(baseURL + "messwert");
 }
 @Test
@@ -88,13 +73,20 @@
 }
 @Test
 public void testLStatusService() {
-	testHttpOK(baseURL + "status");
+	testHttpOK(baseURL + "status?probeId=000007587685X&messungsId=1");
 	testHttpForbidden(baseURL + "status");
 }
 @Test
 public void testLZusatzwertService() {
-	testHttpOK(baseURL + "zusatzwert");
+	testHttpOK(baseURL + "zusatzwert?probeId=000007587685X");
 	testHttpForbidden(baseURL + "zusatzwert");
 }
+@Test
+public void testLProbenSfindByID() {
+	ClientResponse<String> response = getResponse(baseURL + "proben/000007587685X", true);
+	Assert.assertNotNull(response);
+	Assert.assertEquals(200, response.getStatus());
+	checkResponse(response);
+}
 
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)