Java 类com.google.gwt.core.client.testing.StubScheduler 实例源码

项目:gwt-oauth2    文件:AuthTest.java   
/**
 * When the token is found in cookies and will not expire soon, neither popup
 * nor iframe is used, and the token is immediately passed to the callback.
 */
public void testLogin_notExpiringSoon() {
  AuthRequest req = new AuthRequest("url", "clientId").withScopes("scope");

  // Storing a token that does not expire soon (in exactly 10 minutes)
  TokenInfo info = new TokenInfo();
  info.accessToken = "notExpiringSoon";
  info.expires = String.valueOf(MockClock.now + 10 * 60 * 1000);
  auth.setToken(req, info);

  MockCallback callback = new MockCallback();
  auth.login(req, callback);

  // A deferred command will have been scheduled. Execute it.
  List<ScheduledCommand> deferred = ((StubScheduler) auth.scheduler).getScheduledCommands();
  assertEquals(1, deferred.size());
  deferred.get(0).execute();

  // The iframe was used and the popup wasn't.
  assertFalse(auth.loggedInViaPopup);

  // onSuccess() was called and onFailure() wasn't.
  assertEquals("notExpiringSoon", callback.token);
  assertNull(callback.failure);
}
项目:requestor    文件:AuthTest.java   
/**
 * When the token is found in cookies and will not expire soon, neither popup
 * nor iframe is used, and the token is immediately passed to the callback.
 */
public void testLogin_notExpiringSoon() {
  AuthRequest req = new AuthRequest("url", "clientId").withScopes("scope");

  // Storing a token that does not expire soon (in exactly 10 minutes)
  TokenInfo info = new TokenInfo();
  info.setTokenType("type");
  info.setAccessToken("notExpiringSoon");
  info.setExpires(String.valueOf(MockClock.now + 10 * 60 * 1000));
  auth.setToken(req, info);

  MockCallback callback = new MockCallback();
  auth.login(req, callback);

  // A deferred command will have been scheduled. Execute it.
  List<ScheduledCommand> deferred = ((StubScheduler) auth.scheduler).getScheduledCommands();
  assertEquals(1, deferred.size());
  deferred.get(0).execute();

  // The iframe was used and the popup wasn't.
  assertFalse(auth.loggedInViaPopup);

  // onSuccess() was called and onFailure() wasn't.
  assertEquals("notExpiringSoon", callback.token.getAccessToken());
  assertNull(callback.failure);
}
项目:gwt-oauth2    文件:AuthTest.java   
MockAuth() {
  super(TOKEN_STORE, new MockClock(), new MockUrlCodex(), new StubScheduler(), "popup.html");
}
项目:requestor    文件:AuthTest.java   
MockAuth() {
  super(TOKEN_STORE, new MockClock(), new MockUrlCodex(), new StubScheduler(), "popup.html");
}