# HG changeset patch # User Jie Kang # Date 1507648323 25200 # Node ID 0ce9c3b75ab636bd30067dc72c0ad1455f992f88 # Parent ec644f678e6ed765af7a5bddf27aa56430efca9c 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 diff -r ec644f678e6e -r 0ce9c3b75ab6 tests/keycloak-integration-tests/src/test/java/com/redhat/thermostat/gateway/tests/keycloak/BasicKeycloakIntegrationTestSuite.java --- 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 endpoints, KeycloakUserCredentials keycloakUserCredentials) throws InterruptedException, ExecutionException, TimeoutException, IOException { - verifyEndpoints(endpoints, keycloakUserCredentials, 200); + verifyEndpoints(endpoints, keycloakUserCredentials, HttpStatus.OK_200); } private void verifyEndpointsWhenUnauthorized(List endpoints, KeycloakUserCredentials keycloakUserCredentials) throws InterruptedException, ExecutionException, TimeoutException, IOException { - verifyEndpoints(endpoints, keycloakUserCredentials, 403); + verifyEndpoints(endpoints, keycloakUserCredentials, HttpStatus.FORBIDDEN_403); } private void verifyEndpoints(List endpoints, KeycloakUserCredentials keycloakUserCredentials, int expectedStatus) throws InterruptedException, ExecutionException, TimeoutException, IOException {