@Test
public void testAccessTokenExpired_andRevoked() throws Exception {
serviceProvider.setSessionExtension(true);
MakeRequestClient client = makeNonSocialClient("owner", "owner", GADGET_URL);
HttpResponse response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
assertEquals("", response.getResponseAsString());
client.approveToken("user_data=hello-oauth");
response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
assertEquals("User data is hello-oauth", response.getResponseAsString());
assertEquals(1, serviceProvider.getRequestTokenCount());
assertEquals(1, serviceProvider.getAccessTokenCount());
assertEquals(1, serviceProvider.getResourceAccessCount());
clock.incrementSeconds(FakeOAuthServiceProvider.TOKEN_EXPIRATION_SECONDS + 1);
serviceProvider.revokeAllAccessTokens();
response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL + "?cb=1");
assertEquals("", response.getResponseAsString());
assertEquals(2, serviceProvider.getRequestTokenCount());
assertEquals(2, serviceProvider.getAccessTokenCount());
assertEquals(1, serviceProvider.getResourceAccessCount());
client.approveToken("user_data=renewed");
response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL + "?cb=1");
assertEquals(2, serviceProvider.getRequestTokenCount());
assertEquals(3, serviceProvider.getAccessTokenCount());
assertEquals(2, serviceProvider.getResourceAccessCount());
assertEquals("User data is renewed", response.getResponseAsString());
checkLogContains("oauth_token_secret=REMOVED");
}