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

Manik Surtani msurtani at jboss.com
Mon Nov 13 09:20:31 EST 2006


  User: msurtani
  Date: 06/11/13 09:20:31

  Modified:    tests/functional/org/jboss/cache/loader  
                        CacheLoaderTestsBase.java
                        CacheLoaderWithReplicationTest.java
  Log:
  Fixed test suite failures
  
  Revision  Changes    Path
  1.35      +110 -45   JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderTestsBase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderTestsBase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderTestsBase.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -b -r1.34 -r1.35
  --- CacheLoaderTestsBase.java	25 Oct 2006 04:50:19 -0000	1.34
  +++ CacheLoaderTestsBase.java	13 Nov 2006 14:20:31 -0000	1.35
  @@ -31,7 +31,7 @@
    * Commons tests for all CacheLoaders
    *
    * @author Bela Ban
  - * @version $Id: CacheLoaderTestsBase.java,v 1.34 2006/10/25 04:50:19 bstansberry Exp $
  + * @version $Id: CacheLoaderTestsBase.java,v 1.35 2006/11/13 14:20:31 msurtani Exp $
    */
   abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
   {
  @@ -99,7 +99,7 @@
   
      protected void addDelay()
      {
  -      ; // returns immediately in this case.  Subclasses may override where a delay is needed.
  +      ;// returns immediately in this case.  Subclasses may override where a delay is needed.
      }
   
      protected void clean(File dir)
  @@ -145,7 +145,7 @@
         retval = cache.put(NODE, KEY, new Integer(20));
         addDelay();
         assertEquals(new Integer(10), retval);
  -      cache.evict(Fqn.fromString(NODE)); // evicts from memory, but *not* from store
  +      cache.evict(Fqn.fromString(NODE));// evicts from memory, but *not* from store
         addDelay();
         log.debug("put 30, expect 20 back");
         retval = cache.put(NODE, KEY, new Integer(30));
  @@ -166,7 +166,7 @@
         addDelay();
         retval = cache.put(NODE, KEY, new Integer(20));
         assertEquals(new Integer(10), retval);
  -      cache.evict(Fqn.fromString(NODE)); // evicts from memory, but *not* from store
  +      cache.evict(Fqn.fromString(NODE));// evicts from memory, but *not* from store
         cache.evict(Fqn.fromString("/a/b"));
         cache.evict(Fqn.fromString("/a"));
         addDelay();
  @@ -207,6 +207,69 @@
         assertEquals("combined", 4, cache.get(NODE).getData().size());
      }
   
  +   public void testShallowMove() throws Exception
  +   {
  +      Fqn a = Fqn.fromString("/a");
  +      Fqn b = Fqn.fromString("/b");
  +      Fqn a_b = Fqn.fromString("/a/b");
  +      String key = "key", valueA = "A", valueB = "B";
  +
  +      cache.put(a, key, valueA);
  +      cache.put(b, key, valueB);
  +
  +      addDelay();
  +
  +      assertEquals(valueA, cache.getCacheLoader().get(a).get(key));
  +      assertEquals(valueB, cache.getCacheLoader().get(b).get(key));
  +      assertTrue(cache.getCacheLoader().getChildrenNames(Fqn.ROOT).contains("a"));
  +      assertTrue(cache.getCacheLoader().getChildrenNames(Fqn.ROOT).contains("b"));
  +
  +      // now move
  +      cache.move(a, b);
  +
  +      addDelay();
  +
  +      assertEquals(valueA, cache.getCacheLoader().get(a).get(key));
  +      assertNull(cache.getCacheLoader().get(b));
  +      assertEquals(valueB, cache.getCacheLoader().get(a_b).get(key));
  +
  +   }
  +
  +   public void testDeepMove() throws Exception
  +   {
  +      Fqn a = Fqn.fromString("/a");
  +      Fqn b = Fqn.fromString("/b");
  +      Fqn a_b = Fqn.fromString("/a/b");
  +      Fqn b_c = Fqn.fromString("/b/c");
  +      Fqn a_b_c = Fqn.fromString("/a/b/c");
  +
  +      String key = "key", valueA = "A", valueB = "B", valueC = "C";
  +
  +      cache.put(a, key, valueA);
  +      cache.put(b, key, valueB);
  +      cache.put(b_c, key, valueC);
  +
  +
  +      addDelay();
  +
  +      assertEquals(valueA, cache.getCacheLoader().get(a).get(key));
  +      assertEquals(valueB, cache.getCacheLoader().get(b).get(key));
  +      assertEquals(valueC, cache.getCacheLoader().get(b_c).get(key));
  +
  +      // now move
  +      cache.move(a, b);
  +
  +      addDelay();
  +
  +      assertEquals(valueA, cache.getCacheLoader().get(a).get(key));
  +      assertNull(cache.getCacheLoader().get(b));
  +      assertEquals(valueB, cache.getCacheLoader().get(a_b).get(key));
  +      assertNull(cache.getCacheLoader().get(b_c));
  +      assertEquals(valueC, cache.getCacheLoader().get(a_b_c).get(key));
  +
  +   }
  +
  +
      /**
       * Tests various put combos which should exercise the CacheLoaderInterceptor.
       */
  @@ -285,7 +348,7 @@
         assertNotNull(cache.get("/mypojo", new Integer(322649)));
         cache.evict(Fqn.fromString("/mypojo"));
         assertFalse(cache.exists("/mypojo"));
  -      SamplePojo pojo2 = (SamplePojo) cache.get("/mypojo", new Integer(322649)); // should fetch from CacheLoader
  +      SamplePojo pojo2 = (SamplePojo) cache.get("/mypojo", new Integer(322649));// should fetch from CacheLoader
         assertNotNull(pojo2);
         assertEquals(39, pojo2.getAge());
         assertEquals("Bela", pojo2.getName());
  @@ -336,8 +399,8 @@
         cache.evict(Fqn.fromString("1/2/3/4/5/d"));
         System.out.println("-- checking for 1/2/3/4/5/d");
         addDelay();
  -      assertFalse(cache.exists("1/2/3/4/5/d")); // exists() doesn't load
  -      cache.get("1/2/3/4/5/d"); // get *does* load
  +      assertFalse(cache.exists("1/2/3/4/5/d"));// exists() doesn't load
  +      cache.get("1/2/3/4/5/d");// get *does* load
         assertTrue(cache.exists("1/2/3/4/5/d"));
         System.out.println("-- 1/2/3/4/5/d exists");
      }
  @@ -818,12 +881,12 @@
         retval = cache.put(NODE, KEY, new Integer(10));
         assertNull(retval);
   
  -      cache.evict(Fqn.fromString(NODE)); // evicts from memory, but *not* from store
  +      cache.evict(Fqn.fromString(NODE));// evicts from memory, but *not* from store
         addDelay();
         retval = cache.remove(NODE, KEY);
         assertEquals(new Integer(10), retval);
   
  -      cache.evict(Fqn.fromString(NODE)); // evicts from memory, but *not* from store
  +      cache.evict(Fqn.fromString(NODE));// evicts from memory, but *not* from store
         addDelay();
         retval = cache.remove(NODE, KEY);
         assertNull(retval);
  @@ -860,14 +923,14 @@
   
      public void testEvictionWithCacheLoader() throws Exception
      {
  -      cache.put("/first/second", "key1", "val1");        // stored in cache loader
  -      cache.put("/first/second/third", "key2", "val2"); // stored in cache loader
  -      cache.evict(Fqn.fromString("/first/second"));      // doesn't remove node, just data !
  +      cache.put("/first/second", "key1", "val1");// stored in cache loader
  +      cache.put("/first/second/third", "key2", "val2");// stored in cache loader
  +      cache.evict(Fqn.fromString("/first/second"));// doesn't remove node, just data !
         addDelay();
         assertTrue(cache.exists("/first/second/third"));
         assertTrue(cache.exists("/first/second"));
         assertTrue(cache.exists("/first"));
  -      String val = (String) cache.get("/first/second", "key1"); // should be loaded from cache loader
  +      String val = (String) cache.get("/first/second", "key1");// should be loaded from cache loader
         assertEquals("val1", val);
         assertTrue(cache.exists("/first/second/third"));
         assertTrue(cache.exists("/first/second"));
  @@ -877,13 +940,13 @@
   
      public void testEvictionWithCacheLoader2() throws Exception
      {
  -      cache.put("/first/second/third", "key1", "val1");   // stored in cache loader
  -      cache.evict(Fqn.fromString("/first/second/third"));  // removes node, because there are no children
  +      cache.put("/first/second/third", "key1", "val1");// stored in cache loader
  +      cache.evict(Fqn.fromString("/first/second/third"));// removes node, because there are no children
         addDelay();
         assertFalse(cache.exists("/first/second/third"));
         assertTrue(cache.exists("/first/second"));
         assertTrue(cache.exists("/first"));
  -      String val = (String) cache.get("/first/second/third", "key1"); // should be loaded from cache loader
  +      String val = (String) cache.get("/first/second/third", "key1");// should be loaded from cache loader
         assertEquals("val1", val);
         assertTrue(cache.exists("/first/second/third"));
         assertTrue(cache.exists("/first/second"));
  @@ -1311,26 +1374,26 @@
         checkChildren(Fqn.fromString("/key0/a"), new String[]{"1", "2"});
         checkChildren(Fqn.fromString("/key0"),
                 new String[]{"a", "ab", "abc", "x", "xx", "xxx"});
  -//
  -//      loader.put(Fqn.fromString("/key0/\u0000"), null);
  -//      loader.put(Fqn.fromString("/key0/\u0001"), null);
  -//      checkChildren(Fqn.fromString("/key0"),
  -//                    new String[] { "a", "ab", "abc", "x", "xx", "xxx",
  -//                                   "\u0000", "\u0001"});
  -//
  -//      loader.put(Fqn.fromString("/\u0001"), null);
  -//      checkChildren(new Fqn(), new String[] { "key0", "key1", "\u0001" });
  -//
  -//      loader.put(Fqn.fromString("/\u0001/\u0001"), null);
  -//      checkChildren(Fqn.fromString("/\u0001"), new String[] { "\u0001" });
  -//
  -//      loader.put(Fqn.fromString("/\u0001/\uFFFF"), null);
  -//      checkChildren(Fqn.fromString("/\u0001"),
  -//                    new String[] { "\u0001", "\uFFFF" });
  -//
  -//      loader.put(Fqn.fromString("/\u0001/\uFFFF/\u0001"), null);
  -//      checkChildren(Fqn.fromString("/\u0001/\uFFFF"),
  -//                    new String[] { "\u0001" });
  +      //
  +      //      loader.put(Fqn.fromString("/key0/\u0000"), null);
  +      //      loader.put(Fqn.fromString("/key0/\u0001"), null);
  +      //      checkChildren(Fqn.fromString("/key0"),
  +      //                    new String[] { "a", "ab", "abc", "x", "xx", "xxx",
  +      //                                   "\u0000", "\u0001"});
  +      //
  +      //      loader.put(Fqn.fromString("/\u0001"), null);
  +      //      checkChildren(new Fqn(), new String[] { "key0", "key1", "\u0001" });
  +      //
  +      //      loader.put(Fqn.fromString("/\u0001/\u0001"), null);
  +      //      checkChildren(Fqn.fromString("/\u0001"), new String[] { "\u0001" });
  +      //
  +      //      loader.put(Fqn.fromString("/\u0001/\uFFFF"), null);
  +      //      checkChildren(Fqn.fromString("/\u0001"),
  +      //                    new String[] { "\u0001", "\uFFFF" });
  +      //
  +      //      loader.put(Fqn.fromString("/\u0001/\uFFFF/\u0001"), null);
  +      //      checkChildren(Fqn.fromString("/\u0001/\uFFFF"),
  +      //                    new String[] { "\u0001" });
      }
   
      /**
  @@ -1726,7 +1789,9 @@
       */
      public static class Complex implements Serializable
      {
  -      /** The serialVersionUID */
  +      /**
  +       * The serialVersionUID
  +       */
         private static final long serialVersionUID = -6810871775584708565L;
       
         Complex nested;
  @@ -1781,7 +1846,7 @@
   
         cache.remove(fqn);
   
  -      cache.get(fqn); // forces the node to be loaded from cache loader again
  +      cache.get(fqn);// forces the node to be loaded from cache loader again
         cache.getTransactionManager().commit();
   
         log.debug("expect the cache and the loader to be null here.");
  @@ -1806,7 +1871,7 @@
         cache.getTransactionManager().begin();
   
         cache.remove(fqn);
  -      cache.get(fqn); // forces a reload from cloader
  +      cache.get(fqn);// forces a reload from cloader
         cache.getTransactionManager().rollback();
   
         assertEquals(value, cache.get(fqn, key));
  @@ -1850,11 +1915,11 @@
         /* Empty state. */
         loader.remove(Fqn.fromString("/"));
         // assertEquals(0, loader.loadEntireState().length);
  -//      loader.storeEntireState(new byte[0]);
  -//      assertEquals(0, loader.loadEntireState().length);
  -//      loader.storeEntireState(null);
  -//      assertEquals(0, loader.loadEntireState().length);
  -//      assertEquals(null, loader.get(FQN));
  +      //      loader.storeEntireState(new byte[0]);
  +      //      assertEquals(0, loader.loadEntireState().length);
  +      //      loader.storeEntireState(null);
  +      //      assertEquals(0, loader.loadEntireState().length);
  +      //      assertEquals(null, loader.get(FQN));
   
         /* Use a complex object to ensure that the class catalog is used. */
         Complex c1 = new Complex();
  
  
  
  1.24      +19 -0     JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderWithReplicationTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -b -r1.23 -r1.24
  --- CacheLoaderWithReplicationTest.java	25 Oct 2006 04:50:19 -0000	1.23
  +++ CacheLoaderWithReplicationTest.java	13 Nov 2006 14:20:31 -0000	1.24
  @@ -39,6 +39,9 @@
   
      public CacheLoaderWithReplicationTest()
      {
  +      recursivedelete(dir1);
  +      recursivedelete(dir2);
  +
         if (!dir1.exists()) dir1.mkdirs();
         if (!dir2.exists()) dir2.mkdirs();
   
  @@ -88,6 +91,22 @@
            }
   
         }
  +      recursivedelete(dir1);
  +      recursivedelete(dir2);
  +   }
  +
  +   private void recursivedelete(File f)
  +   {
  +      if (f.isDirectory())
  +      {
  +         File[] files = f.listFiles();
  +         for (int i = 0; i < files.length; i++)
  +         {
  +            recursivedelete(files[i]);
  +         }
  +      }
  +      //System.out.println("File " + f.toURI() + " deleted = " + f.delete());
  +      f.delete();
      }
   
      public void testPessSyncRepl() throws Exception
  
  
  



More information about the jboss-cvs-commits mailing list