changeset 274:0ce9c3b75ab6

Use status codes instead of integers in Keycloak integration tests Reviewed-by: ebaron Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/025124.html Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-October/025295.html
author Jie Kang <jkang@redhat.com>
date Tue, 10 Oct 2017 08:12:03 -0700
parents ec644f678e6e
children d7a5efac202c
files tests/keycloak-integration-tests/src/test/java/com/redhat/thermostat/gateway/tests/keycloak/BasicKeycloakIntegrationTestSuite.java
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/keycloak-integration-tests/src/test/java/com/redhat/thermostat/gateway/tests/keycloak/BasicKeycloakIntegrationTestSuite.java	Mon Oct 09 15:57:22 2017 +0200
+++ b/tests/keycloak-integration-tests/src/test/java/com/redhat/thermostat/gateway/tests/keycloak/BasicKeycloakIntegrationTestSuite.java	Tue Oct 10 08:12:03 2017 -0700
@@ -48,6 +48,7 @@
 import org.eclipse.jetty.client.api.Request;
 import org.eclipse.jetty.client.util.StringContentProvider;
 import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpStatus;
 import org.junit.Test;
 
 import com.redhat.thermostat.gateway.tests.utils.EndpointDefinition;
@@ -155,17 +156,17 @@
         for (EndpointDefinition endpoint : endpoints) {
             ContentResponse response = httpRequestUtil.buildRequest(baseResourceUrl + endpoint.getEndpointUrl(), endpoint.getMethod()).send();
 
-            verifyResponse(endpoint, response, 401);
-            assertEquals(401, response.getStatus());
+            verifyResponse(endpoint, response, HttpStatus.UNAUTHORIZED_401);
+            assertEquals(HttpStatus.UNAUTHORIZED_401, response.getStatus());
         }
     }
 
     private void verifyEndpointsWhenAuthorized(List<EndpointDefinition> endpoints, KeycloakUserCredentials keycloakUserCredentials) throws InterruptedException, ExecutionException, TimeoutException, IOException {
-        verifyEndpoints(endpoints, keycloakUserCredentials, 200);
+        verifyEndpoints(endpoints, keycloakUserCredentials, HttpStatus.OK_200);
     }
 
     private void verifyEndpointsWhenUnauthorized(List<EndpointDefinition> endpoints, KeycloakUserCredentials keycloakUserCredentials) throws InterruptedException, ExecutionException, TimeoutException, IOException {
-        verifyEndpoints(endpoints, keycloakUserCredentials, 403);
+        verifyEndpoints(endpoints, keycloakUserCredentials, HttpStatus.FORBIDDEN_403);
     }
 
     private void verifyEndpoints(List<EndpointDefinition> endpoints, KeycloakUserCredentials keycloakUserCredentials, int expectedStatus) throws InterruptedException, ExecutionException, TimeoutException, IOException {