shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r795305 - in /incubator/shiro/trunk: README-runtime-requirements.txt core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java
Date Sat, 18 Jul 2009 03:45:38 GMT
Author: lhazlewood
Date: Sat Jul 18 03:45:37 2009
New Revision: 795305

URL: http://svn.apache.org/viewvc?rev=795305&view=rev
Log:
Added DelegatingSessionTest

Added:
    incubator/shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java
Modified:
    incubator/shiro/trunk/README-runtime-requirements.txt

Modified: incubator/shiro/trunk/README-runtime-requirements.txt
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/README-runtime-requirements.txt?rev=795305&r1=795304&r2=795305&view=diff
==============================================================================
--- incubator/shiro/trunk/README-runtime-requirements.txt (original)
+++ incubator/shiro/trunk/README-runtime-requirements.txt Sat Jul 18 03:45:37 2009
@@ -9,12 +9,11 @@
 
 Minimal required dependencies
 -------------
-Ensure shiro-all.jar, slf4j-api.jar and one of slf4j's bindings (slf4j-simple.jar, slf4j-log4j12,
etc) are in
+Ensure shiro-all.jar, slf4j-api.jar and one of slf4j's bindings (e.g. slf4j-simple.jar, slf4j-log4j12,
etc) are in
 your application's classpath.
 
 
 Feature-based dependencies
 --------------------------
-- .ini based configuration, either for a shiro.ini file in the classpath or embedded .ini
in the ShiroFilter
-  in web.xml:
-  . include Jakarta commons-beanutils-core.jar
+* .ini based configuration, either for a shiro.ini file in the classpath or embedded .ini
in the ShiroFilter in web.xml:
+  - include Jakarta commons-beanutils-core.jar

Added: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java?rev=795305&view=auto
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java
(added)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DelegatingSessionTest.java
Sat Jul 18 03:45:37 2009
@@ -0,0 +1,55 @@
+package org.apache.shiro.session.mgt;
+
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.apache.shiro.util.ThreadContext;
+
+import java.io.Serializable;
+import java.net.InetAddress;
+
+/**
+ * Unit test for the {@link DelegatingSession} class.
+ */
+public class DelegatingSessionTest {
+
+    DelegatingSession session = null;
+    DefaultSessionManager sm = null;
+
+    @Before
+    public void setup() {
+        ThreadContext.clear();
+        sm = new DefaultSessionManager();
+        Serializable sessionId = sm.start((InetAddress)null);
+        this.session = new DelegatingSession(sm, sessionId);
+    }
+
+    @After
+    public void tearDown() {
+        sm.destroy();
+        ThreadContext.clear();
+    }
+
+    public void sleep(long millis) {
+        try {
+            Thread.sleep(millis);
+        } catch (InterruptedException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    @Test
+    public void testTimeout() {
+        Serializable origId = session.getId();
+        assertEquals(session.getTimeout(), AbstractSessionManager.DEFAULT_GLOBAL_SESSION_TIMEOUT);
+        session.setTimeout(100);
+        assertEquals(session.getTimeout(), 100);
+        sleep(100);
+        //now the underlying session should have been expired and a new one replaced by default.
+        //so ensure the replaced session has the default session timeout:
+        assertEquals(session.getTimeout(), AbstractSessionManager.DEFAULT_GLOBAL_SESSION_TIMEOUT);
+        assertFalse(origId.equals(session.getId())); //new ID would have been generated
+    }
+
+}



Mime
View raw message