public void testAccessTokenExpires_onClientNoPredictedExpiration() throws Exception {
serviceProvider.setSessionExtension(true);
serviceProvider.setReportExpirationTimes(false);
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);
response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL + "?cb=1");
assertEquals("User data is hello-oauth", response.getResponseAsString());
assertEquals(1, serviceProvider.getRequestTokenCount());
assertEquals(2, serviceProvider.getAccessTokenCount());
assertEquals(3, serviceProvider.getResourceAccessCount());
response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL + "?cb=3");
assertEquals("User data is hello-oauth", response.getResponseAsString());
assertEquals(1, serviceProvider.getRequestTokenCount());
assertEquals(2, serviceProvider.getAccessTokenCount());
assertEquals(4, serviceProvider.getResourceAccessCount());
clock.incrementSeconds(FakeOAuthServiceProvider.TOKEN_EXPIRATION_SECONDS + 1);
response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL + "?cb=4");
assertEquals("User data is hello-oauth", response.getResponseAsString());
assertEquals(1, serviceProvider.getRequestTokenCount());
assertEquals(3, serviceProvider.getAccessTokenCount());
assertEquals(6, serviceProvider.getResourceAccessCount());
}