dain        2005/02/11 17:30:23

  Modified:    modules/itests/src/itest/org/openejb/test/entity/cmp2
                        Cmp2HandleTests.java Cmp2HomeHandleTests.java
  Log:

  CMP container builder now propertly maps remove methods. This eliminates the 
ArrayIndexOutOfBoundsException in TransactionPolicyManager.
  Handle and HomeHandle can not be copied with serialization on client side.
  Added Handle copy tests to itest suite
  
  Revision  Changes    Path
  1.2       +41 -3     
openejb/modules/itests/src/itest/org/openejb/test/entity/cmp2/Cmp2HandleTests.java
  
  Index: Cmp2HandleTests.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/itests/src/itest/org/openejb/test/entity/cmp2/Cmp2HandleTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Cmp2HandleTests.java      14 Oct 2004 19:47:28 -0000      1.1
  +++ Cmp2HandleTests.java      11 Feb 2005 22:30:23 -0000      1.2
  @@ -44,7 +44,13 @@
    */
   package org.openejb.test.entity.cmp2;
   
  +import java.rmi.MarshalledObject;
  +import java.io.ByteArrayOutputStream;
  +import java.io.ObjectOutputStream;
  +import java.io.ByteArrayInputStream;
  +import java.io.ObjectInputStream;
   import javax.ejb.EJBObject;
  +import javax.ejb.Handle;
   
   import org.openejb.test.entity.cmp.BasicCmpHome;
   
  @@ -87,12 +93,44 @@
           }
       }
   
  +    public void test02_copyHandleByMarshalledObject() {
  +        try {
  +            MarshalledObject obj = new MarshalledObject(ejbHandle);
  +            Handle copy = (Handle) obj.get();
  +
  +            EJBObject object = copy.getEJBObject();
  +            assertNotNull("The EJBObject is null", object);
  +            assertTrue("EJBObjects are not identical", 
object.isIdentical(ejbObject));
  +        } catch (Exception e) {
  +            fail("Received Exception " + e.getClass() + " : " + 
e.getMessage());
  +        }
  +    }
  +
  +    public void test03_copyHandleBySerialize() {
  +        try {
  +            ByteArrayOutputStream baos = new ByteArrayOutputStream();
  +            ObjectOutputStream oos = new ObjectOutputStream(baos);
  +            oos.writeObject(ejbHandle);
  +            oos.flush();
  +            oos.close();
  +            ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());
  +            ObjectInputStream ois = new ObjectInputStream(bais);
  +            Handle copy = (Handle) ois.readObject();
  +
  +            EJBObject object = copy.getEJBObject();
  +            assertNotNull("The EJBObject is null", object);
  +            assertTrue("EJBObjects are not identical", 
object.isIdentical(ejbObject));
  +        } catch (Exception e) {
  +            fail("Received Exception " + e.getClass() + " : " + 
e.getMessage());
  +        }
  +    }
  +
       /**
        * This remove method of the EJBHome is placed hear as it
        * is more a test on the handle then on the remove method
        * itself.
        */
  -    public void test02_EJBHome_remove() {
  +    public void test04_EJBHome_remove() {
           try {
               ejbHome.remove(ejbHandle);
               try {
  @@ -108,8 +146,8 @@
               ejbObject = null;
           }
       }
  +
       //
       // Test handle methods
       //=================================
  -
   }
  
  
  
  1.2       +39 -1     
openejb/modules/itests/src/itest/org/openejb/test/entity/cmp2/Cmp2HomeHandleTests.java
  
  Index: Cmp2HomeHandleTests.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/itests/src/itest/org/openejb/test/entity/cmp2/Cmp2HomeHandleTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Cmp2HomeHandleTests.java  14 Oct 2004 19:47:28 -0000      1.1
  +++ Cmp2HomeHandleTests.java  11 Feb 2005 22:30:23 -0000      1.2
  @@ -44,7 +44,13 @@
    */
   package org.openejb.test.entity.cmp2;
   
  +import java.rmi.MarshalledObject;
  +import java.io.ByteArrayOutputStream;
  +import java.io.ObjectOutputStream;
  +import java.io.ByteArrayInputStream;
  +import java.io.ObjectInputStream;
   import javax.ejb.EJBHome;
  +import javax.ejb.HomeHandle;
   
   import org.openejb.test.entity.cmp.BasicCmpHome;
   
  @@ -70,6 +76,38 @@
       public void test01_getEJBHome() {
           try {
               EJBHome home = ejbHomeHandle.getEJBHome();
  +            assertNotNull("The EJBHome is null", home);
  +        } catch (Exception e) {
  +            fail("Received Exception " + e.getClass() + " : " + 
e.getMessage());
  +        }
  +    }
  +
  +    public void test02_copyHandleByMarshalledObject() {
  +        try {
  +            MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
  +            HomeHandle copy = (HomeHandle) obj.get();
  +
  +            assertNotNull("The HomeHandle copy is null", copy);
  +            EJBHome home = copy.getEJBHome();
  +            assertNotNull("The EJBHome is null", home);
  +        } catch (Exception e) {
  +            fail("Received Exception " + e.getClass() + " : " + 
e.getMessage());
  +        }
  +    }
  +
  +    public void test03_copyHandleBySerialize() {
  +        try {
  +            ByteArrayOutputStream baos = new ByteArrayOutputStream();
  +            ObjectOutputStream oos = new ObjectOutputStream(baos);
  +            oos.writeObject(ejbHomeHandle);
  +            oos.flush();
  +            oos.close();
  +            ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());
  +            ObjectInputStream ois = new ObjectInputStream(bais);
  +            HomeHandle copy = (HomeHandle) ois.readObject();
  +
  +            assertNotNull("The HomeHandle copy is null", copy);
  +            EJBHome home = copy.getEJBHome();
               assertNotNull("The EJBHome is null", home);
           } catch (Exception e) {
               fail("Received Exception " + e.getClass() + " : " + 
e.getMessage());
  
  
  

Reply via email to