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

Manik Surtani msurtani at jboss.com
Thu Jan 4 00:35:39 EST 2007


  User: msurtani
  Date: 07/01/04 00:35:39

  Modified:    tests-50/functional/org/jboss/cache/pojo      
                        ObjectGraphTest.java LocalTest.java
                        NewReplicatedTxTest.java LocalConcurrentTest.java
                        CircularGraphTest.java
                        ReplicatedObjectGraphTest.java
  Log:
  Major changes around nodes, and the way they interact with the interceptor stack.
  Also removed redundant methods in NodeSPI and removed the need for casting to NodeSPI in most cases.
  
  Revision  Changes    Path
  1.7       +18 -17    JBossCache/tests-50/functional/org/jboss/cache/pojo/ObjectGraphTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ObjectGraphTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/ObjectGraphTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- ObjectGraphTest.java	31 Oct 2006 11:07:17 -0000	1.6
  +++ ObjectGraphTest.java	4 Jan 2007 05:35:39 -0000	1.7
  @@ -40,7 +40,7 @@
         cache_.stop();
      }
   
  -//   public void testDummy() {}
  +   //   public void testDummy() {}
   
      protected Person createPerson(String name, int age)
      {
  @@ -74,8 +74,8 @@
         ben.setAddress(addr);
   
         log.info("testMultipleReference(): verify");
  -      Address add1 = (Address) ((Person) cache_.find("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person) cache_.find("/person/ben")).getAddress();
  +      Address add1 = ((Person) cache_.find("/person/joe")).getAddress();
  +      Address add2 = ((Person) cache_.find("/person/ben")).getAddress();
         assertEquals(add1.getCity(), add2.getCity());
         addr.setCity("Santa Clara");
         assertEquals(add1.getCity(), add2.getCity());
  @@ -101,8 +101,8 @@
         ben.setAddress(addr);
   
         log.info("testMultipleReference(): verify");
  -      Address add1 = (Address) ((Person) cache_.find("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person) cache_.find("/person/ben")).getAddress();
  +      Address add1 = ((Person) cache_.find("/person/joe")).getAddress();
  +      Address add2 = ((Person) cache_.find("/person/ben")).getAddress();
         assertEquals(add1.getCity(), add2.getCity());
         addr.setCity("Santa Clara");
         assertEquals(add1.getCity(), add2.getCity());
  @@ -114,6 +114,7 @@
   
      /**
       * Reattach in reverse order
  +    *
       * @throws Exception
       */
      public void testReAttach1() throws Exception
  @@ -136,8 +137,8 @@
         ben.setAddress(addr);
   
         log.info("testMultipleReference(): verify");
  -      Address add1 = (Address) ((Person) cache_.find("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person) cache_.find("/person/ben")).getAddress();
  +      Address add1 = ((Person) cache_.find("/person/joe")).getAddress();
  +      Address add2 = ((Person) cache_.find("/person/ben")).getAddress();
         assertEquals(add1.getCity(), add2.getCity());
         addr.setCity("Santa Clara");
         assertEquals(add1.getCity(), add2.getCity());
  @@ -165,8 +166,8 @@
         joe.setAddress(addr);
         ben.setAddress(addr);
         // They share the sub-object: address
  -      Address add1 = (Address) ((Person) cache_.find("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person) cache_.find("/person/ben")).getAddress();
  +      Address add1 = ((Person) cache_.find("/person/joe")).getAddress();
  +      Address add2 = ((Person) cache_.find("/person/ben")).getAddress();
         assertEquals("Joe's address should still be valid ", "Sunnyvale", add1.getCity());
         assertEquals("Ben's address should still be valid ", "Sunnyvale", add2.getCity());
         assertEquals(add1.getCity(), add2.getCity());
  @@ -201,15 +202,15 @@
         log.info("testMultipleReference(): set Ben address");
         ben.setAddress(addr);
   
  -      Address add1 = (Address) ((Person) cache_.find("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person) cache_.find("/person/ben")).getAddress();
  +      Address add1 = ((Person) cache_.find("/person/joe")).getAddress();
  +      Address add2 = ((Person) cache_.find("/person/ben")).getAddress();
         assertEquals(add1.getCity(), add2.getCity());
         addr.setCity("Santa Clara");
         assertEquals(add1.getCity(), add2.getCity());
   
         // Remove pojo joe will relocate the address field to ben's
         cache_.detach("/person/joe");
  -      add2 = (Address) ((Person) cache_.find("/person/ben")).getAddress();
  +      add2 = ((Person) cache_.find("/person/ben")).getAddress();
         assertEquals("City ", "Santa Clara", add2.getCity());
      }
   
  @@ -241,19 +242,19 @@
         log.info("testMultipleReference(): set John address");
         john.setAddress(addr);
   
  -      Address add1 = (Address) ((Person) cache_.find("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person) cache_.find("/person/ben")).getAddress();
  +      Address add1 = ((Person) cache_.find("/person/joe")).getAddress();
  +      Address add2 = ((Person) cache_.find("/person/ben")).getAddress();
         assertEquals(add1.getCity(), add2.getCity());
         addr.setCity("Santa Clara");
         assertEquals(add1.getCity(), add2.getCity());
   
         // Remove pojo joe will relocate the address field to ben's
         joe.setAddress(addr1);
  -      add2 = (Address) ((Person) cache_.find("/person/joe")).getAddress();
  +      add2 = ((Person) cache_.find("/person/joe")).getAddress();
         assertEquals("City ", "San Jose", add2.getCity());
  -      add2 = (Address) ((Person) cache_.find("/person/ben")).getAddress();
  +      add2 = ((Person) cache_.find("/person/ben")).getAddress();
         assertEquals("City ", "Santa Clara", add2.getCity());
  -      add2 = (Address) ((Person) cache_.find("/person/john")).getAddress();
  +      add2 = ((Person) cache_.find("/person/john")).getAddress();
         assertEquals("City ", "Santa Clara", add2.getCity());
      }
   
  
  
  
  1.12      +11 -10    JBossCache/tests-50/functional/org/jboss/cache/pojo/LocalTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LocalTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/LocalTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- LocalTest.java	16 Nov 2006 08:22:09 -0000	1.11
  +++ LocalTest.java	4 Jan 2007 05:35:39 -0000	1.12
  @@ -49,7 +49,7 @@
         cache_.stop();
      }
   
  -//   public void testDummy() {}
  +   //   public void testDummy() {}
   
      private Person createPerson(String id, String name, int age)
      {
  @@ -106,8 +106,8 @@
      {
         Person joe = createPerson("/person/test3", "Joe", 32);
         cache_.detach("/person/test3");
  -//      assertNull("Underlying cache content " + cache_.getCache().printDetails(),
  -//              cache_.getCache().get("/person/test3"));
  +      //      assertNull("Underlying cache content " + cache_.getCache().printDetails(),
  +      //              cache_.getCache().get("/person/test3"));
      }
   
      public void testDynamicRefSwapping() throws Exception
  @@ -120,8 +120,9 @@
            assertNull("Medication should be null ", med);
            person.setAge(60);
            med = person.getMedication();
  -         assertEquals("Medication ", (Object) "Lipitor", (Object) med.get(0));
  -      } catch (Exception e)
  +         assertEquals("Medication ", "Lipitor", med.get(0));
  +      }
  +      catch (Exception e)
         {
            // should be thrown
         }
  @@ -216,7 +217,7 @@
         language.add("Haka");
         assertEquals("Size of language ", 6, joe.getLanguages().size());
   
  -      String English = (String) language.get(1);
  +      String English = language.get(1);
         assertEquals((Object) "English", English);
         cache_.detach("/person/test6");
      }
  @@ -233,9 +234,9 @@
   
         cache_.attach(id, joe);
         cache_.detach(id);
  -//      TreeCacheProxyImpl impl = (TreeCacheProxyImpl)cache_.getCache();
  -//      System.out.println("*** Here I ");
  -//      System.out.println(impl.printDetails());
  +      //      TreeCacheProxyImpl impl = (TreeCacheProxyImpl)cache_.getCache();
  +      //      System.out.println("*** Here I ");
  +      //      System.out.println(impl.printDetails());
   
         joe.getAge();
         cache_.attach(id, joe);
  @@ -258,7 +259,7 @@
         language.add("Haka");
         assertEquals("Size of language ", 6, joe.getLanguages().size());
   
  -      String English = (String) language.get(1);
  +      String English = language.get(1);
         assertEquals((Object) "English", English);
   
         if (!(language instanceof ClassProxy))
  
  
  
  1.7       +23 -7     JBossCache/tests-50/functional/org/jboss/cache/pojo/NewReplicatedTxTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NewReplicatedTxTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/NewReplicatedTxTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- NewReplicatedTxTest.java	31 Oct 2006 11:07:17 -0000	1.6
  +++ NewReplicatedTxTest.java	4 Jan 2007 05:35:39 -0000	1.7
  @@ -148,7 +148,7 @@
         cache_.attach("/person/ben", ben);
         tx.rollback();
         assertEquals("Zip should be the same ", joe.getAddress().getZip(), p.getAddress().getZip());
  -      assertEquals("Langue 1 should be: ", "English", (String) joe.getLanguages().get(0));
  +      assertEquals("Langue 1 should be: ", "English", joe.getLanguages().get(0));
      }
   
   
  @@ -177,8 +177,9 @@
                  try
                  {
                     throw new RuntimeException("PojoCache is not rolling back properly for Collection yet.");
  -//                  cache_.attach("/test/ben", p);
  -               } catch (Exception ex1)
  +                  //                  cache_.attach("/test/ben", p);
  +               }
  +               catch (Exception ex1)
                  {
                     t1_ex = ex1;
                  }
  @@ -223,10 +224,14 @@
   
         // t2 should rollback due to timeout while t2 should succeed
         if (t1_ex != null)
  +      {
            fail("Thread1 failed: " + t1_ex);
  +      }
         if (t2_ex != null)
  +      {
            fail("Thread2 failed: " + t2_ex);
      }
  +   }
   
      public void testConcurrentTxPutsWithRollback() throws Exception
      {
  @@ -261,10 +266,11 @@
                  {
                     tx = getTransaction();
                     tx.begin();
  -//                  throw new RuntimeException("PojoCache is not rolling back properly for Collection yet.");
  +                  //                  throw new RuntimeException("PojoCache is not rolling back properly for Collection yet.");
                     cache_.attach("/test/ben", p);
                     tx.commit();
  -               } catch (Exception ex)
  +               }
  +               catch (Exception ex)
                  {
                     t1_ex = ex;
                     ex.printStackTrace();
  @@ -315,10 +321,14 @@
   
         // t2 should rollback due to timeout while t2 should succeed
         if (t1_ex != null)
  +      {
            fail("Thread1 failed: " + t1_ex);
  +      }
         if (t2_ex != null)
  +      {
            fail("Thread2 failed: " + t2_ex);
      }
  +   }
   
      public void testConcurrentTxPutsWithRollbackField() throws Exception
      {
  @@ -363,7 +373,8 @@
                     lang.add("3");
                     lang.remove(0);
                     tx.commit();
  -               } catch (Exception ex)
  +               }
  +               catch (Exception ex)
                  {
                     t1_ex = ex;
                  }
  @@ -403,7 +414,8 @@
                     tx.begin();
                     lang.add("2");
                     tx.commit();
  -               } catch (Exception e)
  +               }
  +               catch (Exception e)
                  {
                     e.printStackTrace();
                  }
  @@ -423,10 +435,14 @@
   
         // t2 should rollback due to timeout while t2 should succeed
         if (t1_ex != null)
  +      {
            fail("Thread1 failed: " + t1_ex);
  +      }
         if (t2_ex != null)
  +      {
            fail("Thread2 failed: " + t2_ex);
      }
  +   }
   
      public static Test suite() throws Exception
      {
  
  
  
  1.6       +18 -14    JBossCache/tests-50/functional/org/jboss/cache/pojo/LocalConcurrentTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LocalConcurrentTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/LocalConcurrentTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- LocalConcurrentTest.java	31 Oct 2006 11:07:17 -0000	1.5
  +++ LocalConcurrentTest.java	4 Jan 2007 05:35:39 -0000	1.6
  @@ -29,7 +29,7 @@
    * Local concurrent test for PojoCache. Test attach and detach under load
    * and concurrency.
    *
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    * @author<a href="mailto:bwang at jboss.org">Ben Wang</a> December 2004
    */
   public class LocalConcurrentTest extends TestCase
  @@ -106,10 +106,12 @@
         try
         {
            all();
  -      } catch (UpgradeException ue)
  +      }
  +      catch (UpgradeException ue)
         {
            log("Upgrade exception. Can ingore for repeatable read. " + ue);
  -      } catch (Exception ex)
  +      }
  +      catch (Exception ex)
         {
            log("Exception: " + ex);
            throw ex;
  @@ -131,14 +133,16 @@
         TestingUtil.sleepThread(100);
         t4.start();
   
  -      t1.join(60000); // wait for 20 secs
  -      t2.join(60000); // wait for 20 secs
  -      t3.join(60000); // wait for 20 secs
  -      t4.join(60000); // wait for 20 secs
  +      t1.join(60000);// wait for 20 secs
  +      t2.join(60000);// wait for 20 secs
  +      t3.join(60000);// wait for 20 secs
  +      t4.join(60000);// wait for 20 secs
   
         if (thread_ex != null)
  +      {
            throw thread_ex;
      }
  +   }
   
      class RunThread extends Thread
      {
  @@ -187,7 +191,7 @@
         {
            for (int loop = 0; loop < MAX_LOOP; loop++)
            {
  -            createPerson();   // create a new person instance every loop.
  +            createPerson();// create a new person instance every loop.
               TestingUtil.sleepThread(random_.nextInt(50));
               op1();
            }
  @@ -197,11 +201,11 @@
         private void op1()
         {
            int i = random_.nextInt(nodeList_.size() - 1);
  -         if (i == 0) return; // it is meaningless to test root
  -         String node = (String) nodeList_.get(i) + "/aop";
  +         if (i == 0) return;// it is meaningless to test root
  +         String node = nodeList_.get(i) + "/aop";
            cache_.attach(node, person_);
  -         TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
  -         TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
  +         TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
  +         TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
            cache_.detach(node);
         }
      }
  @@ -230,7 +234,7 @@
            {
               for (int j = 0; j < children; j++)
               {
  -               String tmp = (String) oldList.get(i);
  +               String tmp = oldList.get(i);
                  tmp += Integer.toString(j);
                  if (depth != 1)
                  {
  @@ -266,7 +270,7 @@
      private static void log(String str)
      {
         System.out.println("Thread: " + Thread.currentThread() + ": " + str);
  -//        System.out.println(str);
  +      //        System.out.println(str);
      }
   
   }
  
  
  
  1.6       +6 -7      JBossCache/tests-50/functional/org/jboss/cache/pojo/CircularGraphTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CircularGraphTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/CircularGraphTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- CircularGraphTest.java	30 Dec 2006 17:49:58 -0000	1.5
  +++ CircularGraphTest.java	4 Jan 2007 05:35:39 -0000	1.6
  @@ -13,7 +13,6 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.Node;
   import org.jboss.cache.pojo.test.Link;
   import org.jboss.cache.pojo.test.NodeManager;
   import org.jboss.cache.pojo.test.Person;
  @@ -53,7 +52,7 @@
         cache_.stop();
      }
   
  -//   public void testDummy() {}
  +   //   public void testDummy() {}
   
      protected Person createPerson(String name, int age)
      {
  @@ -162,7 +161,7 @@
         assertEquals("child", ((Link) cache_.find("/link/parent")).getLink().getName());
         Link link = (Link) cache_.detach("/link/parent");
         assertEquals("child", link.getLink().getName());
  -      assertNull("Cache should be null ", ((Node) cache_.getCache().getRoot().getChild(Fqn.fromString("/parent"))));
  +      assertNull("Cache should be null ", cache_.getCache().getRoot().getChild(Fqn.fromString("/parent")));
      }
   
      /**
  @@ -185,7 +184,7 @@
         assertEquals("parent", ((Link) cache_.find("/link/child")).getLink().getName());
         Link link = (Link) cache_.detach("/link/parent");
         assertEquals("child", link.getLink().getName());
  -      assertNull("Cache should be null ", ((Node) cache_.getCache().getRoot().getChild(Fqn.fromString("/parent"))));
  +      assertNull("Cache should be null ", cache_.getCache().getRoot().getChild(Fqn.fromString("/parent")));
      }
   
      /**
  @@ -236,8 +235,8 @@
         List<Link> list1 = (List<Link>) cache_.find("/list");
         List<Link> list2 = (List<Link>) cache_.find("/alias");
   
  -      assertEquals("parent", ((Link) list1.get(0)).getName());
  -      assertEquals("child", ((Link) list2.get(0)).getLink().getName());
  +      assertEquals("parent", list1.get(0).getName());
  +      assertEquals("child", list2.get(0).getLink().getName());
      }
   
      /**
  @@ -252,7 +251,7 @@
         child.setLink(parent);
   
         cache_.attach("parent", parent);
  -      parent.setLink(child); // again
  +      parent.setLink(child);// again
         child.setLink(parent);
      }
   
  
  
  
  1.8       +11 -11    JBossCache/tests-50/functional/org/jboss/cache/pojo/ReplicatedObjectGraphTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedObjectGraphTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/ReplicatedObjectGraphTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- ReplicatedObjectGraphTest.java	6 Nov 2006 13:44:26 -0000	1.7
  +++ ReplicatedObjectGraphTest.java	4 Jan 2007 05:35:39 -0000	1.8
  @@ -5,9 +5,9 @@
   import junit.framework.TestSuite;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.jboss.cache.Fqn;
   import org.jboss.cache.pojo.test.Address;
   import org.jboss.cache.pojo.test.Person;
  -import org.jboss.cache.Fqn;
   
   /**
    * Test object graph handling in aop, e.g., circular reference, multiple reference, link, etc.
  @@ -50,7 +50,7 @@
         return tree;
      }
   
  -//   public void testDummy() {}
  +   //   public void testDummy() {}
   
      protected Person createPerson(String name, int age)
      {
  @@ -127,7 +127,7 @@
   
         Address joe1 = (Address) cache2.find("/address");
         assertEquals("Ben's address should not be changed ", joe.getAddress().getCity(), joe1.getCity());
  -      ben = (Person)cache2.find("/person/ben");
  +      ben = (Person) cache2.find("/person/ben");
         cache2.detach("/person/ben");
         Address joe2 = (Address) cache2.find("/address");
         assertEquals("Joe's reference should be the same.", joe1, joe2);
  @@ -168,15 +168,15 @@
         log.info("testMultipleReference(): set Ben address");
         ben.setAddress(addr);
   
  -      Address add1 = (Address) ((Person) cache2.find("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person) cache2.find("/person/ben")).getAddress();
  +      Address add1 = ((Person) cache2.find("/person/joe")).getAddress();
  +      Address add2 = ((Person) cache2.find("/person/ben")).getAddress();
         assertEquals(add1.getCity(), add2.getCity());
         addr.setCity("Santa Clara");
         assertEquals(add1.getCity(), add2.getCity());
   
         // Remove pojo joe will relocate the address field to ben's
         cache2.detach("/person/joe");
  -      add2 = (Address) ((Person) cache2.find("/person/ben")).getAddress();
  +      add2 = ((Person) cache2.find("/person/ben")).getAddress();
   
         assertEquals("City ", "Santa Clara", add2.getCity());
      }
  @@ -208,19 +208,19 @@
         ben.setAddress(addr);
         john.setAddress(addr);
   
  -      Address add1 = (Address) ((Person) cache2.find("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person) cache2.find("/person/ben")).getAddress();
  +      Address add1 = ((Person) cache2.find("/person/joe")).getAddress();
  +      Address add2 = ((Person) cache2.find("/person/ben")).getAddress();
         assertEquals(add1.getCity(), add2.getCity());
         addr.setCity("Santa Clara");
         assertEquals(add1.getCity(), add2.getCity());
   
         // Remove pojo joe will relocate the address field to ben's
         joe.setAddress(addr1);
  -      add2 = (Address) ((Person) cache2.find("/person/joe")).getAddress();
  +      add2 = ((Person) cache2.find("/person/joe")).getAddress();
         assertEquals("City ", "San Jose", add2.getCity());
  -      add2 = (Address) ((Person) cache2.find("/person/ben")).getAddress();
  +      add2 = ((Person) cache2.find("/person/ben")).getAddress();
         assertEquals("City ", "Santa Clara", add2.getCity());
  -      add2 = (Address) ((Person) cache2.find("/person/john")).getAddress();
  +      add2 = ((Person) cache2.find("/person/john")).getAddress();
         assertEquals("City ", "Santa Clara", add2.getCity());
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list