Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
}
@Test
public void testHandleResponse_5() throws Exception {
final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
builder.setHttpStatusCode(HttpResponse.SC_OK);
builder.setHeader("Content-Type", "application/json");
builder
.setContent("{\"access_token\"=\"xxx\",\"token_type\"=\"Bearer\",\"expires_in\"=\"1\",\"refresh_token\"=\"yyy\",\"example_parameter\"=\"example_value\"}");
final HttpResponse response = builder.create();
final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
accessor, response);
Assert.assertNull(result);
final OAuth2Token accessToken = TokenAuthorizationResponseHandlerTest.store.getToken(
accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
accessor.getScope(), OAuth2Token.Type.ACCESS);
Assert.assertNotNull(accessToken);
Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
Assert.assertTrue(accessToken.getExpiresAt() > 1000);
final OAuth2Token refreshToken = TokenAuthorizationResponseHandlerTest.store.getToken(
accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
accessor.getScope(), OAuth2Token.Type.REFRESH);
Assert.assertNotNull(refreshToken);
Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
}