shiro-commits mailing list archives

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

URL: http://svn.apache.org/r1479209
Log:
SHIRO-388: added test to verify correct functionality.

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

Modified: shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
URL: http://svn.apache.org/viewvc/shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java?rev=1479209&r1=1479208&r2=1479209&view=diff
==============================================================================
--- shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
(original)
+++ shiro/trunk/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
Sat May  4 22:39:21 2013
@@ -18,7 +18,11 @@
  */
 package org.apache.shiro.session.mgt;
 
-import org.apache.shiro.session.*;
+import org.apache.shiro.session.ExpiredSessionException;
+import org.apache.shiro.session.InvalidSessionException;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.session.SessionListener;
+import org.apache.shiro.session.SessionListenerAdapter;
 import org.apache.shiro.session.mgt.eis.SessionDAO;
 import org.apache.shiro.util.ThreadContext;
 import org.easymock.EasyMock;
@@ -96,6 +100,29 @@ public class DefaultSessionManagerTest {
         assertTrue(stopped[0]);
     }
 
+    //asserts fix for SHIRO-388:
+    //Ensures that a session attribute can be accessed in the listener without
+    //causing a stack overflow exception.
+    @Test
+    public void testSessionListenerStopNotificationWithReadAttribute() {
+        final boolean[] stopped = new boolean[1];
+        final String[] value = new String[1];
+        SessionListener listener = new SessionListenerAdapter() {
+            public void onStop(Session session) {
+                stopped[0] = true;
+                value[0] = (String)session.getAttribute("foo");
+            }
+        };
+        sm.getSessionListeners().add(listener);
+        Session session = sm.start(null);
+        session.setAttribute("foo", "bar");
+
+        sm.stop(new DefaultSessionKey(session.getId()));
+
+        assertTrue(stopped[0]);
+        assertEquals("bar", value[0]);
+    }
+
     @Test
     public void testSessionListenerExpiredNotification() {
         final boolean[] expired = new boolean[1];



Mime
View raw message