[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/marshall ...

Manik Surtani msurtani at jboss.com
Fri Jan 19 11:00:32 EST 2007


  User: msurtani
  Date: 07/01/19 11:00:32

  Modified:    tests/functional/org/jboss/cache/marshall    
                        AsyncReplTest.java ActiveInactiveTest.java
                        SyncReplTest.java RegionManagerTest.java
  Log:
  Improved Javadocs
  
  Revision  Changes    Path
  1.16      +53 -34    JBossCache/tests/functional/org/jboss/cache/marshall/AsyncReplTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AsyncReplTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/AsyncReplTest.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- AsyncReplTest.java	11 Jan 2007 13:49:05 -0000	1.15
  +++ AsyncReplTest.java	19 Jan 2007 16:00:32 -0000	1.16
  @@ -12,9 +12,10 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   import org.apache.commons.logging.LogFactory;
  -import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.CacheSPI;
   import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
  +import org.jboss.cache.Region;
   import org.jboss.cache.config.Configuration.CacheMode;
   import org.jboss.cache.factories.UnitTestCacheFactory;
   import org.jboss.cache.marshall.data.Address;
  @@ -31,15 +32,16 @@
    * Test marshalling for async mode.
    *
    * @author Ben Wang
  - * @version $Revision: 1.15 $
  + * @version $Revision: 1.16 $
    */
   public class AsyncReplTest extends RegionBasedMarshallingTestBase
   {
  -   CacheImpl cache1, cache2;
  +   CacheSPI cache1, cache2;
      String props = null;
      Person ben_;
      Address addr_;
      Throwable ex_;
  +   private Fqn aop = Fqn.fromString("/aop");
   
      public void setUp() throws Exception
      {
  @@ -59,13 +61,12 @@
         ben_.setAddress(addr_);
   
         // Pause to give caches time to see each other
  -      TestingUtil.blockUntilViewsReceived(new CacheImpl[]{cache1, cache2}, 60000);
  +      TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
      }
   
  -   private CacheImpl createCache(String name) throws Exception
  +   private CacheSPI createCache(String name) throws Exception
      {
  -      CacheImpl cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
  -      cache.setConfiguration(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_ASYNC));
  +      CacheSPI cache = (CacheSPI) DefaultCacheFactory.getInstance().createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_ASYNC), false);
         cache.getConfiguration().setClusterName(name);
         // Use marshaller
         cache.getConfiguration().setUseRegionBasedMarshalling(true);
  @@ -77,7 +78,7 @@
      public void tearDown() throws Exception
      {
         super.tearDown();
  -      cache1.remove("/");
  +      cache1.removeNode(Fqn.ROOT);
         if (cache1 != null)
         {
            log("stopping cache1");
  @@ -99,19 +100,32 @@
      public void testCLSet2() throws Exception
      {
         ClassLoader cla = getClassLoader();
  -      cache1.registerClassLoader("/aop", cla);
  +
  +      Region existing = cache1.getRegion(aop, false);
  +      if (existing == null)
  +      {
  +         existing = cache1.getRegion(aop, true);
  +      }
  +      existing.registerContextClassLoader(cla);
  +
  +
         ClassLoader clb = getClassLoader();
  -      cache2.registerClassLoader("/aop", clb);
  +      existing = cache2.getRegion(aop, false);
  +      if (existing == null)
  +      {
  +         existing = cache2.getRegion(aop, true);
  +      }
  +      existing.registerContextClassLoader(clb);
   
  -      cache1.put("/aop", "person", ben_);
  -      cache1.put("alias", "person", ben_);
  +      cache1.put(aop, "person", ben_);
  +      cache1.put(new Fqn("alias"), "person", ben_);
   
         TestingUtil.sleepThread(1000);
         Object ben2 = null;
         try
         {
            // Can't cast it to Person. CCE will resutl.
  -         ben2 = cache2.get("/aop", "person");
  +         ben2 = cache2.get(aop, "person");
            assertNotNull(ben2);
            assertEquals(ben_.toString(), ben2.toString());
         }
  @@ -142,9 +156,9 @@
         try
         {
            // Can't cast it to Person. CCE will resutl.
  -         cache2.put("/aop", "person", ben2);
  +         cache2.put(aop, "person", ben2);
            TestingUtil.sleepThread(1000);
  -         Object ben3 = cache1.get("/aop", "person");
  +         Object ben3 = cache1.get(aop, "person");
            assertEquals(ben2.toString(), ben3.toString());
         }
         catch (Exception ex)
  @@ -158,27 +172,29 @@
      public void testPuts() throws Exception
      {
         ClassLoader cl = getClassLoader();
  -      cache1.registerClassLoader("/aop", cl);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cl);
         // Create an empty Person loaded by this classloader
         Object scopedBen1 = getPersonFromClassloader(cl);
   
         cl = getClassLoader();
  -      cache2.registerClassLoader("/aop", cl);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(cl);
         // Create another empty Person loaded by this classloader
         Object scopedBen2 = getPersonFromClassloader(cl);
   
  -      cache1.put("/aop/1", "person", ben_);
  -      cache1.put("/aop/2", "person", scopedBen1);
  +      cache1.put(Fqn.fromString("/aop/1"), "person", ben_);
  +      cache1.put(Fqn.fromString("/aop/2"), "person", scopedBen1);
         TestingUtil.sleepThread(1000);
   
         Object ben2 = null;
         try
         {
            // Can't cast it to Person. CCE will resutl.
  -         ben2 = cache2.get("/aop/1", "person");
  +         ben2 = cache2.get(Fqn.fromString("/aop/1"), "person");
            assertEquals(ben_.toString(), ben2.toString());
   
  -         ben2 = cache2.get("/aop/2", "person");
  +         ben2 = cache2.get(Fqn.fromString("/aop/2"), "person");
            assertFalse("cache2 deserialized with scoped classloader", ben2 instanceof Person);
            assertFalse("cache2 deserialized with cache2 classloader", scopedBen1.equals(ben2));
            assertEquals("scopedBen deserialized properly", scopedBen2, ben2);
  @@ -193,11 +209,11 @@
      public void testTxPut() throws Exception
      {
         Transaction tx = beginTransaction();
  -      cache1.put("/aop", "person", ben_);
  -      cache1.put("/aop", "person1", ben_);
  +      cache1.put(aop, "person", ben_);
  +      cache1.put(aop, "person1", ben_);
         tx.commit();
         TestingUtil.sleepThread(1000);
  -      Person ben2 = (Person) cache2.get("/aop", "person");
  +      Person ben2 = (Person) cache2.get(aop, "person");
         assertNotNull("Person from 2nd cache should not be null ", ben2);
         assertEquals(ben_.toString(), ben2.toString());
      }
  @@ -205,12 +221,14 @@
      public void testTxCLSet2() throws Exception
      {
         ClassLoader cla = getClassLoader();
  -      cache1.registerClassLoader("/aop", cla);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cla);
         ClassLoader clb = getClassLoader();
  -      cache2.registerClassLoader("/aop", clb);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(clb);
   
         Transaction tx = beginTransaction();
  -      cache1.put("/aop", "person", ben_);
  +      cache1.put(aop, "person", ben_);
         tx.commit();
         TestingUtil.sleepThread(1000);
   
  @@ -218,7 +236,7 @@
         try
         {
            // Can't cast it to Person. CCE will resutl.
  -         ben2 = cache2.get("/aop", "person");
  +         ben2 = cache2.get(aop, "person");
            assertEquals(ben_.toString(), ben2.toString());
         }
         catch (Exception ex)
  @@ -247,9 +265,9 @@
         try
         {
            // Can't cast it to Person. CCE will resutl.
  -         cache2.put("/aop", "person", ben2);
  +         cache2.put(aop, "person", ben2);
            TestingUtil.sleepThread(1000);
  -         Object ben3 = cache1.get("/aop", "person");
  +         Object ben3 = cache1.get(aop, "person");
            assertEquals(ben2.toString(), ben3.toString());
         }
         catch (Exception ex)
  @@ -266,12 +284,13 @@
   
      public void testCustomFqn() throws Exception
      {
  -      // FIXME work via the Cache API
  -
         FooClassLoader cl1 = new FooClassLoader(Thread.currentThread().getContextClassLoader());
  -      cache1.registerClassLoader("/aop", cl1);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cl1);
  +
         FooClassLoader cl2 = new FooClassLoader(Thread.currentThread().getContextClassLoader());
  -      cache2.registerClassLoader("/aop", cl2);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(cl2);
   
         Class clazz = cl1.loadFoo();
         Object custom1 = clazz.newInstance();
  
  
  
  1.15      +45 -41    JBossCache/tests/functional/org/jboss/cache/marshall/ActiveInactiveTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ActiveInactiveTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/ActiveInactiveTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- ActiveInactiveTest.java	17 Jan 2007 17:21:37 -0000	1.14
  +++ ActiveInactiveTest.java	19 Jan 2007 16:00:32 -0000	1.15
  @@ -11,6 +11,7 @@
   import org.jboss.cache.CacheImpl;
   import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
  +import org.jboss.cache.Region;
   import org.jboss.cache.RegionManager;
   import org.jboss.cache.Version;
   
  @@ -26,6 +27,9 @@
   {
      RegionManager rman;
      CacheImpl c;
  +   Fqn A = Fqn.fromString("/a");
  +   Fqn I = Fqn.fromString("/i");
  +   Fqn A_B = new Fqn(A, "b");
   
      @Override
      protected void setUp() throws Exception
  @@ -50,101 +54,101 @@
      public void testDefaultActive() throws Exception
      {
         rman.setDefaultInactive(false);
  -      assertFalse("Root is not active", rman.isInactive("/"));
  +      assertFalse("Root is not active", rman.isInactive(Fqn.ROOT));
   
  -      rman.deactivate("/a");
  +      rman.deactivate(A);
         assertFalse("Root is not active after inactivating subtree",
  -              rman.isInactive("/"));
  +              rman.isInactive(Fqn.ROOT));
   
  -      rman.activate("/a");
  +      rman.activate(A);
         assertFalse("Root is not active after activating subtree",
  -              rman.isInactive("/"));
  +              rman.isInactive(Fqn.ROOT));
   
  -      rman.activate("/a/b");
  +      rman.activate(A_B);
   
  -      rman.deactivate("/");
  -      assertTrue("Root is active", rman.isInactive("/"));
  +      rman.deactivate(Fqn.ROOT);
  +      assertTrue("Root is active", rman.isInactive(Fqn.ROOT));
      }
   
      public void testDefaultInactive() throws Exception
      {
         rman.setDefaultInactive(true);
   
  -      assertTrue("Root is not inactive", rman.isInactive("/"));
  +      assertTrue("Root is not inactive", rman.isInactive(Fqn.ROOT));
   
  -      rman.activate("/a");
  +      rman.activate(A);
         assertTrue("Root is not inactive after activating subtree",
  -              rman.isInactive("/"));
  +              rman.isInactive(Fqn.ROOT));
   
  -      rman.deactivate("/a");
  +      rman.deactivate(A);
         assertTrue("Root is not inactive after inactivating subtree",
  -              rman.isInactive("/"));
  +              rman.isInactive(Fqn.ROOT));
   
  -      rman.deactivate("/a/b");
  +      rman.deactivate(A_B);
   
  -      rman.activate("/");
  -      assertFalse("Root is not active", rman.isInactive("/"));
  +      rman.activate(Fqn.ROOT);
  +      assertFalse("Root is not active", rman.isInactive(Fqn.ROOT));
      }
   
      public void testActivate() throws Exception
      {
         rman.setDefaultInactive(false);
  -      rman.activate("/a");
  +      rman.activate(A);
         assertFalse("/a is not active after activating",
  -              rman.isInactive("/a"));
  +              rman.isInactive(A));
   
  -      rman.deactivate("/a");
  -      rman.activate("/a");
  +      rman.deactivate(A);
  +      rman.activate(A);
         assertFalse("/a is not active after reactivating",
  -              rman.isInactive("/a"));
  +              rman.isInactive(A));
   
         rman.reset();
         rman.setDefaultInactive(true);
   
  -      rman.activate("/i");
  +      rman.activate(I);
         assertFalse("/i is not active after activating",
  -              rman.isInactive("/i"));
  +              rman.isInactive(I));
         assertFalse("/i/k is not active after activating /i",
  -              rman.isInactive("/i/k"));
  +              rman.isInactive(Fqn.fromString("/i/k")));
   
  -      rman.deactivate("/i");
  -      rman.activate("/i");
  +      rman.deactivate(I);
  +      rman.activate(I);
         assertFalse("/i is not active after reactivating",
  -              rman.isInactive("/i"));
  +              rman.isInactive(I));
      }
   
      public void testInactivate() throws Exception
      {
         rman.setDefaultInactive(true);
   
  -      rman.deactivate("/i");
  +      rman.deactivate(I);
         assertTrue("/i is not inactive after inactivating",
  -              rman.isInactive("/i"));
  +              rman.isInactive(I));
   
  -      rman.activate("/i");
  -      rman.deactivate("/i");
  +      rman.activate(I);
  +      rman.deactivate(I);
         assertTrue("/i is not inactive after re-inactivating",
  -              rman.isInactive("/i"));
  +              rman.isInactive(I));
   
         rman.reset();
         rman.setDefaultInactive(false);
   
  -      rman.deactivate("/a");
  +      rman.deactivate(A);
         assertTrue("/a is not inactive after inactivating",
  -              rman.isInactive("/a"));
  +              rman.isInactive(A));
         assertTrue("/a/b is not inactive after inactivating /a",
  -              rman.isInactive("/a/b"));
  +              rman.isInactive(A_B));
   
  -      rman.activate("/a");
  -      rman.deactivate("/a");
  +      rman.activate(A);
  +      rman.deactivate(A);
         assertTrue("/a is not inactive after re-inactivating",
  -              rman.isInactive("/a"));
  +              rman.isInactive(A));
      }
   
      public void testObjectFromByteBuffer() throws Exception
      {
         MethodCall put = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal,
  -              null, Fqn.fromString("/a/b"), "name", "Joe", false);
  +              null, A_B, "name", "Joe", false);
   
         MethodCall replicate = MethodCallFactory.create(MethodDeclarations.replicateMethod, put);
   
  @@ -162,8 +166,8 @@
            // expected to fail since region is inactive
         }
   
  -      rman.activate("/a");
  -      assertTrue(rman.hasRegion(Fqn.fromString("/a")));
  +      rman.activate(A);
  +      assertTrue(rman.hasRegion(A, Region.Type.ANY));
   
         MethodCall result = (MethodCall) testee.objectFromByteBuffer(callBytes);
         Method method = result.getMethod();
  
  
  
  1.17      +87 -71    JBossCache/tests/functional/org/jboss/cache/marshall/SyncReplTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SyncReplTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/SyncReplTest.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- SyncReplTest.java	11 Jan 2007 13:49:05 -0000	1.16
  +++ SyncReplTest.java	19 Jan 2007 16:00:32 -0000	1.17
  @@ -11,13 +11,12 @@
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  -import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.CacheSPI;
   import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.config.Configuration;
  +import org.jboss.cache.Region;
   import org.jboss.cache.config.Configuration.CacheMode;
   import org.jboss.cache.factories.UnitTestCacheFactory;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.marshall.data.Address;
   import org.jboss.cache.marshall.data.Person;
   import org.jboss.cache.misc.TestingUtil;
  @@ -33,15 +32,16 @@
    * Test case for marshalling using Sync mode.
    *
    * @author Ben Wang
  - * @version $Revision: 1.16 $
  + * @version $Revision: 1.17 $
    */
   public class SyncReplTest extends RegionBasedMarshallingTestBase
   {
  -   CacheImpl cache1, cache2;
  +   CacheSPI cache1, cache2;
      String props = null;
      Person ben_;
      Address addr_;
      Throwable ex_;
  +   private Fqn aop = Fqn.fromString("/aop");
   
      public void setUp() throws Exception
      {
  @@ -60,20 +60,15 @@
         ben_.setAddress(addr_);
   
         // Pause to give caches time to see each other
  -      TestingUtil.blockUntilViewsReceived(new CacheImpl[]{cache1, cache2}, 60000);
  +      TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
      }
   
  -   private CacheImpl createCache(String name) throws Exception
  +   private CacheSPI createCache(String name) throws Exception
      {
  -      CacheImpl cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
  -
  -      XmlConfigurationParser parser = new XmlConfigurationParser();
  -      Configuration c = UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC);
  -      cache.setConfiguration(c);
  -
  -      c.setClusterName(name);
  +      CacheSPI cache = (CacheSPI) DefaultCacheFactory.getInstance().createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), false);
  +      cache.getConfiguration().setClusterName(name);
         // Use marshaller
  -      c.setUseRegionBasedMarshalling(true);
  +      cache.getConfiguration().setUseRegionBasedMarshalling(true);
         cache.create();
         cache.start();
         return cache;
  @@ -82,7 +77,7 @@
      public void tearDown() throws Exception
      {
         super.tearDown();
  -      cache1.remove("/");
  +      cache1.removeNode(Fqn.ROOT);
         if (cache1 != null)
         {
            log("stopping cache1");
  @@ -98,8 +93,8 @@
   
      public void testPlainPut() throws Exception
      {
  -      cache1.put("/aop", "person", ben_);
  -      Person ben2 = (Person) cache2.get("/aop", "person");
  +      cache1.put(aop, "person", ben_);
  +      Person ben2 = (Person) cache2.get(aop, "person");
         assertNotNull("Person from 2nd cache should not be null ", ben2);
         assertEquals(ben_.toString(), ben2.toString());
      }
  @@ -107,14 +102,17 @@
      public void testCCE() throws Exception
      {
         ClassLoader cl = getClassLoader();
  -      cache1.registerClassLoader("/aop", cl);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cl);
  +
         cl = getClassLoader();
  -      cache2.registerClassLoader("/aop", cl);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(cl);
   
  -      cache1.put("/aop", "person", ben_);
  +      cache1.put(aop, "person", ben_);
         try
         {
  -         Person ben2 = (Person) cache2.get("/aop", "person");
  +         Person ben2 = (Person) cache2.get(aop, "person");
         }
         catch (ClassCastException ex)
         {
  @@ -127,30 +125,34 @@
      public void testPut() throws Exception
      {
         ClassLoader cla = getClassLoader();
  -      cache1.registerClassLoader("/aop", cla);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cla);
         ClassLoader clb = getClassLoader();
  -      cache2.registerClassLoader("/aop", clb);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(clb);
   
  -      cache1.put("/aop", "person", ben_);
  +      cache1.put(aop, "person", ben_);
   
         Object ben2;
         // Can't cast it to Person. CCE will resutl.
  -      ben2 = cache2.get("/aop", "person");
  +      ben2 = cache2.get(aop, "person");
         assertEquals(ben_.toString(), ben2.toString());
      }
   
      public void testCLSet() throws Exception
      {
         ClassLoader cla = getClassLoader();
  -      cache1.registerClassLoader("/aop", cla);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cla);
         ClassLoader clb = getClassLoader();
  -      cache2.registerClassLoader("/aop", clb);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(clb);
   
  -      cache1.put("/aop", "person", ben_);
  +      cache1.put(aop, "person", ben_);
   
         Object ben2;
         // Can't cast it to Person. CCE will resutl.
  -      ben2 = cache2.get("/aop", "person");
  +      ben2 = cache2.get(aop, "person");
         assertEquals(ben_.toString(), ben2.toString());
   
         Class claz = clb.loadClass(ADDRESS_CLASSNAME);
  @@ -179,15 +181,17 @@
      public void testCLSet2() throws Exception
      {
         ClassLoader cla = getClassLoader();
  -      cache1.registerClassLoader("/aop", cla);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cla);
         ClassLoader clb = getClassLoader();
  -      cache2.registerClassLoader("/aop", clb);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(clb);
   
  -      cache1.put("/aop", "person", ben_);
  +      cache1.put(aop, "person", ben_);
   
         Object ben2;
         // Can't cast it to Person. CCE will resutl.
  -      ben2 = cache2.get("/aop", "person");
  +      ben2 = cache2.get(aop, "person");
         assertEquals(ben_.toString(), ben2.toString());
   
         Class claz = clb.loadClass(ADDRESS_CLASSNAME);
  @@ -209,8 +213,8 @@
   
         // Set it back to the cache
         // Can't cast it to Person. CCE will resutl.
  -      cache2.put("/aop", "person", ben2);
  -      Object ben3 = cache1.get("/aop", "person");
  +      cache2.put(aop, "person", ben2);
  +      Object ben3 = cache1.get(aop, "person");
         assertEquals(ben2.toString(), ben3.toString());
   
      }
  @@ -218,26 +222,30 @@
      public void testPuts() throws Exception
      {
         ClassLoader cl = getClassLoader();
  -      cache1.registerClassLoader("/aop", cl);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cl);
  +
         // Create an empty Person loaded by this classloader
         Object scopedBen1 = getPersonFromClassloader(cl);
   
         cl = getClassLoader();
  -      cache2.registerClassLoader("/aop", cl);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(cl);
  +
         // Create another empty Person loaded by this classloader
         Object scopedBen2 = getPersonFromClassloader(cl);
   
  -      cache1.put("/aop/1", "person", ben_);
  -      cache1.put("/aop/2", "person", scopedBen1);
  +      cache1.put(Fqn.fromString("/aop/1"), "person", ben_);
  +      cache1.put(Fqn.fromString("/aop/2"), "person", scopedBen1);
   
         Object ben2 = null;
         try
         {
            // Can't cast it to Person. CCE will resutl.
  -         ben2 = cache2.get("/aop/1", "person");
  +         ben2 = cache2.get(Fqn.fromString("/aop/1"), "person");
            assertEquals(ben_.toString(), ben2.toString());
   
  -         ben2 = cache2.get("/aop/2", "person");
  +         ben2 = cache2.get(Fqn.fromString("/aop/2"), "person");
            assertFalse("cache2 deserialized with scoped classloader", ben2 instanceof Person);
            assertFalse("cache2 deserialized with cache2 classloader", scopedBen1.equals(ben2));
            assertEquals("scopedBen deserialized properly", scopedBen2, ben2);
  @@ -252,17 +260,19 @@
      public void testMethodCall() throws Exception
      {
         ClassLoader cl = getClassLoader();
  -      cache1.registerClassLoader("/aop", cl);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cl);
         cl = getClassLoader();
  -      cache2.registerClassLoader("/aop", cl);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(cl);
   
  -      cache1.put("/aop/1", "person", ben_);
  -      cache1.remove("/aop/1", "person");
  +      cache1.put(Fqn.fromString("/aop/1"), "person", ben_);
  +      cache1.remove(Fqn.fromString("/aop/1"), "person");
         HashMap map = new HashMap();
         map.put("1", "1");
         map.put("2", "2");
  -      cache1.put("/aop/2", map);
  -      cache1.remove("/aop/2");
  +      cache1.put(Fqn.fromString("/aop/2"), map);
  +      cache1.removeNode(Fqn.fromString("/aop/2"));
   
         TestingUtil.sleepThread(1000);
      }
  @@ -270,18 +280,20 @@
      public void testTxMethodCall() throws Exception
      {
         ClassLoader cl = getClassLoader();
  -      cache1.registerClassLoader("/aop", cl);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cl);
         cl = getClassLoader();
  -      cache2.registerClassLoader("/aop", cl);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(cl);
   
         Transaction tx = beginTransaction();
  -      cache1.put("/aop/1", "person", ben_);
  -      cache1.remove("/aop/1", "person");
  +      cache1.put(Fqn.fromString("/aop/1"), "person", ben_);
  +      cache1.remove(Fqn.fromString("/aop/1"), "person");
         HashMap map = new HashMap();
         map.put("1", "1");
         map.put("2", "2");
  -      cache1.put("/aop/2", map);
  -      cache1.remove("/aop/2");
  +      cache1.put(Fqn.fromString("/aop/2"), map);
  +      cache1.removeNode(Fqn.fromString("/aop/2"));
         tx.commit();
   
         TestingUtil.sleepThread(1000);
  @@ -290,12 +302,12 @@
      public void testTxPut() throws Exception
      {
         Transaction tx = beginTransaction();
  -      cache1.put("/aop", "person", ben_);
  -      cache1.put("/aop", "person1", ben_);
  -      cache1.remove("/aop");
  -      cache1.put("/aop", "person", ben_);
  +      cache1.put(aop, "person", ben_);
  +      cache1.put(aop, "person1", ben_);
  +      cache1.removeNode(aop);
  +      cache1.put(aop, "person", ben_);
         tx.commit();
  -      Person ben2 = (Person) cache2.get("/aop", "person");
  +      Person ben2 = (Person) cache2.get(aop, "person");
         assertNotNull("Person from 2nd cache should not be null ", ben2);
         assertEquals(ben_.toString(), ben2.toString());
      }
  @@ -303,27 +315,29 @@
      public void testTxRollback() throws Exception
      {
         Transaction tx = beginTransaction();
  -      cache1.put("/aop", "person", ben_);
  -      cache1.put("/aop", "person1", ben_);
  +      cache1.put(aop, "person", ben_);
  +      cache1.put(aop, "person1", ben_);
         tx.rollback();
  -      Person ben2 = (Person) cache2.get("/aop", "person");
  +      Person ben2 = (Person) cache2.get(aop, "person");
         assertNull("Person from 2nd cache should be null ", ben2);
      }
   
      public void testTxCLSet2() throws Exception
      {
         ClassLoader cla = getClassLoader();
  -      cache1.registerClassLoader("/aop", cla);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cla);
         ClassLoader clb = getClassLoader();
  -      cache2.registerClassLoader("/aop", clb);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(clb);
   
         Transaction tx = beginTransaction();
  -      cache1.put("/aop", "person", ben_);
  +      cache1.put(aop, "person", ben_);
         tx.commit();
   
         Object ben2;
         // Can't cast it to Person. CCE will resutl.
  -      ben2 = cache2.get("/aop", "person");
  +      ben2 = cache2.get(aop, "person");
         assertEquals(ben_.toString(), ben2.toString());
   
         Class claz = clb.loadClass(ADDRESS_CLASSNAME);
  @@ -345,8 +359,8 @@
   
         // Set it back to the cache
         // Can't cast it to Person. CCE will resutl.
  -      cache2.put("/aop", "person", ben2);
  -      Object ben3 = cache1.get("/aop", "person");
  +      cache2.put(aop, "person", ben2);
  +      Object ben3 = cache1.get(aop, "person");
         assertEquals(ben2.toString(), ben3.toString());
      }
   
  @@ -358,9 +372,11 @@
      public void testCustomFqn() throws Exception
      {
         FooClassLoader cl1 = new FooClassLoader(Thread.currentThread().getContextClassLoader());
  -      cache1.registerClassLoader("/aop", cl1);
  +      Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
  +      r1.registerContextClassLoader(cl1);
         FooClassLoader cl2 = new FooClassLoader(Thread.currentThread().getContextClassLoader());
  -      cache2.registerClassLoader("/aop", cl2);
  +      Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
  +      r2.registerContextClassLoader(cl2);
   
         Class clazz = cl1.loadFoo();
         Object custom1 = clazz.newInstance();
  @@ -368,7 +384,7 @@
         clazz = cl2.loadFoo();
         Object custom2 = clazz.newInstance();
   
  -      Fqn base = Fqn.fromString("/aop");
  +      Fqn base = aop;
         cache1.put(new Fqn(base, custom1), "key", "value");
   
         try
  
  
  
  1.11      +23 -23    JBossCache/tests/functional/org/jboss/cache/marshall/RegionManagerTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RegionManagerTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/RegionManagerTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- RegionManagerTest.java	18 Jan 2007 16:55:20 -0000	1.10
  +++ RegionManagerTest.java	19 Jan 2007 16:00:32 -0000	1.11
  @@ -65,7 +65,7 @@
         Collections.sort(expected);
         Iterator<Region> expectedRegions = expected.iterator();
   
  -      for (Region reg : r.getAllMarshallingRegions())
  +      for (Region reg : r.getAllRegions(Region.Type.MARSHALLING))
         {
            assertSame("Unexpected region " + reg, expectedRegions.next(), reg);
         }
  @@ -118,28 +118,28 @@
         Region r2 = r.getRegion(fqn2, true);
         Region r3 = r.getRegion(fqn3, true);
   
  -      assertEquals("Expecting 3 regions", 3, r.getAllRegions().size());
  +      assertEquals("Expecting 3 regions", 3, r.getAllRegions(Region.Type.ANY).size());
   
         // test that removal doesn't affect parent traversal.
         assertEquals(r3, r.getRegion(fqn3, false));
   
  -      r.removeRegion(fqn3);
  +      r.removeRegion(Fqn.fromString(fqn3));
   
  -      assertEquals("Expecting 2 regions", 2, r.getAllRegions().size());
  +      assertEquals("Expecting 2 regions", 2, r.getAllRegions(Region.Type.ANY).size());
   
         // test that removal doesn't affect parent traversal.
         assertEquals("Should have retrieved parent region", r2, r.getRegion(fqn3, false));
   
  -      r.removeRegion(fqn2);
  +      r.removeRegion(Fqn.fromString(fqn2));
   
  -      assertEquals("Expecting 1 region", 1, r.getAllRegions().size());
  +      assertEquals("Expecting 1 region", 1, r.getAllRegions(Region.Type.ANY).size());
   
         // test that removal doesn't affect parent traversal.
         assertEquals("Should have retrieved parent region", r1, r.getRegion(fqn3, false));
   
  -      r.removeRegion(fqn1);
  +      r.removeRegion(Fqn.fromString(fqn1));
   
  -      assertEquals("Expecting 0 regions", 0, r.getAllRegions().size());
  +      assertEquals("Expecting 0 regions", 0, r.getAllRegions(Region.Type.ANY).size());
      }
   
      public void testGetRegionsMethods()
  @@ -150,38 +150,38 @@
   
         Region r1 = r.getRegion(f1, true), r2 = r.getRegion(f2, true), r3 = r.getRegion(f3, true), r4 = r.getRegion(f4, true);
   
  -      assertEquals("4 regions should exist", 4, r.getAllRegions().size());
  +      assertEquals("4 regions should exist", 4, r.getAllRegions(Region.Type.ANY).size());
   
  -      assertEquals("None of the regions should marshalling or active", 0, r.getAllMarshallingRegions().size());
  +      assertEquals("None of the regions should marshalling or active", 0, r.getAllRegions(Region.Type.MARSHALLING).size());
   
         r3.registerContextClassLoader(getClass().getClassLoader());
         r3.activate();
   
  -      assertEquals("r3 should be marshalling and active", 1, r.getAllMarshallingRegions().size());
  -      assertSame("r3 should be marshalling and active", r3, r.getAllMarshallingRegions().get(0));
  +      assertEquals("r3 should be marshalling and active", 1, r.getAllRegions(Region.Type.MARSHALLING).size());
  +      assertSame("r3 should be marshalling and active", r3, r.getAllRegions(Region.Type.MARSHALLING).get(0));
   
         r4.activate();// but don't se a class loader
   
  -      assertEquals("r3 should be marshalling and active", 1, r.getAllMarshallingRegions().size());
  -      assertSame("r3 should be marshalling and active", r3, r.getAllMarshallingRegions().get(0));
  +      assertEquals("r3 should be marshalling and active", 1, r.getAllRegions(Region.Type.MARSHALLING).size());
  +      assertSame("r3 should be marshalling and active", r3, r.getAllRegions(Region.Type.MARSHALLING).get(0));
   
         r2.registerContextClassLoader(getClass().getClassLoader());// but don't activate
   
  -      assertEquals("r3 should be marshalling and active", 1, r.getAllMarshallingRegions().size());
  -      assertSame("r3 should be marshalling and active", r3, r.getAllMarshallingRegions().get(0));
  +      assertEquals("r3 should be marshalling and active", 1, r.getAllRegions(Region.Type.MARSHALLING).size());
  +      assertSame("r3 should be marshalling and active", r3, r.getAllRegions(Region.Type.MARSHALLING).get(0));
   
         r2.activate();
   
  -      assertEquals("r2 + r3 should be marshalling and active", 2, r.getAllMarshallingRegions().size());
  -      assertSame("r2 should be marshalling and active", r2, r.getAllMarshallingRegions().get(0));
  -      assertSame("r3 should be marshalling and active", r3, r.getAllMarshallingRegions().get(1));
  +      assertEquals("r2 + r3 should be marshalling and active", 2, r.getAllRegions(Region.Type.MARSHALLING).size());
  +      assertSame("r2 should be marshalling and active", r2, r.getAllRegions(Region.Type.MARSHALLING).get(0));
  +      assertSame("r3 should be marshalling and active", r3, r.getAllRegions(Region.Type.MARSHALLING).get(1));
   
         r4.registerContextClassLoader(getClass().getClassLoader());
   
  -      assertEquals("r2 + r3 + r4 should be marshalling and active", 3, r.getAllMarshallingRegions().size());
  -      assertSame("r2 should be marshalling and active", r2, r.getAllMarshallingRegions().get(0));
  -      assertSame("r3 should be marshalling and active", r3, r.getAllMarshallingRegions().get(1));
  -      assertSame("r4 should be marshalling and active", r4, r.getAllMarshallingRegions().get(2));
  +      assertEquals("r2 + r3 + r4 should be marshalling and active", 3, r.getAllRegions(Region.Type.MARSHALLING).size());
  +      assertSame("r2 should be marshalling and active", r2, r.getAllRegions(Region.Type.MARSHALLING).get(0));
  +      assertSame("r3 should be marshalling and active", r3, r.getAllRegions(Region.Type.MARSHALLING).get(1));
  +      assertSame("r4 should be marshalling and active", r4, r.getAllRegions(Region.Type.MARSHALLING).get(2));
   
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list