@Test
public void testAuthenticateOAuth2FailCookieAuth() throws ServiceUnavailableException {

  authenticator = new GoogleAppEngineAuthenticator(oauthService, userService) {
    @Override
    com.google.appengine.api.users.User getOAuth2User(HttpServletRequest request,
        ApiMethodConfig config) {
      return null;
    }
    @Override
    boolean shouldTryCookieAuth(ApiMethodConfig config) {
      return true;
    }
  };
  when(userService.getCurrentUser()).thenReturn(APP_ENGINE_USER);
  assertEquals(USER, authenticator.authenticate(request));
  assertEquals(APP_ENGINE_USER, attr.get(Attribute.AUTHENTICATED_APPENGINE_USER));
}