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

Manik Surtani msurtani at belmont.prod.atl2.jboss.com
Wed Aug 30 13:08:19 EDT 2006


  User: msurtani
  Date: 06/08/30 13:08:19

  Modified:    tests/functional/org/jboss/cache/marshall   
                        ActiveInactiveTest.java
                        BaseTreeCacheMarshallerTest.java
  Added:       tests/functional/org/jboss/cache/marshall   
                        MethodCallFactoryTest.java
  Log:
  Java5 optimisations
  
  Revision  Changes    Path
  1.8       +75 -70    JBossCache/tests/functional/org/jboss/cache/marshall/ActiveInactiveTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ActiveInactiveTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/ActiveInactiveTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- ActiveInactiveTest.java	25 Aug 2006 14:10:10 -0000	1.7
  +++ ActiveInactiveTest.java	30 Aug 2006 17:08:19 -0000	1.8
  @@ -10,7 +10,6 @@
   import junit.framework.TestCase;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Version;
  -import org.jboss.cache.marshall.MethodCall;
   
   import java.lang.reflect.Method;
   
  @@ -37,10 +36,12 @@
               testee.isInactive("/"));
         
         RegionNameConflictException ex = null;
  -      try {
  +      try
  +      {
           testee.activate("/a/b");
         }
  -      catch (RegionNameConflictException e) {
  +      catch (RegionNameConflictException e)
  +      {
            ex = e;
         }
         assertNull("No RegionNameConflictException against default region", ex);
  @@ -48,11 +49,13 @@
         testee.inactivate("/");
         assertTrue("Root is inactive", testee.isInactive("/"));
         
  -      try {
  +      try
  +      {
            testee.activate("/a");
            fail("Did not throw RegionNameConflictException when overriding '/'");
          }
  -       catch (RegionNameConflictException e) {
  +      catch (RegionNameConflictException e)
  +      {
             // good
          }
      }
  @@ -71,10 +74,12 @@
               testee.isInactive("/"));
         
         RegionNameConflictException ex = null;
  -      try {
  +      try
  +      {
           testee.inactivate("/a/b");
         }
  -      catch (RegionNameConflictException e) {
  +      catch (RegionNameConflictException e)
  +      {
            ex = e;
         }
         assertNull("Caught RegionNameConflictException against default region", ex);
  @@ -141,9 +146,9 @@
      public void testObjectFromByteBuffer() throws Exception
      {
         MethodCall put = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal,
  -            new Object[] { null, Fqn.fromString("/a/b"), "name", "Joe", Boolean.FALSE });
  +              null, Fqn.fromString("/a/b"), "name", "Joe", false);
         
  -      MethodCall replicate = MethodCallFactory.create(MethodDeclarations.replicateMethod, new Object[] { put });
  +      MethodCall replicate = MethodCallFactory.create(MethodDeclarations.replicateMethod, put);
   
         VersionAwareMarshaller testee = new VersionAwareMarshaller(new RegionManager(), true, true, Version.getVersionString(Version.getVersionShort()));
         byte[] callBytes = testee.objectToByteBuffer(replicate);
  
  
  
  1.4       +12 -12    JBossCache/tests/functional/org/jboss/cache/marshall/BaseTreeCacheMarshallerTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BaseTreeCacheMarshallerTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/marshall/BaseTreeCacheMarshallerTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- BaseTreeCacheMarshallerTest.java	30 Aug 2006 15:03:33 -0000	1.3
  +++ BaseTreeCacheMarshallerTest.java	30 Aug 2006 17:08:19 -0000	1.4
  @@ -103,7 +103,7 @@
   
      public void testNonStringBasedFqn() throws Exception
      {
  -      Fqn fqn = new Fqn(new Object[]{3, Boolean.FALSE});
  +      Fqn fqn = new Fqn(new Object[]{3, false});
         byte[] asBytes = marshaller.objectToByteBuffer(fqn);
         Object o2 = marshaller.objectFromByteBuffer(asBytes);
         assertEquals(fqn, o2);
  @@ -111,8 +111,8 @@
   
      public void testMethodCall() throws Exception
      {
  -      Fqn fqn = new Fqn(new Object[]{3, Boolean.FALSE});
  -      MethodCall call = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{null, fqn, "key", "value", Boolean.TRUE});
  +      Fqn fqn = new Fqn(new Object[]{3, false});
  +      MethodCall call = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, fqn, "key", "value", true);
         byte[] asBytes = marshaller.objectToByteBuffer(call);
         Object o2 = marshaller.objectFromByteBuffer(asBytes);
   
  @@ -124,9 +124,9 @@
   
      public void testNestedMethodCall() throws Exception
      {
  -      Fqn fqn = new Fqn(new Object[]{3, Boolean.FALSE});
  -      MethodCall call = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{null, fqn, "key", "value", Boolean.TRUE});
  -      MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, new Object[]{call});
  +      Fqn fqn = new Fqn(new Object[]{3, false});
  +      MethodCall call = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, fqn, "key", "value", true);
  +      MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, call);
         byte[] asBytes = marshaller.objectToByteBuffer(replicateCall);
         Object o2 = marshaller.objectFromByteBuffer(asBytes);
         assertTrue("Unmarshalled object should be a method call", o2 instanceof MethodCall);
  @@ -211,20 +211,20 @@
         // replication queue takes a list of replicate() MethodCalls and wraps them in a single replicate call.
         List<MethodCall> calls = new ArrayList<MethodCall>();
   
  -      Fqn f = new Fqn(new Object[]{"BlahBlah", 3, Boolean.FALSE});
  +      Fqn f = new Fqn(new Object[]{"BlahBlah", 3, false});
         String k = "key", v = "value";
   
  -      MethodCall actualCall = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{null, f, k, v, Boolean.TRUE});
  -      MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, new Object[]{actualCall});
  +      MethodCall actualCall = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, f, k, v, true);
  +      MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, actualCall);
   
         calls.add(replicateCall);
   
  -      actualCall = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, new Object[]{null, f, k, v, Boolean.TRUE});
  -      replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, new Object[]{actualCall});
  +      actualCall = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, f, k, v, true);
  +      replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, actualCall);
   
         calls.add(replicateCall);
   
  -      MethodCall call = MethodCallFactory.create(MethodDeclarations.replicateAllMethod, new Object[]{calls});
  +      MethodCall call = MethodCallFactory.create(MethodDeclarations.replicateAllMethod, calls);
   
         byte[] buf = marshaller.objectToByteBuffer(call);
   
  
  
  
  1.1      date: 2006/08/30 17:08:19;  author: msurtani;  state: Exp;JBossCache/tests/functional/org/jboss/cache/marshall/MethodCallFactoryTest.java
  
  Index: MethodCallFactoryTest.java
  ===================================================================
  package org.jboss.cache.marshall;
  
  import junit.framework.TestCase;
  import org.jboss.cache.GlobalTransaction;
  
  /**
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   */
  public class MethodCallFactoryTest extends TestCase
  {
     public void testVarArgsMethod()
     {
        GlobalTransaction gtx = new GlobalTransaction();
        MethodCall c = MethodCallFactory.create(MethodDeclarations.commitMethod, gtx);
  
        assertEquals(gtx, c.getArgs()[0]);
     }
  
     public void testObjectArrayMethod()
     {
        GlobalTransaction gtx = new GlobalTransaction();
        MethodCall c = MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{gtx});
  
        assertEquals(gtx, c.getArgs()[0]);
     }
  
     public void testMultipleArrayElems()
     {
        GlobalTransaction gtx = new GlobalTransaction();
        MethodCall c = MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{gtx, gtx, gtx});
  
        assertEquals(gtx, c.getArgs()[0]);
        assertEquals(gtx, c.getArgs()[1]);
        assertEquals(gtx, c.getArgs()[2]);
  
        assertEquals(3, c.getArgs().length);
     }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list