@Test (timeout = 30000)
public void testHasSufficientTimeElapsed() throws Exception {

  // Make hasSufficientTimeElapsed public
  Method method = UserGroupInformation.class
          .getDeclaredMethod("hasSufficientTimeElapsed", long.class);
  method.setAccessible(true);
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
  User user = ugi.getSubject().getPrincipals(User.class).iterator().next();
  long now = System.currentTimeMillis();
  // Using default relogin time (1 minute)
  user.setLastLogin(now - 2 * 60 * 1000);  // 2 minutes before "now"
  assertTrue((Boolean)method.invoke(ugi, now));
  user.setLastLogin(now - 30 * 1000);      // 30 seconds before "now"
  assertFalse((Boolean)method.invoke(ugi, now));
  // Using relogin time of 10 minutes
  Configuration conf2 = new Configuration(conf);
  conf2.setLong(
     CommonConfigurationKeysPublic.HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN,
     10 * 60);
  UserGroupInformation.setConfiguration(conf2);
  user.setLastLogin(now - 15 * 60 * 1000); // 15 minutes before "now"
  assertTrue((Boolean)method.invoke(ugi, now));
  user.setLastLogin(now - 6 * 60 * 1000);  // 6 minutes before "now"
  assertFalse((Boolean)method.invoke(ugi, now));
  // Restore original conf to UGI
  UserGroupInformation.setConfiguration(conf);
  // Restore hasSufficientTimElapsed back to private
  method.setAccessible(false);
}