jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1678209 - in /jackrabbit/branches/2.8: ./ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenProviderTest.java
Date Thu, 07 May 2015 13:54:41 GMT
Author: reschke
Date: Thu May  7 13:54:41 2015
New Revision: 1678209

URL: http://svn.apache.org/r1678209
Log:
JCR-3790 - fix test case handling of System.currentTimeMillis (ported to 2.8)

Modified:
    jackrabbit/branches/2.8/   (props changed)
    jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenProviderTest.java

Propchange: jackrabbit/branches/2.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu May  7 13:54:41 2015
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1592881,1597717,1597799,1597806,1598035,1598058,1603769,1609712,1634584,1667787
+/jackrabbit/trunk:1592881,1597717,1597799,1597806,1598035,1598058,1603769,1603934,1609712,1634584,1667787

Modified: jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenProviderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenProviderTest.java?rev=1678209&r1=1678208&r2=1678209&view=diff
==============================================================================
--- jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenProviderTest.java
(original)
+++ jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenProviderTest.java
Thu May  7 13:54:41 2015
@@ -160,7 +160,7 @@ public class TokenProviderTest extends A
     public void testIsExpired() throws Exception {
         TokenInfo info = tokenProvider.createToken(testuser, new SimpleCredentials(userId,
userId.toCharArray()));
 
-        long loginTime = System.currentTimeMillis();
+        long loginTime = waitForSystemTimeIncrement(System.currentTimeMillis());
         assertFalse(info.isExpired(loginTime));
         assertTrue(info.isExpired(loginTime + TokenBasedAuthentication.TOKEN_EXPIRATION));
     }
@@ -169,7 +169,7 @@ public class TokenProviderTest extends A
         TokenInfo info = tokenProvider.createToken(testuser, new SimpleCredentials(userId,
userId.toCharArray()));
         long expTime = getTokenNode(info).getProperty("rep:token.exp").getLong();
 
-        long loginTime = System.currentTimeMillis();
+        long loginTime = waitForSystemTimeIncrement(System.currentTimeMillis());
         assertFalse(info.resetExpiration(loginTime));
         assertFalse(info.resetExpiration(loginTime + TokenBasedAuthentication.TOKEN_EXPIRATION));
 
@@ -188,4 +188,11 @@ public class TokenProviderTest extends A
     private Node getTokenNode(TokenInfo info) throws RepositoryException {
         return TokenProvider.getTokenNode(info.getToken(), session);
     }
+
+    private static long waitForSystemTimeIncrement(long old){
+        while (old == System.currentTimeMillis()) {
+            // wait for system timer to move
+        }
+        return System.currentTimeMillis();
+    }
 }
\ No newline at end of file



Mime
View raw message