throws Exception {
ResponseType rts = new ResponseType();
rts.add(ResponseType.Value.CODE);
State state = new State("xyz");
AuthorizationErrorResponse r = new AuthorizationErrorResponse(REDIRECT_URI,
OAuth2Error.INVALID_REQUEST,
rts,
state);
assertEquals(REDIRECT_URI, r.getRedirectionURI());
assertEquals(OAuth2Error.INVALID_REQUEST, r.getErrorObject());
assertEquals(rts, r.getResponseType());
assertEquals(state, r.getState());
Map<String,String> params = r.toParameters();
assertEquals(OAuth2Error.INVALID_REQUEST.getCode(), params.get("error"));
assertEquals(OAuth2Error.INVALID_REQUEST.getDescription(), params.get("error_description"));
assertNull(params.get("error_uri"));
assertEquals(state.toString(), params.get("state"));
assertEquals(3, params.size());
URI location = r.toURI();
System.out.println(location.toString());
assertNull(location.getFragment());
assertNotNull(location.getQuery());
assertEquals(REDIRECT_URI.getScheme(), location.getScheme());
assertEquals(REDIRECT_URI.getPort(), location.getPort());
assertEquals(REDIRECT_URI.getHost(), location.getHost());
assertEquals(REDIRECT_URI.getPath(), location.getPath());
params = URLUtils.parseParameters(location.getQuery());
assertEquals(OAuth2Error.INVALID_REQUEST.getCode(), params.get("error"));
assertEquals(OAuth2Error.INVALID_REQUEST.getDescription(), params.get("error_description"));
assertEquals(state.toString(), params.get("state"));
assertEquals(3, params.size());
HTTPResponse httpResponse = r.toHTTPResponse();
assertEquals(HTTPResponse.SC_FOUND, httpResponse.getStatusCode());