# HG changeset patch # User torsten # Date 1376035861 -7200 # Node ID 0701c6b6182dd35fee4b986dcca1acb6ec2b4dd1 # Parent 0d3966077415ba708b174f7acbbd7c34c6dcf213 Fixed indention diff -r 0d3966077415 -r 0701c6b6182d src/main/java/de/intevation/lada/test/RestEasyClient.java --- a/src/main/java/de/intevation/lada/test/RestEasyClient.java Fri Aug 09 10:10:43 2013 +0200 +++ b/src/main/java/de/intevation/lada/test/RestEasyClient.java Fri Aug 09 10:11:01 2013 +0200 @@ -8,102 +8,102 @@ public class RestEasyClient { -public static String baseURL = "https://bfs-lada.intevation.de/lada/server/rest/"; - -public ClientResponse getResponse(String url, boolean header){ - ClientRequest request = new ClientRequest(url); - if(header) - request.header("Authorization", "Basic dGVzdGVpbnM6TjVKOENmSm5iOA=="); - ClientResponse response = null; - try { - response = request.get(String.class); - } - catch(Exception e) { - e.printStackTrace(); - } - return response; -} - -public void checkResponse(ClientResponse response){ - Assert.assertEquals(true, response.getEntity().contains("\"message\":\"200\"")); -} + public static String baseURL = "https://bfs-lada.intevation.de/lada/server/rest/"; -public void testHttpOK(String url) { - ClientResponse response = getResponse(url, true); - Assert.assertNotNull("Response shouldnot be null", response); - Assert.assertEquals(200, response.getStatus()); - checkResponse(response); -} - -public void testHttpForbidden(String url) { - ClientResponse response = getResponse(url, false); - Assert.assertNotNull("Response shouldnot be null", response); - Assert.assertEquals(401, response.getStatus()); -} + public ClientResponse getResponse(String url, boolean header){ + ClientRequest request = new ClientRequest(url); + if(header) + request.header("Authorization", "Basic dGVzdGVpbnM6TjVKOENmSm5iOA=="); + ClientResponse response = null; + try { + response = request.get(String.class); + } + catch(Exception e) { + e.printStackTrace(); + } + return response; + } -@Test -public void testLOrtService(){ - testHttpOK(baseURL + "ort?probeId=000007587685X"); - testHttpForbidden(baseURL + "ort"); - ClientResponse response = getResponse(baseURL + "ort/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); -} -@Test -public void testLMessKommentarService() { - testHttpOK(baseURL + "messkommentare?probeId=000007587685X&messungsId=1"); - testHttpForbidden(baseURL + "messkommentare"); - ClientResponse response = getResponse(baseURL + "messkommentare/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); + public void checkResponse(ClientResponse response){ + Assert.assertEquals(true, response.getEntity().contains("\"message\":\"200\"")); + } + + public void testHttpOK(String url) { + ClientResponse response = getResponse(url, true); + Assert.assertNotNull("Response shouldnot be null", response); + Assert.assertEquals(200, response.getStatus()); + checkResponse(response); + } + + public void testHttpForbidden(String url) { + ClientResponse response = getResponse(url, false); + Assert.assertNotNull("Response shouldnot be null", response); + Assert.assertEquals(401, response.getStatus()); + } + + @Test + public void testLOrtService(){ + testHttpOK(baseURL + "ort?probeId=000007587685X"); + testHttpForbidden(baseURL + "ort"); + ClientResponse response = getResponse(baseURL + "ort/000007587685X", true); + Assert.assertNotNull(response); + Assert.assertEquals(404, response.getStatus()); + } + @Test + public void testLMessKommentarService() { + testHttpOK(baseURL + "messkommentare?probeId=000007587685X&messungsId=1"); + testHttpForbidden(baseURL + "messkommentare"); + ClientResponse response = getResponse(baseURL + "messkommentare/000007587685X", true); + Assert.assertNotNull(response); + Assert.assertEquals(404, response.getStatus()); + } + @Test + public void testLKommentarService() { + testHttpOK(baseURL + "kommentare?probeId=000007587685X"); + testHttpForbidden(baseURL + "kommentare"); + ClientResponse response = getResponse(baseURL + "kommentare/000007587685X", true); + Assert.assertNotNull(response); + Assert.assertEquals(404, response.getStatus()); + } + @Test + public void testMessungService() { + testHttpOK(baseURL + "messung?probeId=000007587685X"); + testHttpForbidden(baseURL + "messung"); + ClientResponse response = getResponse(baseURL + "messung/000007587685X", true); + Assert.assertNotNull(response); + Assert.assertEquals(404, response.getStatus()); + } + @Test + public void testLMesswertService() { + testHttpOK(baseURL + "messwert?probeId=000007587685X&messungsId=1"); + testHttpForbidden(baseURL + "messwert"); + ClientResponse response = getResponse(baseURL + "messungwert/000007587685X", true); + Assert.assertNotNull(response); + Assert.assertEquals(404, response.getStatus()); + } + @Test + public void testLProbenService() { + testHttpOK(baseURL + "proben?mstId=06010&umwId=N24"); + testHttpForbidden(baseURL + "proben?mstId=06010&umwId=N24"); + ClientResponse response = getResponse(baseURL + "proben/000007587685X", true); + Assert.assertNotNull(response); + Assert.assertEquals(200, response.getStatus()); + checkResponse(response); + } + @Test + public void testLStatusService() { + testHttpOK(baseURL + "status?probeId=000007587685X&messungsId=1"); + testHttpForbidden(baseURL + "status"); + ClientResponse response = getResponse(baseURL + "status/000007587685X", true); + Assert.assertNotNull(response); + Assert.assertEquals(404, response.getStatus()); + } + @Test + public void testLZusatzwertService() { + testHttpOK(baseURL + "zusatzwert?probeId=000007587685X"); + testHttpForbidden(baseURL + "zusatzwert"); + ClientResponse response = getResponse(baseURL + "zusatzwert/000007587685X", true); + Assert.assertNotNull(response); + Assert.assertEquals(404, response.getStatus()); + } } -@Test -public void testLKommentarService() { - testHttpOK(baseURL + "kommentare?probeId=000007587685X"); - testHttpForbidden(baseURL + "kommentare"); - ClientResponse response = getResponse(baseURL + "kommentare/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); -} -@Test -public void testMessungService() { - testHttpOK(baseURL + "messung?probeId=000007587685X"); - testHttpForbidden(baseURL + "messung"); - ClientResponse response = getResponse(baseURL + "messung/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); -} -@Test -public void testLMesswertService() { - testHttpOK(baseURL + "messwert?probeId=000007587685X&messungsId=1"); - testHttpForbidden(baseURL + "messwert"); - ClientResponse response = getResponse(baseURL + "messungwert/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); -} -@Test -public void testLProbenService() { - testHttpOK(baseURL + "proben?mstId=06010&umwId=N24"); - testHttpForbidden(baseURL + "proben?mstId=06010&umwId=N24"); - ClientResponse response = getResponse(baseURL + "proben/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(200, response.getStatus()); - checkResponse(response); -} -@Test -public void testLStatusService() { - testHttpOK(baseURL + "status?probeId=000007587685X&messungsId=1"); - testHttpForbidden(baseURL + "status"); - ClientResponse response = getResponse(baseURL + "status/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); -} -@Test -public void testLZusatzwertService() { - testHttpOK(baseURL + "zusatzwert?probeId=000007587685X"); - testHttpForbidden(baseURL + "zusatzwert"); - ClientResponse response = getResponse(baseURL + "zusatzwert/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); -} -} \ No newline at end of file