}
@Test
public void testSetBody() throws Exception {
OAuthJSONAccessTokenResponse r = null;
try {
r = new OAuthJSONAccessTokenResponse();
r.init(TestUtils.VALID_JSON_RESPONSE,
OAuth.ContentType.JSON, 200);
} catch (OAuthProblemException e) {
fail("Exception not expected");
}
String accessToken = r.getAccessToken();
Long expiresIn = r.getExpiresIn();
Assert.assertEquals(TestUtils.EXPIRES_IN, expiresIn);
Assert.assertEquals(TestUtils.ACCESS_TOKEN, accessToken);
try {
new OAuthJSONAccessTokenResponse();
r.init(TestUtils.ERROR_JSON_BODY,
OAuth.ContentType.JSON, 200);
fail("Exception expected");
} catch (OAuthProblemException e) {
Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
}