You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2006/08/27 20:29:56 UTC

svn commit: r437434 - /geronimo/server/trunk/modules/geronimo-security/src/test/java/org/apache/geronimo/security/ContextManagerTest.java

Author: djencks
Date: Sun Aug 27 11:29:55 2006
New Revision: 437434

URL: http://svn.apache.org/viewvc?rev=437434&view=rev
Log:
GERONIMO-2313 some ContextManager tests

Modified:
    geronimo/server/trunk/modules/geronimo-security/src/test/java/org/apache/geronimo/security/ContextManagerTest.java

Modified: geronimo/server/trunk/modules/geronimo-security/src/test/java/org/apache/geronimo/security/ContextManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-security/src/test/java/org/apache/geronimo/security/ContextManagerTest.java?rev=437434&r1=437433&r2=437434&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-security/src/test/java/org/apache/geronimo/security/ContextManagerTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-security/src/test/java/org/apache/geronimo/security/ContextManagerTest.java Sun Aug 27 11:29:55 2006
@@ -44,4 +44,40 @@
         Principal principal = ContextManager.getCurrentPrincipal(subject);
         assertSame("Expected GeronimoCallerPrincipal", userPrincipal, principal);
     }
+
+    private final Subject s1 = new Subject();
+    private final Subject s2 = new Subject();
+    private final Subject s3 = new Subject();
+
+    public void testPushNextCallerWithSubjectPresent() throws Exception {
+        try {
+            ContextManager.setCallers(s1, s1);
+            Callers c1 = ContextManager.pushNextCaller(s2);
+            assertSame("Callers should have s1 in current position", s1, c1.getCurrentCaller());
+            assertSame("Callers should have s1 in next position", s1, c1.getNextCaller());
+            assertSame("CurrentCaller should be s1", s1, ContextManager.getCurrentCaller());
+            Callers c2 = ContextManager.pushNextCaller(s3);
+            assertSame("Callers should have s1 in current position", s1, c2.getCurrentCaller());
+            assertSame("Callers should have s2 in next position", s2, c2.getNextCaller());
+            assertSame("CurrentCaller should be s2", s2, ContextManager.getCurrentCaller());
+            Callers c3 = ContextManager.pushNextCaller(null);
+            assertSame("Callers should have s2 in current position", s2, c3.getCurrentCaller());
+            assertSame("Callers should have s3 in next position", s3, c3.getNextCaller());
+            assertSame("CurrentCaller should be s3", s3, ContextManager.getCurrentCaller());
+            Callers c4 = ContextManager.pushNextCaller(null);
+            assertSame("Callers should have s3 in current position", s3, c4.getCurrentCaller());
+            assertSame("Callers should have s3 in next position", s3, c4.getNextCaller());
+            assertSame("CurrentCaller should be s3", s3, ContextManager.getCurrentCaller());
+            ContextManager.popCallers(c4);
+            assertSame("CurrentCaller should be s3", s3, ContextManager.getCurrentCaller());
+            ContextManager.popCallers(c3);
+            assertSame("CurrentCaller should be s2", s2, ContextManager.getCurrentCaller());
+            ContextManager.popCallers(c2);
+            assertSame("CurrentCaller should be s1", s1, ContextManager.getCurrentCaller());
+            ContextManager.popCallers(c1);
+            assertSame("CurrentCaller should be s1", s1, ContextManager.getCurrentCaller());
+        } finally {
+            ContextManager.clearCallers();
+        }
+    }
 }