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

Manik Surtani msurtani at jboss.com
Tue Aug 29 08:24:41 EDT 2006


  User: msurtani
  Date: 06/08/29 08:24:41

  Modified:    tests/functional/org/jboss/cache/marshall      
                        AsyncReplTest.java LocalTest.java SyncReplTest.java
  Removed:     tests/functional/org/jboss/cache/marshall       Address.java
                        Debug.java Person.java
  Log:
  Test data migrated to subpackage to reduce ambiguity
  
  Revision  Changes    Path
  1.8       +75 -54    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.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- AsyncReplTest.java	20 Jul 2006 11:14:17 -0000	1.7
  +++ AsyncReplTest.java	29 Aug 2006 12:24:41 -0000	1.8
  @@ -15,6 +15,8 @@
   import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.TreeCache;
   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;
   import org.jboss.cache.transaction.DummyTransactionManager;
   
  @@ -25,29 +27,33 @@
   
   /**
    * Test marshalling for async mode.
  + *
    * @author Ben Wang
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
  -public class AsyncReplTest extends TestCase {
  +public class AsyncReplTest extends TestCase
  +{
      TreeCache cache1, cache2;
  -   String props=null;
  +   String props = null;
      Person ben_;
      Address addr_;
      Throwable ex_;
   
  -   public AsyncReplTest(String name) {
  +   public AsyncReplTest(String name)
  +   {
         super(name);
      }
   
  -   public void setUp() throws Exception {
  +   public void setUp() throws Exception
  +   {
         super.setUp();
   
         log("creating cache1");
  -      cache1=createCache("TestCache");
  +      cache1 = createCache("TestCache");
   
         log("creating cache2");
   
  -      cache2=createCache("TestCache");
  +      cache2 = createCache("TestCache");
         
         addr_ = new Address();
         addr_.setCity("San Jose");
  @@ -56,11 +62,12 @@
         ben_.setAddress(addr_);
         
         // Pause to give caches time to see each other
  -      TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
  +      TestingUtil.blockUntilViewsReceived(new TreeCache[]{cache1, cache2}, 60000);
      }
   
  -   private TreeCache createCache(String name) throws Exception {
  -      TreeCache tree=new TreeCache();
  +   private TreeCache createCache(String name) throws Exception
  +   {
  +      TreeCache tree = new TreeCache();
         tree.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replAsync-service.xml"));
         tree.getConfiguration().setClusterName(name);
         // Use marshaller
  @@ -70,15 +77,18 @@
         return tree;
      }
   
  -   public void tearDown() throws Exception {
  +   public void tearDown() throws Exception
  +   {
         super.tearDown();
         cache1.remove("/");
  -      if(cache1 != null) {
  +      if (cache1 != null)
  +      {
            log("stopping cache1");
            cache1.stopService();
         }
   
  -      if(cache2 != null) {
  +      if (cache2 != null)
  +      {
            log("stopping cache2");
            cache2.stopService();
         }
  @@ -86,6 +96,7 @@
   
      /**
       * Test replication with classloaders.
  +    *
       * @throws Exception
       */
      public void testCLSet2() throws Exception
  @@ -106,10 +117,11 @@
            ben2 = cache2.get("/aop", "person");
            assertNotNull(ben2); 
            assertEquals(ben_.toString(), ben2.toString());
  -      } catch (Exception ex)
  +      }
  +      catch (Exception ex)
         {
            LogFactory.getLog("TEST").debug("Ex:", ex);
  -         fail("Test fails with exception " +ex);
  +         fail("Test fails with exception " + ex);
         }
   
         Class claz = clb.loadClass("org.jboss.cache.marshall.Address");
  @@ -137,10 +149,11 @@
            TestingUtil.sleepThread(1000);
            Object ben3 = cache1.get("/aop", "person");
            assertEquals(ben2.toString(), ben3.toString());
  -      } catch (Exception ex)
  +      }
  +      catch (Exception ex)
         {
            ex.printStackTrace();
  -         fail("Test fails with exception " +ex);
  +         fail("Test fails with exception " + ex);
         }
   
      }
  @@ -162,9 +175,10 @@
            // Can't cast it to Person. CCE will resutl.
            ben2 = cache2.get("/aop/1", "person");
            assertEquals(ben_.toString(), ben2.toString());
  -      } catch (Exception ex)
  +      }
  +      catch (Exception ex)
         {
  -         fail("Test fails with exception " +ex);
  +         fail("Test fails with exception " + ex);
         }
   
      }
  @@ -176,7 +190,7 @@
         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());
      }
  @@ -199,9 +213,10 @@
            // Can't cast it to Person. CCE will resutl.
            ben2 = cache2.get("/aop", "person");
            assertEquals(ben_.toString(), ben2.toString());
  -      } catch (Exception ex)
  +      }
  +      catch (Exception ex)
         {
  -         fail("Test fails with exception " +ex);
  +         fail("Test fails with exception " + ex);
         }
   
         Class claz = clb.loadClass("org.jboss.cache.marshall.Address");
  @@ -229,9 +244,10 @@
            TestingUtil.sleepThread(1000);
            Object ben3 = cache1.get("/aop", "person");
            assertEquals(ben2.toString(), ben3.toString());
  -      } catch (Exception ex)
  +      }
  +      catch (Exception ex)
         {
  -         fail("Test fails with exception " +ex);
  +         fail("Test fails with exception " + ex);
         }
   
      }
  @@ -241,31 +257,36 @@
         // Need to test out if app is not registered with beforehand??
      }
   
  -   Transaction beginTransaction() throws SystemException, NotSupportedException {
  -      DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +   Transaction beginTransaction() throws SystemException, NotSupportedException
  +   {
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         mgr.begin();
  -      Transaction tx=mgr.getTransaction();
  +      Transaction tx = mgr.getTransaction();
         return tx;
      }
   
  -   protected ClassLoader getClassLoader() throws Exception {
  -      String[] includesClasses = { "org.jboss.cache.marshall.Person",
  -                                   "org.jboss.cache.marshall.Address" };
  +   protected ClassLoader getClassLoader() throws Exception
  +   {
  +      String[] includesClasses = {"org.jboss.cache.marshall.Person",
  +              "org.jboss.cache.marshall.Address"};
         String [] excludesClasses = {};
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         return new SelectedClassnameClassLoader(includesClasses, excludesClasses, cl);
      }
   
  -   void log(String msg) {
  +   void log(String msg)
  +   {
         System.out.println("-- [" + Thread.currentThread() + "]: " + msg);
      }
   
   
  -   public static Test suite() {
  +   public static Test suite()
  +   {
         return new TestSuite(AsyncReplTest.class);
      }
   
  -   public static void main(String[] args) {
  +   public static void main(String[] args)
  +   {
         junit.textui.TestRunner.run(suite());
      }
   
  
  
  
  1.7       +45 -34    JBossCache/tests/functional/org/jboss/cache/marshall/LocalTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LocalTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/LocalTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- LocalTest.java	20 Jul 2006 09:03:54 -0000	1.6
  +++ LocalTest.java	29 Aug 2006 12:24:41 -0000	1.7
  @@ -7,52 +7,61 @@
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.config.Configuration;
   import org.jboss.cache.lock.IsolationLevel;
  +import org.jboss.cache.marshall.data.Debug;
   
   import javax.transaction.Transaction;
   import java.io.File;
  +import java.lang.reflect.Method;
   import java.net.URL;
   import java.net.URLClassLoader;
  -import java.lang.reflect.Method;
   
   /**
    * Simple functional tests for LegacyTreeCacheMarshaller
  + *
    * @author Ben Wang
  - * @version $Id: LocalTest.java,v 1.6 2006/07/20 09:03:54 msurtani Exp $
  + * @version $Id: LocalTest.java,v 1.7 2006/08/29 12:24:41 msurtani Exp $
    */
  -public class LocalTest extends TestCase {
  -   TreeCache cache=null;
  -   Transaction tx=null;
  -   final Fqn FQN=Fqn.fromString("/myNode");
  -   final String KEY="key";
  -   final String VALUE="value";
  +public class LocalTest extends TestCase
  +{
  +   TreeCache cache = null;
  +   Transaction tx = null;
  +   final Fqn FQN = Fqn.fromString("/myNode");
  +   final String KEY = "key";
  +   final String VALUE = "value";
      Exception ex;
   
   
  -   protected void setUp() throws Exception {
  +   protected void setUp() throws Exception
  +   {
         super.setUp();
  -      cache=new TreeCache();
  +      cache = new TreeCache();
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
         cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
         cache.createService();
         cache.startService();
  -      ex=null;
  +      ex = null;
      }
   
  -   protected void tearDown() throws Exception {
  +   protected void tearDown() throws Exception
  +   {
         super.tearDown();
  -      if(cache != null) {
  +      if (cache != null)
  +      {
            cache.stopService();
            cache.destroyService();
  -         cache=null;
  +         cache = null;
         }
  -      if(ex != null)
  +      if (ex != null)
  +      {
            throw ex;
      }
  +   }
   
  -   public void testClassloader() throws Exception {
  +   public void testClassloader() throws Exception
  +   {
         String jarDir = System.getProperty("test.jar.dir");
  -      File jar0 = new File(jarDir+ "/testMarshall.jar");
  +      File jar0 = new File(jarDir + "/testMarshall.jar");
         URL[] cp0 = {jar0.toURL()};
         URLClassLoader ucl0 = new URLClassLoader(cp0);
         Thread.currentThread().setContextClassLoader(ucl0);
  @@ -79,7 +88,7 @@
            Debug.displayClassInfo(value.getClass(), buffer, false);
            log(buffer.toString());
         }
  -      catch(Exception e)
  +      catch (Exception e)
         {
            e.printStackTrace();
            log("Failed to invoke getName: " + e);
  @@ -121,7 +130,7 @@
            Debug.displayClassInfo(value.getClass(), buffer, false);
            log(buffer.toString());
         }
  -      catch(Exception e)
  +      catch (Exception e)
         {
            e.printStackTrace();
            log("Failed to invoke: " + e);
  @@ -130,11 +139,13 @@
   
      }
   
  -   void log(String msg) {
  +   void log(String msg)
  +   {
         System.out.println("-- " + msg);
      }
   
  -   public static Test suite() {
  +   public static Test suite()
  +   {
         return new TestSuite(LocalTest.class);
      }
   
  
  
  
  1.7       +75 -59    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.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- SyncReplTest.java	20 Jul 2006 06:04:56 -0000	1.6
  +++ SyncReplTest.java	29 Aug 2006 12:24:41 -0000	1.7
  @@ -15,6 +15,8 @@
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.config.Configuration;
   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;
   import org.jboss.cache.transaction.DummyTransactionManager;
   
  @@ -26,30 +28,33 @@
   
   /**
    * Test case for marshalling using Sync mode.
  - * @author Ben Wang
    *
  - * @version $Revision: 1.6 $
  + * @author Ben Wang
  + * @version $Revision: 1.7 $
    */
  -public class SyncReplTest extends TestCase {
  +public class SyncReplTest extends TestCase
  +{
      TreeCache cache1, cache2;
  -   String props=null;
  +   String props = null;
      Person ben_;
      Address addr_;
      Throwable ex_;
   
  -   public SyncReplTest(String name) {
  +   public SyncReplTest(String name)
  +   {
         super(name);
      }
   
  -   public void setUp() throws Exception {
  +   public void setUp() throws Exception
  +   {
         super.setUp();
   
         log("creating cache1");
  -      cache1=createCache("TestCache");
  +      cache1 = createCache("TestCache");
   
         log("creating cache2");
   
  -      cache2=createCache("TestCache");
  +      cache2 = createCache("TestCache");
         addr_ = new Address();
         addr_.setCity("San Jose");
         ben_ = new Person();
  @@ -57,11 +62,12 @@
         ben_.setAddress(addr_);
         
         // Pause to give caches time to see each other
  -      TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
  +      TestingUtil.blockUntilViewsReceived(new TreeCache[]{cache1, cache2}, 60000);
      }
   
  -   private TreeCache createCache(String name) throws Exception {
  -      TreeCache tree=new TreeCache();
  +   private TreeCache createCache(String name) throws Exception
  +   {
  +      TreeCache tree = new TreeCache();
   
          XmlConfigurationParser parser = new XmlConfigurationParser();
          Configuration c = parser.parseFile("META-INF/replSync-service.xml");
  @@ -75,15 +81,18 @@
         return tree;
      }
   
  -   public void tearDown() throws Exception {
  +   public void tearDown() throws Exception
  +   {
         super.tearDown();
         cache1.remove("/");
  -      if(cache1 != null) {
  +      if (cache1 != null)
  +      {
            log("stopping cache1");
            cache1.stopService();
         }
   
  -      if(cache2 != null) {
  +      if (cache2 != null)
  +      {
            log("stopping cache2");
            cache2.stopService();
         }
  @@ -92,7 +101,7 @@
      public void testPlainPut() throws Exception
      {
         cache1.put("/aop", "person", ben_);
  -      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());
      }
  @@ -108,8 +117,9 @@
         Person ben2 = null;
         try
         {
  -         ben2 = (Person)cache2.get("/aop", "person");
  -      } catch (ClassCastException ex)
  +         ben2 = (Person) cache2.get("/aop", "person");
  +      }
  +      catch (ClassCastException ex)
         {
            // That's ok.
            return;
  @@ -166,6 +176,7 @@
   
      /**
       * Test replication with classloaders.
  +    *
       * @throws Exception
       */
      public void testCLSet2() throws Exception
  @@ -270,7 +281,7 @@
         cache1.remove("/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());
      }
  @@ -281,7 +292,7 @@
         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);
      }
   
  @@ -330,31 +341,36 @@
         // Need to test out if app is not registered with beforehand??
      }
   
  -   Transaction beginTransaction() throws SystemException, NotSupportedException {
  -      DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +   Transaction beginTransaction() throws SystemException, NotSupportedException
  +   {
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         mgr.begin();
  -      Transaction tx=mgr.getTransaction();
  +      Transaction tx = mgr.getTransaction();
         return tx;
      }
   
  -   protected ClassLoader getClassLoader() throws Exception {
  -      String[] includesClasses = { "org.jboss.cache.marshall.Person",
  -                                   "org.jboss.cache.marshall.Address" };
  +   protected ClassLoader getClassLoader() throws Exception
  +   {
  +      String[] includesClasses = {"org.jboss.cache.marshall.Person",
  +              "org.jboss.cache.marshall.Address"};
         String [] excludesClasses = {};
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         return new SelectedClassnameClassLoader(includesClasses, excludesClasses, cl);
      }
   
  -   void log(String msg) {
  +   void log(String msg)
  +   {
         System.out.println("-- [" + Thread.currentThread() + "]: " + msg);
      }
   
   
  -   public static Test suite() {
  +   public static Test suite()
  +   {
         return new TestSuite(SyncReplTest.class);
      }
   
  -   public static void main(String[] args) {
  +   public static void main(String[] args)
  +   {
         junit.textui.TestRunner.run(suite());
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list