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

Manik Surtani msurtani at jboss.com
Tue Sep 19 09:52:33 EDT 2006


  User: msurtani
  Date: 06/09/19 09:52:33

  Modified:    tests/functional/org/jboss/cache/api  NodeMoveAPITest.java
  Log:
  Fixed moving with cache loaders
  
  Revision  Changes    Path
  1.5       +72 -6     JBossCache/tests/functional/org/jboss/cache/api/NodeMoveAPITest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeMoveAPITest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/api/NodeMoveAPITest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- NodeMoveAPITest.java	16 Sep 2006 12:03:55 -0000	1.4
  +++ NodeMoveAPITest.java	19 Sep 2006 13:52:33 -0000	1.5
  @@ -207,15 +207,25 @@
   
      public void testWithCacheloaders() throws Exception
      {
  +      doCacheLoaderTest(false);
  +   }
  +
  +   public void testWithPassivation() throws Exception
  +   {
  +      doCacheLoaderTest(true);
  +   }
  +
  +   protected void doCacheLoaderTest(boolean pasv) throws Exception
  +   {
         cache.stop();
  -      cache.getConfiguration().setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), null, false, false, false));
  +      cache.getConfiguration().setCacheLoaderConfiguration(getSingleCacheLoaderConfig(pasv, "", DummyInMemoryCacheLoader.class.getName(), null, false, false, false, false));
         cache.start();
   
         DummyInMemoryCacheLoader loader = (DummyInMemoryCacheLoader) cache.getCacheLoader();
   
         rootNode.put("key", "value");
   
  -      assertEquals("value", loader.get(Fqn.ROOT).get("key"));
  +      if (!pasv) assertEquals("value", loader.get(Fqn.ROOT).get("key"));
   
         nodeA = rootNode.addChild(A);
         nodeA.put(k, vA);
  @@ -249,14 +259,38 @@
         assertEquals(nodeC, nodeD.getParent());
         assertEquals(nodeD, nodeE.getParent());
   
  +      System.out.println("Loader" + loader);
  +
  +      System.out.println("Current tree is " + ((TreeCacheProxyImpl) cache).treeCache.printLockInfo());
  +
  +      cache.evict(Fqn.ROOT, true);
  +
  +      System.out.println("Current tree is " + ((TreeCacheProxyImpl) cache).treeCache.printLockInfo());
  +
         // move
         nodeC.move(nodeB);
   
  +      // after eviction, the node objects we hold are probably stale.
  +      nodeA = rootNode.getChild(A);
  +      nodeB = rootNode.getChild(B);
  +      nodeC = nodeB.getChild(C);
  +      nodeD = nodeC.getChild(D);
  +      nodeE = nodeD.getChild(E);
  +
  +
  +      System.out.println("Current tree is " + ((TreeCacheProxyImpl) cache).treeCache.printLockInfo());
  +
  +      Fqn old_C = new Fqn(C);
  +      Fqn old_D = new Fqn(old_C, D);
  +      Fqn old_E = new Fqn(old_D, E);
  +
  +
         assertTrue(rootNode.hasChild(A));
         assertTrue(rootNode.hasChild(B));
         assertFalse(rootNode.hasChild(C));
         assertFalse(nodeA.hasChild(C));
         assertTrue(nodeB.hasChild(C));
  +
         assertTrue(nodeC.hasChild(D));
         assertTrue(nodeD.hasChild(E));
   
  @@ -274,17 +308,19 @@
         assertEquals(nodeC, nodeD.getParent());
         assertEquals(nodeD, nodeE.getParent());
   
  +      if (pasv) cache.evict(Fqn.ROOT, true);
  +
         //now inspect the loader.
         assertEquals(vA, loader.get(nodeA.getFqn()).get(k));
         assertEquals(vB, loader.get(nodeB.getFqn()).get(k));
         assertEquals(vC, loader.get(nodeC.getFqn()).get(k));
         assertEquals(vD, loader.get(nodeD.getFqn()).get(k));
         assertEquals(vE, loader.get(nodeE.getFqn()).get(k));
  -   }
   
  -   public void testWithPassivation()
  -   {
  -      fail("implement me!");
  +      assertNull(loader.get(old_C));
  +      assertNull(loader.get(old_D));
  +      assertNull(loader.get(old_E));
  +
      }
   
      public void testLocksDeepMove() throws Exception
  @@ -410,5 +446,35 @@
            t.join();
         }
   
  +      assertEquals(0, ((TreeCacheProxyImpl) cache).treeCache.getNumberOfLocksHeld());
  +      boolean found_x = false, found_x_again = false;
  +      for (Node n : NODES)
  +      {
  +         if (!found_x)
  +         {
  +            found_x = n.hasChild(FQN_X);
  +         }
  +         else
  +         {
  +            found_x_again = found_x_again || n.hasChild(FQN_X);
  +         }
  +      }
  +      boolean found_y = false, found_y_again = false;
  +      for (Node n : NODES)
  +      {
  +         if (!found_y)
  +         {
  +            found_y = n.hasChild(FQN_Y);
  +         }
  +         else
  +         {
  +            found_y_again = found_y_again || n.hasChild(FQN_Y);
  +         }
  +      }
  +
  +      assertTrue("Should have found x", found_x);
  +      assertTrue("Should have found y", found_y);
  +      assertFalse("Should have only found x once", found_x_again);
  +      assertFalse("Should have only found y once", found_y_again);
      }
   }
  
  
  



More information about the jboss-cvs-commits mailing list