[jboss-cvs] JBossAS SVN: r65337 - trunk/testsuite/src/main/org/jboss/test/web/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Sep 12 11:59:39 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-09-12 11:59:39 -0400 (Wed, 12 Sep 2007)
New Revision: 65337

Removed:
   trunk/testsuite/src/main/org/jboss/test/web/test/TreeCacheSSOClusterManagerUnitTestCase.java
Log:
Move TreeCacheSSOClusterManagerUnitTestCase to cluster test package

Deleted: trunk/testsuite/src/main/org/jboss/test/web/test/TreeCacheSSOClusterManagerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/TreeCacheSSOClusterManagerUnitTestCase.java	2007-09-12 15:54:35 UTC (rev 65336)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/TreeCacheSSOClusterManagerUnitTestCase.java	2007-09-12 15:59:39 UTC (rev 65337)
@@ -1,297 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.web.test;
-
-import java.util.Set;
-import java.util.Vector;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.transaction.TransactionManager;
-
-import org.apache.catalina.Manager;
-import org.apache.catalina.Session;
-import org.apache.catalina.session.StandardManager;
-import org.apache.catalina.session.StandardSession;
-import org.jboss.cache.CacheImpl;
-import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.jmx.CacheJmxWrapper;
-import org.jboss.cache.notifications.event.EventImpl;
-import org.jboss.cache.notifications.event.Event.Type;
-import org.jboss.cache.transaction.BatchModeTransactionManager;
-import org.jboss.cache.transaction.TransactionManagerLookup;
-import org.jboss.test.JBossTestCase;
-import org.jboss.util.threadpool.BasicThreadPool;
-import org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn;
-import org.jboss.web.tomcat.service.sso.TreeCacheSSOClusterManager;
-import org.jgroups.Address;
-import org.jgroups.View;
-import org.jgroups.ViewId;
-import org.jgroups.stack.IpAddress;
-
-/**
- * Test of the TreeCacheSSOClusterManager class.
- * 
- * @author Brian Stansberry
- */
-public class TreeCacheSSOClusterManagerUnitTestCase extends JBossTestCase
-{
-   private static IpAddress LOCAL_ADDRESS;
-   private static IpAddress REMOTE_ADDRESS;
-   
-   public TreeCacheSSOClusterManagerUnitTestCase(String name)
-   {
-      super(name);
-   }
-   
-   @Override
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      LOCAL_ADDRESS  = new IpAddress("127.0.0.1", 11111);
-      REMOTE_ADDRESS = new IpAddress("192.168.0.1", 11111);
-   }
-
-   public void testDeadMemberCleanupWithPool() throws Exception
-   {
-      deadMemberCleanupTest(true);
-   }
-   
-   public void testDeadMemberCleanupWithoutPool() throws Exception
-   {
-      deadMemberCleanupTest(false);
-   }
-   
-   private void deadMemberCleanupTest(boolean usePool) throws Exception
-   {
-      log.debug("+++ testDeadMemberCleanup()");
-      
-      MBeanServer mbeanServer = 
-         MBeanServerFactory.createMBeanServer("deadMemberTest");
-      try 
-      {
-         // Register a cache
-         MockTreeCache cache = new MockTreeCache();
-         // JBAS-4097 -- don't use a TransactionManagerLookup that will
-         // bind DummyTransactionManager into JNDI, as that will screw
-         // up other tests
-         cache.setTransactionManagerLookup(new MockTransactionManagerLookup());
-         CacheJmxWrapper wrapper = new CacheJmxWrapper(cache);
-         mbeanServer.registerMBean(wrapper, new ObjectName(TreeCacheSSOClusterManager.DEFAULT_GLOBAL_CACHE_NAME));
-         wrapper.create();
-         wrapper.start();
-         
-         if (usePool)
-         {
-            BasicThreadPool pool = new BasicThreadPool();
-            mbeanServer.registerMBean(pool, new ObjectName(TreeCacheSSOClusterManager.DEFAULT_THREAD_POOL_NAME));
-         }
-         
-         // Build up an SSO infrastructure based on LOCAL_ADDRESS         
-         TreeCacheSSOClusterManager localSSOManager = new TreeCacheSSOClusterManager(mbeanServer);
-         localSSOManager.setCacheName(TreeCacheSSOClusterManager.DEFAULT_GLOBAL_CACHE_NAME);
-         
-         MockSSOValve localValve = new MockSSOValve();
-         localValve.setClusterManager(localSSOManager);
-         localSSOManager.setSingleSignOnValve(localValve);
-         localSSOManager.start();
-         
-         assertEquals("Thread pool usage as expected", usePool, localSSOManager.isUsingThreadPool());
-         
-         //  Build up a second SSO infrastructure based on LOCAL_ADDRESS
-         // It uses the same mock cache, but we change the cache address
-         // so it thinks it's a different address when it starts
-         cache.setOurAddress(REMOTE_ADDRESS);
-         
-         TreeCacheSSOClusterManager remoteSSOManager = new TreeCacheSSOClusterManager(mbeanServer);
-         remoteSSOManager.setCacheName(TreeCacheSSOClusterManager.DEFAULT_GLOBAL_CACHE_NAME);
-         
-         MockSSOValve remoteValve = new MockSSOValve();
-         remoteValve.setClusterManager(remoteSSOManager);
-         remoteSSOManager.setSingleSignOnValve(localValve);
-         remoteSSOManager.start();
-         
-         
-         // Create an SSO that will have sessions from both valves
-         localSSOManager.register("1", "FORM", "Brian", "password");
-         
-         Manager localSessMgr1 = new StandardManager();
-         Session sess1 = new MockSession(localSessMgr1, "1");
-         localSSOManager.addSession("1", sess1);
-         
-         Manager remoteSessMgr1 = new StandardManager();
-         Session sess2 = new MockSession(remoteSessMgr1, "2");
-         remoteSSOManager.addSession("1", sess2);
-         
-         
-         // Create another SSO with sessions only from remote
-         remoteSSOManager.register("2", "FORM", "Brian", "password");
-         
-         Manager remoteSessMgr2 = new StandardManager();
-         Session sess3 = new MockSession(remoteSessMgr2, "3");
-         remoteSSOManager.addSession("2", sess3);
-         
-         Manager remoteSessMgr3 = new StandardManager();
-         Session sess4 = new MockSession(remoteSessMgr3, "4");
-         remoteSSOManager.addSession("2", sess4);
-         
-         
-         // Create a third SSO that will have sessions from both valves
-         localSSOManager.register("3", "FORM", "Brian", "password");
-         
-         Manager localSessMgr2 = new StandardManager();
-         Session sess5 = new MockSession(localSessMgr2, "5");
-         localSSOManager.addSession("3", sess5);
-         
-         Manager remoteSessMgr4 = new StandardManager();
-         Session sess6 = new MockSession(remoteSessMgr4, "6");
-         remoteSSOManager.addSession("3", sess6);
-         
-         
-         // Create a fourth SSO that will have two sessions from local valve
-         localSSOManager.register("4", "FORM", "Brian", "password");
-         
-         Manager localSessMgr3 = new StandardManager();
-         Session sess7 = new MockSession(localSessMgr3, "7");
-         localSSOManager.addSession("4", sess7);
-         
-         Manager localSessMgr4 = new StandardManager();
-         Session sess8 = new MockSession(localSessMgr4, "8");
-         localSSOManager.addSession("4", sess8);
-         
-         // Confirm that data is cached properly
-         assertEquals("SSO 1 has correct number of sessions", 2, localSSOManager.getSessionCount("1"));
-         assertEquals("SSO 1 has correct number of sessions", 2, remoteSSOManager.getSessionCount("1"));
-         assertEquals("SSO 2 has correct number of sessions", 2, localSSOManager.getSessionCount("2"));
-         assertEquals("SSO 2 has correct number of sessions", 2, remoteSSOManager.getSessionCount("2"));
-         assertEquals("SSO 3 has correct number of sessions", 2, localSSOManager.getSessionCount("3"));
-         assertEquals("SSO 3 has correct number of sessions", 2, remoteSSOManager.getSessionCount("3"));
-         assertEquals("SSO 4 has correct number of sessions", 2, localSSOManager.getSessionCount("4"));
-         assertEquals("SSO 4 has correct number of sessions", 2, remoteSSOManager.getSessionCount("4"));
-         
-         // Put in a new view with REMOTE_ADDRESS dead
-         ViewId viewId = new ViewId(LOCAL_ADDRESS, 1);
-         Vector v = new Vector();
-         v.add(LOCAL_ADDRESS);
-         EventImpl event = new EventImpl();
-         event.setNewView(new View(viewId, v));
-         event.setType(Type.VIEW_CHANGED);
-         event.setPre(false);
-         
-         localSSOManager.viewChange(event);
-         
-         // Give the cleanup thread time to finish
-         Thread.sleep(2000);
-         
-         // Confirm that cached data is properly cleaned up
-         assertEquals("SSO 1 has correct number of sessions", 1, localSSOManager.getSessionCount("1"));
-         assertEquals("SSO 2 has correct number of sessions", 0, localSSOManager.getSessionCount("2"));
-         assertEquals("SSO 3 has correct number of sessions", 1, localSSOManager.getSessionCount("3"));
-         assertEquals("SSO 4 has correct number of sessions", 2, localSSOManager.getSessionCount("4"));         
-      }
-      finally
-      {
-         MBeanServerFactory.releaseMBeanServer(mbeanServer);
-      }      
-   }
-   
-   
-   static class MockTreeCache extends CacheImpl
-   {
-      private IpAddress ourAddress = LOCAL_ADDRESS;
-      
-      public MockTreeCache() throws Exception
-      {
-         super();
-         getConfiguration().setCacheMode(CacheMode.LOCAL);
-      }
-
-      @Override
-      public Address getLocalAddress()
-      {
-         return ourAddress;
-      }
-      
-      void setOurAddress(IpAddress address)
-      {
-         ourAddress = address;
-      }
-
-      @Override
-      public Vector getMembers()
-      {
-         Vector v = new Vector();
-         v.add(LOCAL_ADDRESS);
-         v.add(REMOTE_ADDRESS);
-         return v;
-      }      
-      
-   }
-   
-   /**
-    * Override ClusteredSingleSignOn to suppress the empty SSO callbacks
-    */
-   static class MockSSOValve extends ClusteredSingleSignOn
-   {
-      @Override
-      protected void notifySSOEmpty(String ssoId)
-      {
-         // no-op
-      }
-
-      @Override
-      protected void notifySSONotEmpty(String ssoId)
-      {
-         // no-op
-      }      
-   }
-   
-   static class MockSession extends StandardSession
-   {
-      private static final long serialVersionUID = 1L;
-      
-      private String ourId;
-      
-      MockSession(Manager manager, String id)
-      {
-         super(manager);
-         ourId = id;
-      }
-      
-      @Override
-      public String getId()
-      {
-         return ourId;
-      }
-   }
-   
-   static class MockTransactionManagerLookup implements TransactionManagerLookup
-   {
-      public TransactionManager getTransactionManager() throws Exception
-      {
-         return new BatchModeTransactionManager();
-      }
-      
-   }
-
-}




More information about the jboss-cvs-commits mailing list