[java-identity-provider COMMIT] in /trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl: PopulateSes...

noreply at shibboleth.net noreply at shibboleth.net
Fri Oct 11 20:43:30 EDT 2013


Author: scantor
Date: Fri Oct 11 20:43:30 2013
New Revision: 4845

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4845&view=rev
Log:
Refactor test case with base class.

Added:
    trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/SessionManagerBaseTestCase.java   (with props)
Modified:
    trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java

Modified: trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java?rev=4845&r1=4844&r2=4845&view=diff
==============================================================================
--- trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java (original)
+++ trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java Fri Oct 11 20:43:30 2013
@@ -22,65 +22,31 @@
 import net.shibboleth.idp.session.SessionException;
 import net.shibboleth.idp.session.context.SessionContext;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.net.CookieManager;
 import net.shibboleth.utilities.java.support.net.HttpServletRequestResponseContext;
-import net.shibboleth.utilities.java.support.net.ThreadLocalHttpServletRequestProxy;
-import net.shibboleth.utilities.java.support.net.ThreadLocalHttpServletResponseProxy;
-import net.shibboleth.utilities.java.support.security.SecureRandomIdentifierGenerationStrategy;
 
 import org.opensaml.profile.ProfileException;
 import org.opensaml.profile.action.ActionTestingSupport;
 import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.storage.impl.MemoryStorageService;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 /** {@link PopulateSessionContext} unit test. */
-public class PopulateSessionContextTest {
+public class PopulateSessionContextTest extends SessionManagerBaseTestCase {
     
-    private static MemoryStorageService storageService;
-    
-    private static StorageBackedSessionManager manager;
-
     private ProfileRequestContext prc;
     
     private PopulateSessionContext action;
-    
-    @BeforeClass public static void setUp() throws ComponentInitializationException {
-        storageService = new MemoryStorageService();
-        storageService.initialize();
-
-        CookieManager cookieManager = new CookieManager();
-        cookieManager.setHttpServletRequest(new ThreadLocalHttpServletRequestProxy());
-        cookieManager.setHttpServletResponse(new ThreadLocalHttpServletResponseProxy());
-        
-        manager = new StorageBackedSessionManager();
-        manager.setSessionTimeout(5000);
-        manager.setStorageService(storageService);
-        manager.setIDGenerator(new SecureRandomIdentifierGenerationStrategy());
-        manager.setHttpServletRequest(new ThreadLocalHttpServletRequestProxy());
-        manager.setHttpServletResponse(new ThreadLocalHttpServletResponseProxy());
-        manager.setCookieManager(cookieManager);
-        manager.initialize();
-    }
-    
-    @AfterClass public static void tearDown() {
-        manager.destroy();
-        storageService.destroy();
-    }
     
     @BeforeMethod public void setUpAction() throws ComponentInitializationException {
         prc = new ProfileRequestContext();
         
         action = new PopulateSessionContext();
-        action.setHttpServletRequest(new ThreadLocalHttpServletRequestProxy());
-        action.setHttpServletResponse(new ThreadLocalHttpServletResponseProxy());
-        action.setSessionResolver(manager);
+        action.setHttpServletRequest(requestProxy);
+        action.setHttpServletResponse(responseProxy);
+        action.setSessionResolver(sessionManager);
         action.initialize();
     }
     
@@ -92,7 +58,7 @@
     }
     
     @Test public void testSession() throws ProfileException, SessionException {
-        Cookie cookie = createSession();
+        Cookie cookie = createSession("joe");
         
         HttpServletRequestResponseContext.loadCurrent(new MockHttpServletRequest(), new MockHttpServletResponse());
         ((MockHttpServletRequest) HttpServletRequestResponseContext.getRequest()).setCookies(cookie);
@@ -106,7 +72,7 @@
     }
 
     @Test public void testAddressRebind() throws ProfileException, SessionException {
-        Cookie cookie = createSession();
+        Cookie cookie = createSession("joe");
         
         HttpServletRequestResponseContext.loadCurrent(new MockHttpServletRequest(), new MockHttpServletResponse());

[... 39 lines stripped ...]


More information about the commits mailing list