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

Manik Surtani msurtani at jboss.com
Wed Sep 6 11:30:57 EDT 2006


  User: msurtani
  Date: 06/09/06 11:30:57

  Modified:    tests/functional/org/jboss/cache/aop      
                        CacheLoaderTestsBase.java LocalConcurrentTest.java
                        RecursiveRefAopTest.java
                        ReplicatedObjectGraphAopTest.java
                        SharedRefConcurrentTest.java
                        TreeCacheAopTester.java
  Log:
  Removed TreeCache dependency on ServiceMBeanSupport
  
  Revision  Changes    Path
  1.6       +30 -17    JBossCache/tests/functional/org/jboss/cache/aop/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/aop/CacheLoaderTestsBase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- CacheLoaderTestsBase.java	20 Jul 2006 08:05:17 -0000	1.5
  +++ CacheLoaderTestsBase.java	6 Sep 2006 15:30:56 -0000	1.6
  @@ -13,47 +13,56 @@
    * Commons tests for all CacheLoaders. Aop version.
    *
    * @author bwang
  - * @version $Id: CacheLoaderTestsBase.java,v 1.5 2006/07/20 08:05:17 msurtani Exp $
  + * @version $Id: CacheLoaderTestsBase.java,v 1.6 2006/09/06 15:30:56 msurtani Exp $
    */
  -abstract public class CacheLoaderTestsBase extends TestCase {
  +abstract public class CacheLoaderTestsBase extends TestCase
  +{
      PojoCache cache;
      CacheLoader loader = null;
      Transaction tx = null;
      static final Fqn FQN = new Fqn("key");
   
  -   protected void setUp() throws Exception {
  +   protected void setUp() throws Exception
  +   {
         super.setUp();
         cache = new PojoCache();
         cache.getConfiguration().setCacheMode("local");
         configureCache();
         cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
         loader = cache.getCacheLoader();
      }
   
      abstract protected void configureCache() throws Exception;
   
  -   protected void tearDown() throws Exception {
  +   protected void tearDown() throws Exception
  +   {
         super.tearDown();
  -      if (tx != null) {
  -         try {
  +      if (tx != null)
  +      {
  +         try
  +         {
               tx.commit();
  -         } catch (Throwable e) {
  +         }
  +         catch (Throwable e)
  +         {
               e.printStackTrace();
            }
         }
         cache.remove("/");
         loader.remove(Fqn.fromString("/"));
  -      cache.stopService();
  -      cache.destroyService();
  +      cache.stop();
  +      cache.destroy();
      }
   
  -   protected void addDelay() {
  +   protected void addDelay()
  +   {
         ; // returns immediately in this case.  Subclasses may override where a delay is needed.
      }
   
  -   public void testEvictionWithCacheLoader() throws Exception {
  +   public void testEvictionWithCacheLoader() throws Exception
  +   {
         cache.putObject("/first/second/third", "val1");   // stored in cache loader
         cache.evict(Fqn.fromString("/first/second/third"));  // removes node, because there are no children
         addDelay();
  @@ -68,7 +77,8 @@
      }
   
   
  -   public void testPojoEvictionWithCacheLoader() throws Exception {
  +   public void testPojoEvictionWithCacheLoader() throws Exception
  +   {
         Person test = new Person();
         test.setName("Ben");
         test.setAge(10);
  @@ -86,7 +96,8 @@
         assertTrue(cache.exists("/first"));
      }
   
  -   public void testPojoRemoveWithCacheLoader() throws Exception {
  +   public void testPojoRemoveWithCacheLoader() throws Exception
  +   {
         Person test = new Person();
         test.setName("Ben");
         test.setAge(10);
  @@ -100,11 +111,13 @@
         assertNull(val);
      }
   
  -   public static Test suite() {
  +   public static Test suite()
  +   {
         return new TestSuite(CacheLoaderTestsBase.class);
      }
   
  -   public static void main(String[] args) {
  +   public static void main(String[] args)
  +   {
         junit.textui.TestRunner.run(suite());
      }
   
  
  
  
  1.11      +52 -33    JBossCache/tests/functional/org/jboss/cache/aop/LocalConcurrentTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LocalConcurrentTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/LocalConcurrentTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- LocalConcurrentTest.java	20 Jul 2006 11:48:26 -0000	1.10
  +++ LocalConcurrentTest.java	6 Sep 2006 15:30:56 -0000	1.11
  @@ -34,7 +34,7 @@
    * Local mode stress test for PojoCache. Test getObject and putObject under load
    * and concurrency.
    *
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    * @author<a href="mailto:bwang at jboss.org">Ben Wang</a> December 2004
    */
   public class LocalConcurrentTest extends TestCase
  @@ -49,7 +49,7 @@
      static final int children_ = 2;
      static final int MAX_LOOP = 100;
      static final int SLEEP_TIME = 50;
  -   static Exception thread_ex=null;
  +   static Exception thread_ex = null;
      UserTransaction tx_ = null;
   
      public LocalConcurrentTest(String name)
  @@ -60,15 +60,16 @@
      public void setUp() throws Exception
      {
         super.setUp();
  -      oldFactory_=System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
  +      oldFactory_ = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
         DummyTransactionManager.getInstance();
  -      if(p_ == null) {
  -         p_=new Properties();
  +      if (p_ == null)
  +      {
  +         p_ = new Properties();
            p_.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
         }
   
  -      tx_ = (UserTransaction)new InitialContext(p_).lookup("UserTransaction");
  +      tx_ = (UserTransaction) new InitialContext(p_).lookup("UserTransaction");
   
         initCaches(Configuration.CacheMode.LOCAL);
         nodeList_ = nodeGen(depth_, children_);
  @@ -79,11 +80,12 @@
      public void tearDown() throws Exception
      {
         super.tearDown();
  -      thread_ex=null;
  +      thread_ex = null;
         DummyTransactionManager.destroy();
         destroyCaches();
   
  -      if (oldFactory_ != null) {
  +      if (oldFactory_ != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, oldFactory_);
            oldFactory_ = null;
         }
  @@ -96,13 +98,13 @@
         cache_ = new PojoCache();
         cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-service.xml"));
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      cache_.createService();
  -      cache_.startService();
  +      cache_.create();
  +      cache_.start();
      }
   
      void destroyCaches() throws Exception
      {
  -      cache_.stopService();
  +      cache_.stop();
         cache_ = null;
      }
   
  @@ -126,12 +128,14 @@
         {
            setLevelRW();
            all();
  -      } catch (UpgradeException ue)
  +      }
  +      catch (UpgradeException ue)
         {
  -         log("Upgrade exception. Can ingore for repeatable read. " +ue);
  -      } catch (Exception ex)
  +         log("Upgrade exception. Can ingore for repeatable read. " + ue);
  +      }
  +      catch (Exception ex)
         {
  -         log("Exception: " +ex);
  +         log("Exception: " + ex);
            throw ex;
         }
      }
  @@ -162,7 +166,7 @@
         t3.join(60000); // wait for 20 secs
         t4.join(60000); // wait for 20 secs
   
  -      if(thread_ex != null)
  +      if (thread_ex != null)
            throw thread_ex;
      }
   
  @@ -178,7 +182,8 @@
            random_ = new Random(seed);
         }
   
  -      private void createPerson() {
  +      private void createPerson()
  +      {
            person_ = new Person();
            person_.setName("Ben");
            person_.setAge(18);
  @@ -194,24 +199,31 @@
            person_.setAddress(addr);
         }
   
  -      public void run() {
  -         try {
  +      public void run()
  +      {
  +         try
  +         {
               _run();
            }
  -         catch(Exception e) {
  -            thread_ex=e;
  +         catch (Exception e)
  +         {
  +            thread_ex = e;
            }
         }
   
         /**
          */
  -      public void _run() throws Exception {
  -         for (int loop = 0; loop < MAX_LOOP; loop++) {
  +      public void _run() throws Exception
  +      {
  +         for (int loop = 0; loop < MAX_LOOP; loop++)
  +         {
               createPerson();   // create a new person instance every loop.
               TestingUtil.sleepThread(random_.nextInt(50));
  -            try {
  +            try
  +            {
                  op1();
  -            } catch (CacheException ex)
  +            }
  +            catch (CacheException ex)
               {
                  throw ex;
               }
  @@ -219,9 +231,10 @@
         }
   
         // Operation 1
  -      private void op1() throws CacheException {
  +      private void op1() throws CacheException
  +      {
            int i = random_.nextInt(nodeList_.size() - 1);
  -         if(i==0) return; // it is meaningless to test root
  +         if (i == 0) return; // it is meaningless to test root
            String node = (String) nodeList_.get(i) + "/aop";
            cache_.putObject(node, person_);
            TestingUtil.sleepThread(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
  @@ -249,14 +262,18 @@
         newList.add("/");
         strList.add("/");
   
  -      while (depth > 0) {
  +      while (depth > 0)
  +      {
            // Trying to produce node name at this depth.
            newList = new ArrayList();
  -         for (int i = 0; i < oldList.size(); i++) {
  -            for (int j = 0; j < children; j++) {
  +         for (int i = 0; i < oldList.size(); i++)
  +         {
  +            for (int j = 0; j < children; j++)
  +            {
                  String tmp = (String) oldList.get(i);
                  tmp += Integer.toString(j);
  -               if (depth != 1) {
  +               if (depth != 1)
  +               {
                     tmp += "/";
                  }
   
  @@ -269,8 +286,10 @@
         }
   
         // let's prune out root node
  -      for(int i=0; i < strList.size(); i++) {
  -         if( strList.get(i).equals("/") ) {
  +      for (int i = 0; i < strList.size(); i++)
  +      {
  +         if (strList.get(i).equals("/"))
  +         {
               strList.remove(i);
               break;
            }
  
  
  
  1.6       +8 -5      JBossCache/tests/functional/org/jboss/cache/aop/RecursiveRefAopTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RecursiveRefAopTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/RecursiveRefAopTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- RecursiveRefAopTest.java	20 Jul 2006 11:14:17 -0000	1.5
  +++ RecursiveRefAopTest.java	6 Sep 2006 15:30:56 -0000	1.6
  @@ -14,7 +14,7 @@
   {
      private static final String CONFIG_FILENAME = "META-INF/local-service.xml";
      private PojoCache treeCache;
  -   Log log=LogFactory.getLog(ReplicatedAopTest.class);
  +   Log log = LogFactory.getLog(ReplicatedAopTest.class);
   
      private Map cachedMap;
   
  @@ -30,7 +30,7 @@
         treeCache = new PojoCache();
   
         treeCache.setConfiguration(new XmlConfigurationParser().parseFile(CONFIG_FILENAME));
  -      treeCache.startService();
  +      treeCache.start();
         treeCache.putObject("/aop/test", new HashMap());
         cachedMap = (Map) treeCache.getObject("/aop/test");
      }
  @@ -40,7 +40,8 @@
         super.tearDown();
      }
   
  -   public void XtestDummy() {
  +   public void XtestDummy()
  +   {
   
      }
   
  @@ -50,12 +51,14 @@
       */
      public void testRecuriveMapKey()
      {
  -      try {
  +      try
  +      {
            IdObject id = new IdObject("1");
            ValueObject value = new ValueObject(id, 3.0f);
            cachedMap.put(id, value);
         } // try
  -      catch (Exception x) {
  +      catch (Exception x)
  +      {
            x.printStackTrace();
            fail("testFailed");
         } // catch
  
  
  
  1.25      +36 -32    JBossCache/tests/functional/org/jboss/cache/aop/ReplicatedObjectGraphAopTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedObjectGraphAopTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/ReplicatedObjectGraphAopTest.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- ReplicatedObjectGraphAopTest.java	20 Jul 2006 11:14:17 -0000	1.24
  +++ ReplicatedObjectGraphAopTest.java	6 Sep 2006 15:30:56 -0000	1.25
  @@ -17,12 +17,13 @@
   
   /**
    * Test object graph handling in aop, e.g., circular reference, multiple reference, link, etc.
  + *
    * @author Ben Wang  
    */
   
   public class ReplicatedObjectGraphAopTest extends TestCase
   {
  -   Log log=LogFactory.getLog(ReplicatedObjectGraphAopTest.class);
  +   Log log = LogFactory.getLog(ReplicatedObjectGraphAopTest.class);
      PojoCache cache1;
      PojoCache cache2;
   
  @@ -47,12 +48,13 @@
         cache2.stop();
      }
   
  -   private PojoCache createCache(String name) throws Exception {
  -      PojoCache tree=new PojoCache();
  +   private PojoCache createCache(String name) throws Exception
  +   {
  +      PojoCache tree = new PojoCache();
         tree.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replSync-service.xml")); 
         tree.getConfiguration().setClusterName(name);
  -      tree.createService();
  -      tree.startService();
  +      tree.create();
  +      tree.start();
         return tree;
      }
   
  @@ -117,7 +119,8 @@
         assertEquals("Ben's address should be changed ", "Santa Clara", ben.getAddress().getCity());
      }
   
  -   /** Test whether repeated update on the ref count will change the replicated aop instances
  +   /**
  +    * Test whether repeated update on the ref count will change the replicated aop instances
       *
       * @throws Exception
       */
  @@ -126,15 +129,15 @@
         log.info("testCheckReplInstance() ...");
         stage0();
         TestingUtil.sleepThread(100);
  -      Person joe = (Person)cache1.getObject("/person/joe");
  -      Person ben = (Person)cache1.getObject("/person/ben");
  +      Person joe = (Person) cache1.getObject("/person/joe");
  +      Person ben = (Person) cache1.getObject("/person/ben");
         assertEquals("Ben and Joe's address should be the same ", joe.getAddress().getCity(),
               ben.getAddress().getCity());
   
  -      Address joe1 = (Address)cache2.getObject("/address");
  +      Address joe1 = (Address) cache2.getObject("/address");
         assertEquals("Ben's address should not be changed ", joe.getAddress().getCity(), joe1.getCity());
         cache1.removeObject("/person/ben");
  -      Address joe2 = (Address)cache2.getObject("/address");
  +      Address joe2 = (Address) cache2.getObject("/address");
         assertEquals("Joe's reference should be the same.", joe1, joe2);
      }
   
  @@ -143,8 +146,8 @@
         log.info("testRefCountCheckRepl() ...");
         stage1();
         TestingUtil.sleepThread(100);
  -      Person joe = (Person)cache1.getObject("/person/joe");
  -      Person ben = (Person)cache1.getObject("/person/ben");
  +      Person joe = (Person) cache1.getObject("/person/joe");
  +      Person ben = (Person) cache1.getObject("/person/ben");
         assertEquals("Ben and Joe's address should be the same ", joe.getAddress().getCity(),
               ben.getAddress().getCity());
         TestingUtil.sleepThread(100);
  @@ -169,9 +172,9 @@
         assertEquals("child", ((Link) cache2.getObject("/link/parent")).getLink().getName());
         ((Link) cache2.getObject("/link/parent")).setLink(null);
         assertNull("Child should be null", ((Link) cache2.getObject("/link/parent")).getLink());
  -      Link link = (Link)cache1.removeObject("/link/parent");
  +      Link link = (Link) cache1.removeObject("/link/parent");
         assertNotNull("Link should not be null ", link);
  -      System.out.println("Link: " +link);
  +      System.out.println("Link: " + link);
      }
   
      public void testCircularReference2() throws Exception
  @@ -189,7 +192,7 @@
         assertEquals("child", ((Link) cache2.getObject("/link/parent")).getLink().getName());
         ((Link) cache2.getObject("/link/parent")).setLink(null);
         assertNull("Child should be null", ((Link) cache2.getObject("/link/parent")).getLink());
  -      Link link = (Link)cache1.removeObject("/link/parent");
  +      Link link = (Link) cache1.removeObject("/link/parent");
         assertNotNull("Link should not be null ", link);
      }
   
  @@ -222,12 +225,13 @@
   
         p2.setLink(null);
         assertNull("Child should be null", p2.getLink());
  -      Link link = (Link)cache1.removeObject("/link/parent");
  +      Link link = (Link) cache1.removeObject("/link/parent");
         assertNotNull("Link should not be null ", link);
      }
   
      /**
       * Setting the circular relationship and also as a shared object.
  +    *
       * @throws Exception
       */
      public void testCircularReference4() throws Exception
  @@ -246,8 +250,8 @@
         cache1.putObject("/alias", list);
   
         TestingUtil.sleepThread(100);
  -      List list1 = (List)cache2.getObject("/list");
  -      List list2 = (List)cache2.getObject("/alias");
  +      List list1 = (List) cache2.getObject("/list");
  +      List list2 = (List) cache2.getObject("/alias");
   
         assertEquals("parent", ((Link) list1.get(0)).getName());
         assertEquals("child", ((Link) list2.get(0)).getLink().getName());
  @@ -268,7 +272,7 @@
         pm_.addNode("root.kanto.tokyo", "hadanshita");
         assertEquals("hadanshita", pm_.findNode("root.kanto.tokyo.hadanshita").getNodeRDN());
   
  -      NodeManager pm2_ = (NodeManager)cache2.getObject("/propagation");
  +      NodeManager pm2_ = (NodeManager) cache2.getObject("/propagation");
         assertEquals("kanagawa", pm2_.findNode("root.kanto.kanagawa").getNodeRDN());
         assertEquals("hadanshita", pm2_.findNode("root.kanto.tokyo.hadanshita").getNodeRDN());
   
  @@ -306,16 +310,16 @@
         log.info("testMultipleReference(): set Ben address");
         ben.setAddress(addr);
   
  -      Address add1 = (Address) ((Person)cache2.getObject("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person)cache2.getObject("/person/ben")).getAddress();
  +      Address add1 = (Address) ((Person) cache2.getObject("/person/joe")).getAddress();
  +      Address add2 = (Address) ((Person) cache2.getObject("/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.removeObject("/person/joe");
  -      add2 = (Address) ((Person)cache2.getObject("/person/ben")).getAddress();
  -      System.out.println("*** Cache content *** " +cache2.printDetails());
  +      add2 = (Address) ((Person) cache2.getObject("/person/ben")).getAddress();
  +      System.out.println("*** Cache content *** " + cache2.printDetails());
   
         assertEquals("City ", "Santa Clara", add2.getCity());
      }
  @@ -347,19 +351,19 @@
         ben.setAddress(addr);
         john.setAddress(addr);
   
  -      Address add1 = (Address) ((Person)cache2.getObject("/person/joe")).getAddress();
  -      Address add2 = (Address) ((Person)cache2.getObject("/person/ben")).getAddress();
  +      Address add1 = (Address) ((Person) cache2.getObject("/person/joe")).getAddress();
  +      Address add2 = (Address) ((Person) cache2.getObject("/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.getObject("/person/joe")).getAddress();
  +      add2 = (Address) ((Person) cache2.getObject("/person/joe")).getAddress();
         assertEquals("City ", "San Jose", add2.getCity());
  -      add2 = (Address) ((Person)cache2.getObject("/person/ben")).getAddress();
  +      add2 = (Address) ((Person) cache2.getObject("/person/ben")).getAddress();
         assertEquals("City ", "Santa Clara", add2.getCity());
  -      add2 = (Address) ((Person)cache2.getObject("/person/john")).getAddress();
  +      add2 = (Address) ((Person) cache2.getObject("/person/john")).getAddress();
         assertEquals("City ", "Santa Clara", add2.getCity());
      }
   
  
  
  
  1.7       +73 -67    JBossCache/tests/functional/org/jboss/cache/aop/SharedRefConcurrentTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SharedRefConcurrentTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/SharedRefConcurrentTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- SharedRefConcurrentTest.java	20 Jul 2006 11:48:26 -0000	1.6
  +++ SharedRefConcurrentTest.java	6 Sep 2006 15:30:56 -0000	1.7
  @@ -27,7 +27,7 @@
    * Tests concurrency of the __JBossInternal__ region of the cache.
    * 
    * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class SharedRefConcurrentTest extends TestCase
   {
  @@ -39,7 +39,7 @@
      private static final int MAX_SLEEP = 200;
      private static final int MIN_SLEEP = 5;
      
  -   private Log log=LogFactory.getLog(SharedRefConcurrentTest.class);
  +   private Log log = LogFactory.getLog(SharedRefConcurrentTest.class);
      
      /**
       * Tests partial state transfer under heavy concurrent load and REPL_SYNC.
  @@ -72,7 +72,6 @@
       * for concurrency problems with the shared reference map.
       * 
       * @param sync whether to use REPL_SYNC or REPL_ASYNCE
  -    * 
       * @throws Exception
       */
      private void concurrentUseTest(boolean sync) throws Exception
  @@ -82,16 +81,19 @@
   //      int CACHE_COUNT = names.length;
         CacheUser[] cacheUsers = new CacheUser[CACHE_COUNT];      
         
  -      try {
  +      try
  +      {
            // Create a semaphore and take all its tickets
            Semaphore semaphore = new Semaphore(CACHE_COUNT);         
  -         for (int i = 0; i < CACHE_COUNT; i++) {
  +         for (int i = 0; i < CACHE_COUNT; i++)
  +         {
               semaphore.acquire();
            }   
            
            // Create activation threads that will block on the semaphore
            TreeCache[] caches = new TreeCache[CACHE_COUNT];
  -         for (int i = 0; i < CACHE_COUNT; i++) {
  +         for (int i = 0; i < CACHE_COUNT; i++)
  +         {
               cacheUsers[i] = new CacheUser(semaphore, String.valueOf(i), sync);
               caches[i] = cacheUsers[i].getTreeCache();
            }
  @@ -107,7 +109,8 @@
            
            // Reacquire the semaphore tickets; when we have them all
            // we know the threads are done         
  -         for (int i = 0; i < CACHE_COUNT; i++) {
  +         for (int i = 0; i < CACHE_COUNT; i++)
  +         {
               boolean acquired = semaphore.attempt(60000);
               if (!acquired)
                  fail("failed to acquire semaphore " + i);
  @@ -126,10 +129,12 @@
                            null, cacheUsers[i].getException());            
            }
         }
  -      catch (Exception ex) {
  +      catch (Exception ex)
  +      {
            fail(ex.getLocalizedMessage());
         }
  -      finally {
  +      finally
  +      {
            for (int i = 0; i < CACHE_COUNT; i++)
               cacheUsers[i].cleanup();
         }
  @@ -144,11 +149,11 @@
   
         PojoCache tree = new PojoCache();
         String configFile = sync ? "META-INF/replSync-service.xml" : "META-INF/replAsync-service.xml";
  -tree.setConfiguration(new XmlConfigurationParser().parseFile(configFile));
  +      tree.setConfiguration(new XmlConfigurationParser().parseFile(configFile));
         tree.setDeadlockDetection(sync);
         tree.getConfiguration().setClusterName("StateTransferTest");
  -      tree.createService();
  -      tree.startService();
  +      tree.create();
  +      tree.start();
   
         caches.put(cacheID, tree);
   
  @@ -181,8 +186,8 @@
         {
            try
            {
  -            cache.stopService();
  -            cache.destroyService();
  +            cache.stop();
  +            cache.destroy();
            }
            catch (Exception e)
            {
  @@ -273,8 +278,9 @@
               factor = random.nextInt(MAX_SLEEP);
                  
               int index = factor % SUBTREE_SIZE;
  -            fqn = "/" + name +"/" + String.valueOf(index);
  -            if (loaded[index] == false) {
  +            fqn = "/" + name + "/" + String.valueOf(index);
  +            if (loaded[index] == false)
  +            {
                  cache.putObject(fqn, people[index]);
                  loaded[index] = true;
                  log.info("TEST: " + name + " put Person at " + fqn);
  
  
  
  1.6       +76 -37    JBossCache/tests/functional/org/jboss/cache/aop/TreeCacheAopTester.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheAopTester.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/TreeCacheAopTester.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- TreeCacheAopTester.java	20 Jul 2006 08:05:17 -0000	1.5
  +++ TreeCacheAopTester.java	6 Sep 2006 15:30:56 -0000	1.6
  @@ -29,47 +29,53 @@
   
      PojoCache cache;
   
  -   Log logger_=LogFactory.getLog(TreeCacheAopTester.class);
  +   Log logger_ = LogFactory.getLog(TreeCacheAopTester.class);
   
      public TreeCacheAopTester(String configFile)
      {
  -      try {
  +      try
  +      {
            /*
                cache=new PojoCache(cluster_name, props, 10000);
  -             cache.startService();
  +             cache.start();
                cache2=new PojoCache(cluster_name, props, 10000);
  -             cache2.startService();
  +             cache2.start();
                */
            cache = new PojoCache();
             XmlConfigurationParser parser = new XmlConfigurationParser();
             Configuration c = parser.parseFile(configFile);
             cache.setConfiguration(c);
  -         cache.startService();
  -      } catch (Exception e) {
  +         cache.start();
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
         }
      }
   
      public void stop()
      {
  -      cache.stopService();
  +      cache.stop();
      }
   
      public void testSetup()
      {
         Person p = new Person();
  -      if (!(p instanceof Advised)) {
  +      if (!(p instanceof Advised))
  +      {
            logger_.error("testSetup(): p is not an instance of Advised");
            throw new RuntimeException("Person must be advised!");
         }
         Address a = new Address();
  -      if (!(a instanceof Advised)) {
  +      if (!(a instanceof Advised))
  +      {
            logger_.error("testSetup(): a is not an instance of Advised");
            throw new RuntimeException("Address must be advised!");
         }
      }
   
  -   public void setSyncCommitPhase(boolean bool) {
  +   public void setSyncCommitPhase(boolean bool)
  +   {
         cache.getConfiguration().setSyncCommitPhase(bool);
      }
   
  @@ -79,18 +85,24 @@
         p.setName(name);
         p.setAge(age);
         p.setAddress(new Address());
  -      try {
  +      try
  +      {
            cache.putObject(key, p);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            throw new RuntimeException(e);
         }
      }
   
      public void removePerson(String key)
      {
  -      try {
  +      try
  +      {
            cache.removeObject(key);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
            throw new RuntimeException(e);
         }
  @@ -98,9 +110,12 @@
   
      Object getPerson(String key)
      {
  -      try {
  +      try
  +      {
            return (Person) cache.getObject(key);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            throw new RuntimeException(e);
         }
      }
  @@ -112,18 +127,24 @@
         p.setAge(age);
         p.setAddress(new Address());
         p.setYear(year);
  -      try {
  +      try
  +      {
            cache.putObject(key, p);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            throw new RuntimeException(e);
         }
      }
   
      public void removeStudent(String key)
      {
  -      try {
  +      try
  +      {
            cache.removeObject(key);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
            throw new RuntimeException(e);
         }
  @@ -131,9 +152,12 @@
   
      Object getStudent(String key)
      {
  -      try {
  +      try
  +      {
            return (Student) cache.getObject(key);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            throw new RuntimeException(e);
         }
      }
  @@ -143,7 +167,8 @@
         ((Student) getStudent(key)).setYear(year);
      }
   
  -   public String getYear(String key) {
  +   public String getYear(String key)
  +   {
         return ((Student) getStudent(key)).getYear();
      }
   
  @@ -229,7 +254,8 @@
      {
         Person person = ((Person) getPerson(key));
         Map hobbies = person.getHobbies();
  -      if (hobbies == null) {
  +      if (hobbies == null)
  +      {
            hobbies = new HashMap();
            person.setHobbies(hobbies);
            // NB: it is neccessary to get hobbies again to get advised version
  @@ -244,7 +270,8 @@
         person.setHobbies(map);
      }
   
  -   public Map getHobbies(String key) {
  +   public Map getHobbies(String key)
  +   {
         return ((Person) getPerson(key)).getHobbies();
      }
      // List operations
  @@ -266,7 +293,8 @@
      {
         Person person = ((Person) getPerson(key));
         List languages = person.getLanguages();
  -      if (languages == null) {
  +      if (languages == null)
  +      {
            person.setLanguages(new ArrayList());
            languages = person.getLanguages();
         }
  @@ -295,7 +323,8 @@
      {
         Person person = ((Person) getPerson(key));
         Set skills = person.getSkills();
  -      if (skills == null) {
  +      if (skills == null)
  +      {
            person.setSkills(new HashSet());
            skills = person.getSkills();
         }
  @@ -306,14 +335,16 @@
      {
         Person person = ((Person) getPerson(key));
         Set skills = person.getSkills();
  -      if (skills != null) {
  +      if (skills != null)
  +      {
            skills.remove(skill);
         }
      }
   
      public Object testSerialization()
      {
  -      try {
  +      try
  +      {
            Person p = new Person();
            /*
            if (!(p instanceof Externalizable)) {
  @@ -326,16 +357,21 @@
            p.setAddress(address);
            cache.putObject("/person/joe", p);
            return (Person) cache.getObject("/person/joe");
  -      } catch (Throwable t) {
  +      }
  +      catch (Throwable t)
  +      {
            throw new RuntimeException(t);
         }
      }
   
      public void testDeserialization(String key, Object value)
      {
  -      try {
  +      try
  +      {
            cache.putObject(key, value);
  -      } catch (Throwable t) {
  +      }
  +      catch (Throwable t)
  +      {
            throw new RuntimeException(t);
         }
      }
  @@ -357,12 +393,15 @@
   
      public Object getFieldValue(String key, String name)
      {
  -      try {
  +      try
  +      {
            Object object = cache.getObject(key);
            Field f = object.getClass().getDeclaredField(name);
            f.setAccessible(true);
            return f.get(object);
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            throw new RuntimeException(e);
         }
      }
  
  
  



More information about the jboss-cvs-commits mailing list