shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r1479180 - /shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java
Date Sat, 04 May 2013 21:32:18 GMT
Author: lhazlewood
Date: Sat May  4 21:32:18 2013
New Revision: 1479180

URL: http://svn.apache.org/r1479180
Log:
SHIRO-399: added minor test execution delay to ensure session timeout.

Modified:
    shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java

Modified: shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java
URL: http://svn.apache.org/viewvc/shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java?rev=1479180&r1=1479179&r2=1479180&view=diff
==============================================================================
--- shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java
(original)
+++ shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java
Sat May  4 21:32:18 2013
@@ -19,13 +19,10 @@
 package org.apache.shiro.session.mgt;
 
 import org.apache.shiro.authz.AuthorizationException;
-import org.apache.shiro.mgt.DefaultSecurityManager;
-import org.apache.shiro.mgt.SecurityManager;
 import org.apache.shiro.session.Session;
 import org.apache.shiro.session.SessionListener;
 import org.apache.shiro.session.SessionListenerAdapter;
 import org.apache.shiro.session.UnknownSessionException;
-import org.apache.shiro.util.ThreadContext;
 import org.junit.Test;
 
 import java.util.ArrayList;
@@ -103,10 +100,6 @@ public class AbstractValidatingSessionMa
      */
     @Test
     public void testNoMemoryLeakOnInvalidSessions() throws Exception {
-        ThreadContext.remove();
-        SecurityManager sm = new DefaultSecurityManager();
-        ThreadContext.bind(sm);
-
         SessionListener sessionListener = new SessionListener() {
             public void onStart(Session session) {
                 session.setAttribute("I love", "Romania");
@@ -132,12 +125,14 @@ public class AbstractValidatingSessionMa
         sessionManager.setSessionListeners(Arrays.asList(sessionListener));
 
         Session session = sessionManager.start(null);
-        session.setTimeout(0L);
-
-        sessionManager.getSessionDAO().update(session);
         assertEquals(1, sessionManager.getActiveSessions().size());
 
+        session.setTimeout(0L);
+        //last access timestamp needs to be older than the current timestamp when validating,
so ensure a delay:
+        Thread.sleep(1);
+
         sessionManager.validateSessions();
+
         assertEquals(0, sessionManager.getActiveSessions().size());
     }
 }



Mime
View raw message