@Parameters({ "clientInfoPath" }) @Test public void requestClientInfoInvalidRequest(final String clientInfoPath) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + clientInfoPath).request(); request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); ClientInfoRequest clientInfoRequest = new ClientInfoRequest(null); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(clientInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestClientInfoInvalidRequest", response, entity); assertEquals(response.getStatus(), 400, "Unexpected response code."); assertNotNull(entity, "Unexpected result: " + entity); try { JSONObject jsonObj = new JSONObject(entity); assertTrue(jsonObj.has("error"), "The error type is null"); assertTrue(jsonObj.has("error_description"), "The error description is null"); } catch (JSONException e) { e.printStackTrace(); fail(e.getMessage() + "\nResponse was: " + entity); } }
@Parameters({ "clientInfoPath" }) @Test public void requestClientInfoInvalidToken(final String clientInfoPath) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + clientInfoPath).request(); request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); ClientInfoRequest clientInfoRequest = new ClientInfoRequest("INVALID-TOKEN"); clientInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(clientInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestClientInfoInvalidToken", response, entity); assertEquals(response.getStatus(), 400, "Unexpected response code."); assertNotNull(entity, "Unexpected result: " + entity); try { JSONObject jsonObj = new JSONObject(entity); assertTrue(jsonObj.has("error"), "The error type is null"); assertTrue(jsonObj.has("error_description"), "The error description is null"); } catch (JSONException e) { e.printStackTrace(); fail(e.getMessage() + "\nResponse was: " + entity); } }
.post(Entity.form(new MultivaluedHashMap<String, String>(clientInfoRequest.getParameters()))); String entity = response.readEntity(String.class);
.post(Entity.form(new MultivaluedHashMap<String, String>(clientInfoRequest.getParameters()))); String entity = response.readEntity(String.class);