You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/03/21 03:03:19 UTC

svn commit: r520702 - in /incubator/openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/ itests/openejb-itests-beans/src/main/java/org/...

Author: dain
Date: Tue Mar 20 19:03:17 2007
New Revision: 520702

URL: http://svn.apache.org/viewvc?view=rev&rev=520702
Log:
Complex primary key support for CMP 2.x beans

Added:
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmp2Bean.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbMetaDataTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HandleTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeHandleTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeIntfcTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2RemoteIntfcTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/ComplexCmp2TestClient.java
Modified:
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp1Generator.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmp2Bean.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpHome.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpObject.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/HsqldbTestDatabase.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/BasicCmp2TestClient.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java
    incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2TestSuite.java

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java Tue Mar 20 19:03:17 2007
@@ -100,6 +100,15 @@
             throw new IOException("Could not find entity bean class " + beanClass);
         }
 
+        Class<?> primKeyClass = null;
+        if (entityBeanInfo.primKeyClass != null) {
+            try {
+                primKeyClass = tempClassLoader.loadClass(entityBeanInfo.primKeyClass);
+            } catch (ClassNotFoundException e) {
+                throw new IOException("Could not find entity primary key class " + entityBeanInfo.primKeyClass);
+            }
+        }
+
         byte[] bytes = null;
         if (entityBeanInfo.cmpVersion != 2) {
             Cmp1Generator cmp1Generator = new Cmp1Generator(cmpImplClass, beanClass);
@@ -113,6 +122,7 @@
             Cmp2Generator cmp2Generator = new Cmp2Generator(cmpImplClass,
                     beanClass,
                     entityBeanInfo.primKeyField,
+                    primKeyClass,
                     entityBeanInfo.cmpFieldNames.toArray(new String[entityBeanInfo.cmpFieldNames.size()]));
 
             for (CmrFieldInfo cmrFieldInfo : entityBeanInfo.cmrFields) {

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp1Generator.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp1Generator.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp1Generator.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp1Generator.java Tue Mar 20 19:03:17 2007
@@ -20,6 +20,7 @@
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
+import org.objectweb.asm.FieldVisitor;
 
 public class Cmp1Generator implements Opcodes {
     private String implClassName;
@@ -40,7 +41,8 @@
         // if we have an unknown pk, we need to add a field for the pk
         if (unknownPk) {
             // public Long OpenEJB_pk;
-            cw.visitField(ACC_PUBLIC, "OpenEJB_pk", "Ljava/lang/Long;", null, null);
+            FieldVisitor fv = cw.visitField(ACC_PUBLIC, "OpenEJB_pk", "Ljava/lang/Long;", null, null);
+            fv.visitEnd();
         }
 
         createConstructor();

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java Tue Mar 20 19:03:17 2007
@@ -17,10 +17,6 @@
  */
 package org.apache.openejb.core.cmp.cmp2;
 
-import java.lang.reflect.Method;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.FieldVisitor;
 import org.objectweb.asm.Label;
@@ -28,17 +24,28 @@
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
 
+import java.lang.reflect.Method;
+import java.lang.reflect.Field;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 public class Cmp2Generator implements Opcodes {
-    private String implClassName;
-    private String beanClassName;
-    private ClassWriter cw;
+    private static final String UNKNOWN_PK_NAME = "OpenEJB_pk";
+    private static final String UNKNOWN_PK_DESCRIPTOR = Type.LONG_TYPE.getDescriptor();
+
+    private final String implClassName;
+    private final String beanClassName;
+    private final ClassWriter cw;
     private final Map<String, CmpField> cmpFields = new LinkedHashMap<String, CmpField>();
     private final Map<String, CmrField> cmrFields = new LinkedHashMap<String, CmrField>();
-    private CmpField pkField;
+    private final CmpField pkField;
+    private final Class primKeyClass;
 
-    public Cmp2Generator(String cmpImplClass, Class beanClass, String pkField, String[] cmrFields) {
+    public Cmp2Generator(String cmpImplClass, Class beanClass, String pkField, Class<?> primKeyClass, String[] cmrFields) {
+        if (pkField == null && primKeyClass == null) throw new NullPointerException("Both pkField and primKeyClass are null");
         beanClassName = Type.getInternalName(beanClass);
         implClassName = cmpImplClass.replace('.', '/');
+        this.primKeyClass = primKeyClass;
 
         for (String cmpFieldName : cmrFields) {
             String getterName = getterName(cmpFieldName);
@@ -52,11 +59,15 @@
             }
         }
 
-        this.pkField = cmpFields.get(pkField);
-        // todo warn about unsupported complex primary key
-        if (pkField != null && this.pkField == null) {
-            throw new IllegalArgumentException("No such property " + pkField + " defined on bean class " + beanClassName);
+        if (pkField != null) {
+            this.pkField = cmpFields.get(pkField);
+            if (this.pkField == null) {
+                throw new IllegalArgumentException("No such property " + pkField + " defined on bean class " + beanClassName);
+            }
+        } else {
+            this.pkField = null;
         }
+
         cw = new ClassWriter(true);
     }
 
@@ -79,6 +90,11 @@
             fv.visitEnd();
         }
 
+        if (Object.class.equals(primKeyClass)) {
+            FieldVisitor fv = cw.visitField(ACC_PRIVATE, UNKNOWN_PK_NAME, UNKNOWN_PK_DESCRIPTOR, null, null);
+            fv.visitEnd();
+        }
+
         // private ${cmpField.type} ${cmpField.name};
         for (CmpField cmpField : cmpFields.values()) {
             createField(cmpField);
@@ -107,7 +123,7 @@
             createCmrSetter(cmrField);
         }
 
-        createSimplePrimaryKeyGetter(pkField);
+        createSimplePrimaryKeyGetter();
 
         createOpenEJB_deleted();
 
@@ -305,20 +321,64 @@
         return "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
     }
 
-    private void createSimplePrimaryKeyGetter(CmpField pkField) {
-        // todo complex pk
-        if (pkField == null) return;
+    private void createSimplePrimaryKeyGetter() {
+        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "OpenEJB_getPrimaryKey", "()Ljava/lang/Object;", null, null);
+        if (pkField != null) {
+            String descriptor = pkField.getType().getDescriptor();
+
+            // push the pk field
+            mv.visitVarInsn(ALOAD, 0);
+            mv.visitFieldInsn(GETFIELD, implClassName, pkField.getName(), descriptor);
+
+            // return the pk field (from the stack)
+            mv.visitInsn(pkField.getType().getOpcode(IRETURN));
+        } else if (Object.class.equals(primKeyClass)) {
+            // push the pk field
+            mv.visitVarInsn(ALOAD, 0);
+            mv.visitFieldInsn(GETFIELD, implClassName, UNKNOWN_PK_NAME, UNKNOWN_PK_DESCRIPTOR);
+
+            // return the pk field (from the stack)
+            mv.visitInsn(pkField.getType().getOpcode(IRETURN));
+        } else {
+            String pkImplName = primKeyClass.getName().replace('.', '/');
+
+            // new Pk();
+            mv.visitTypeInsn(NEW, pkImplName);
+            mv.visitInsn(DUP);
+            mv.visitMethodInsn(INVOKESPECIAL, pkImplName, "<init>", "()V");
+            mv.visitVarInsn(ASTORE, 1);
+            mv.visitVarInsn(ALOAD, 1);
+
+            // copy each field from the ejb to the pk class
+            for (Field field : primKeyClass.getFields()) {
+                CmpField cmpField = cmpFields.get(field.getName());
+
+                // only process the cmp fields
+                if (cmpField == null) {
+                    continue;
+                }
+
+                // verify types match... this should have been caught by the verifier, but
+                // check again since generated code is so hard to debug
+                if (!cmpField.getType().getClassName().equals(field.getType().getName())) {
+                    throw new IllegalArgumentException("Primary key " + cmpField.getName() + " is type " + cmpField.getType().getClassName() + " but CMP field is type " + field.getType().getName());
+                }
+
+                // push the value from the cmp bean
+                mv.visitVarInsn(ALOAD, 0);
+                mv.visitFieldInsn(GETFIELD, implClassName, cmpField.getName(), cmpField.getDescriptor());
+                // set matching field in the pk class to the value on the stack
+                mv.visitFieldInsn(PUTFIELD, pkImplName, cmpField.getName(), cmpField.getDescriptor());
+                mv.visitVarInsn(ALOAD, 1);
+            }
 
-        String descriptor = pkField.getType().getDescriptor();
+            // return the Pk();
+            mv.visitInsn(ARETURN);
+        }
 
-        String methodName = "OpenEJB_getPrimaryKey";
-        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "()Ljava/lang/Object;", null, null);
-        mv.visitVarInsn(ALOAD, 0);
-        mv.visitFieldInsn(GETFIELD, implClassName, pkField.getName(), descriptor);
-        mv.visitInsn(pkField.getType().getOpcode(IRETURN));
         mv.visitMaxs(0, 0);
+        mv.visitEnd();
     }
-
 
     private void createCmrFields(CmrField cmrField) {
         FieldVisitor fv = cw.visitField(ACC_PRIVATE,

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmp2Bean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmp2Bean.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmp2Bean.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmp2Bean.java Tue Mar 20 19:03:17 2007
@@ -22,14 +22,15 @@
 import javax.ejb.CreateException;
 import javax.ejb.EntityBean;
 import javax.ejb.EntityContext;
-import java.util.Hashtable;
 import java.util.Properties;
 import java.util.StringTokenizer;
+import java.util.Map;
+import java.util.HashMap;
 
 public abstract class BasicCmp2Bean implements EntityBean {
     private static int nextId;
     public EntityContext ejbContext;
-    public Hashtable allowedOperationsTable = new Hashtable();
+    public Map<String,OperationsPolicy> allowedOperationsTable = new HashMap<String,OperationsPolicy>();
 
     public abstract Integer getId();
 
@@ -72,19 +73,6 @@
     public void ejbPostCreateObject(String name) {
     }
     
-    /**
-     * Maps to BasicCmpHome.create(Integer primarykey, String name)
-     */
-    public Integer ejbCreate(Integer primarykey, String name) throws CreateException {
-        StringTokenizer st = new StringTokenizer(name, " ");
-        setFirstName(st.nextToken());
-        setLastName(st.nextToken());
-        setId(primarykey);
-        return null;
-    }
-
-    public void ejbPostCreate(Integer primarykey, String name) throws CreateException {
-    }
     //
     // Home interface methods
     //=============================
@@ -142,7 +130,7 @@
      * @param methodName The method for which to get the allowed opperations report
      */
     public OperationsPolicy getAllowedOperationsReport(String methodName) {
-        return (OperationsPolicy) allowedOperationsTable.get(methodName);
+        return allowedOperationsTable.get(methodName);
     }
 
     //
@@ -227,56 +215,56 @@
         /*[1] Test getEJBHome /////////////////*/
         try {
             ejbContext.getEJBHome();
-            policy.allow(policy.Context_getEJBHome);
+            policy.allow(OperationsPolicy.Context_getEJBHome);
         } catch (IllegalStateException ise) {
         }
 
         /*[2] Test getCallerPrincipal /////////*/
         try {
             ejbContext.getCallerPrincipal();
-            policy.allow(policy.Context_getCallerPrincipal);
+            policy.allow(OperationsPolicy.Context_getCallerPrincipal);
         } catch (IllegalStateException ise) {
         }
 
         /*[3] Test isCallerInRole /////////////*/
         try {
             ejbContext.isCallerInRole("ROLE");
-            policy.allow(policy.Context_isCallerInRole);
+            policy.allow(OperationsPolicy.Context_isCallerInRole);
         } catch (IllegalStateException ise) {
         }
 
         /*[4] Test getRollbackOnly ////////////*/
         try {
             ejbContext.getRollbackOnly();
-            policy.allow(policy.Context_getRollbackOnly);
+            policy.allow(OperationsPolicy.Context_getRollbackOnly);
         } catch (IllegalStateException ise) {
         }
 
         /*[5] Test setRollbackOnly ////////////*/
         try {
             ejbContext.setRollbackOnly();
-            policy.allow(policy.Context_setRollbackOnly);
+            policy.allow(OperationsPolicy.Context_setRollbackOnly);
         } catch (IllegalStateException ise) {
         }
 
         /*[6] Test getUserTransaction /////////*/
         try {
             ejbContext.getUserTransaction();
-            policy.allow(policy.Context_getUserTransaction);
+            policy.allow(OperationsPolicy.Context_getUserTransaction);
         } catch (Exception e) {
         }
 
         /*[7] Test getEJBObject ///////////////*/
         try {
             ejbContext.getEJBObject();
-            policy.allow(policy.Context_getEJBObject);
+            policy.allow(OperationsPolicy.Context_getEJBObject);
         } catch (IllegalStateException ise) {
         }
 
         /*[8] Test getPrimaryKey //////////////*/
         try {
             ejbContext.getPrimaryKey();
-            policy.allow(policy.Context_getPrimaryKey);
+            policy.allow(OperationsPolicy.Context_getPrimaryKey);
         } catch (IllegalStateException ise) {
         }
 

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpHome.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpHome.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpHome.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpHome.java Tue Mar 20 19:03:17 2007
@@ -16,26 +16,24 @@
  */
 package org.apache.openejb.test.entity.cmp;
 
+import javax.ejb.CreateException;
+import javax.ejb.FinderException;
+import java.rmi.RemoteException;
+import java.util.Collection;
+
 
 /**
- * 
  * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
  * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
  */
 public interface BasicCmpHome extends javax.ejb.EJBHome {
+    BasicCmpObject createObject(String name) throws CreateException, RemoteException;
 
-
-    public BasicCmpObject createObject(String name)
-    throws javax.ejb.CreateException, java.rmi.RemoteException;
-    
-    public BasicCmpObject findByPrimaryKey(Integer primarykey)
-    throws javax.ejb.FinderException, java.rmi.RemoteException;
+    BasicCmpObject findByPrimaryKey(Integer primarykey) throws FinderException, RemoteException;
     
-    public java.util.Collection findEmptyCollection()
-    throws javax.ejb.FinderException, java.rmi.RemoteException;
+    Collection findEmptyCollection() throws FinderException, RemoteException;
     
-    public java.util.Collection findByLastName(String lastName)
-    throws javax.ejb.FinderException, java.rmi.RemoteException;
+    Collection findByLastName(String lastName) throws FinderException, RemoteException;
     
-    public int sum(int x, int y) throws java.rmi.RemoteException;
+    int sum(int x, int y) throws RemoteException;
 }

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpObject.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpObject.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpObject.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/BasicCmpObject.java Tue Mar 20 19:03:17 2007
@@ -22,40 +22,36 @@
 import org.apache.openejb.test.ApplicationException;
 import org.apache.openejb.test.object.OperationsPolicy;
 
+import javax.ejb.EJBObject;
+
 /**
- * 
  * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
  * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
  */
-public interface BasicCmpObject extends javax.ejb.EJBObject{
-    
+public interface BasicCmpObject extends EJBObject{
     /**
      * Reverses the string passed in then returns it
-     * 
      */
-    public String businessMethod(String text) throws RemoteException;
+    String businessMethod(String text) throws RemoteException;
     
     /**
      * Throws an ApplicationException when invoked
-     * 
      */
-    public void throwApplicationException() throws RemoteException, ApplicationException;
+    void throwApplicationException() throws RemoteException, ApplicationException;
     
     /**
      * Throws a java.lang.NullPointerException when invoked
      * This is a system exception and should result in the 
      * destruction of the instance and invalidation of the
      * remote reference.
-     * 
      */
-    public void throwSystemException_NullPointer() throws RemoteException;
+    void throwSystemException_NullPointer() throws RemoteException;
     
     /**
      * Returns a report of the bean's 
      * runtime permissions
-     * 
      */
-    public Properties getPermissionsReport() throws RemoteException;
+    Properties getPermissionsReport() throws RemoteException;
     
     /**
      * Returns a report of the allowed opperations
@@ -63,5 +59,5 @@
      * 
      * @param methodName The method for which to get the allowed opperations report
      */
-    public OperationsPolicy getAllowedOperationsReport(String methodName) throws RemoteException;
+    OperationsPolicy getAllowedOperationsReport(String methodName) throws RemoteException;
 }

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmp2Bean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmp2Bean.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmp2Bean.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmp2Bean.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,273 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp;
+
+import org.apache.openejb.test.ApplicationException;
+import org.apache.openejb.test.object.OperationsPolicy;
+
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.CreateException;
+import java.util.StringTokenizer;
+import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+
+public abstract class ComplexCmp2Bean implements EntityBean {
+    public EntityContext ejbContext;
+    public Map<String,OperationsPolicy> allowedOperationsTable = new HashMap<String,OperationsPolicy>();
+
+    public abstract String getFirstName();
+
+    public abstract void setFirstName(String firstName);
+
+    public abstract String getLastName();
+
+    public abstract void setLastName(String lastName);
+
+
+    //=============================
+    // Home interface methods
+    //
+
+    /**
+     * Maps to BasicCmpHome.sum
+     *
+     * Adds x and y and returns the result.
+     */
+    public int ejbHomeSum(int x, int y) {
+        testAllowedOperations("ejbHome");
+        return x + y;
+    }
+
+    /**
+     * Maps to BasicCmpHome.create(String name)
+     */
+    public ComplexCmpBeanPk ejbCreateObject(String name) throws CreateException {
+        StringTokenizer st = new StringTokenizer(name, " ");
+        setFirstName(st.nextToken());
+        setLastName(st.nextToken());
+        return null;
+    }
+
+    public void ejbPostCreateObject(String name) {
+    }
+
+    //
+    // Home interface methods
+    //=============================
+
+
+    //=============================
+    // Remote interface methods
+    //
+
+    /**
+     * Maps to BasicCmpObject.businessMethod
+     */
+    public String businessMethod(String text) {
+        testAllowedOperations("businessMethod");
+        StringBuffer b = new StringBuffer(text);
+        return b.reverse().toString();
+    }
+
+
+    /**
+     * Throws an ApplicationException when invoked
+     */
+    public void throwApplicationException() throws ApplicationException {
+        throw new ApplicationException("Testing ability to throw Application Exceptions");
+    }
+
+    /**
+     * Throws a java.lang.NullPointerException when invoked
+     * This is a system exception and should result in the
+     * destruction of the instance and invalidation of the
+     * remote reference.
+     */
+    public void throwSystemException_NullPointer() {
+        throw new NullPointerException("Testing ability to throw System Exceptions");
+    }
+
+
+    /**
+     * Maps to BasicCmpObject.getPermissionsReport
+     *
+     * Returns a report of the bean's
+     * runtime permissions
+     */
+    public Properties getPermissionsReport() {
+        /* TO DO: */
+        return null;
+    }
+
+    /**
+     * Maps to BasicCmpObject.getAllowedOperationsReport
+     *
+     * Returns a report of the allowed opperations
+     * for one of the bean's methods.
+     *
+     * @param methodName The method for which to get the allowed opperations report
+     */
+    public OperationsPolicy getAllowedOperationsReport(String methodName) {
+        return allowedOperationsTable.get(methodName);
+    }
+
+    //
+    // Remote interface methods
+    //=============================
+
+
+    //================================
+    // EntityBean interface methods
+    //
+
+    /**
+     * A container invokes this method to instruct the
+     * instance to synchronize its state by loading it state from the
+     * underlying database.
+     */
+    public void ejbLoad() {
+    }
+
+    /**
+     * Set the associated entity context. The container invokes this method
+     * on an instance after the instance has been created.
+     */
+    public void setEntityContext(EntityContext ctx) {
+        ejbContext = ctx;
+        testAllowedOperations("setEntityContext");
+    }
+
+    /**
+     * Unset the associated entity context. The container calls this method
+     * before removing the instance.
+     */
+    public void unsetEntityContext() {
+        testAllowedOperations("unsetEntityContext");
+    }
+
+    /**
+     * A container invokes this method to instruct the
+     * instance to synchronize its state by storing it to the underlying
+     * database.
+     */
+    public void ejbStore() {
+    }
+
+    /**
+     * A container invokes this method before it removes the EJB object
+     * that is currently associated with the instance. This method
+     * is invoked when a client invokes a remove operation on the
+     * enterprise Bean's home interface or the EJB object's remote interface.
+     * This method transitions the instance from the ready state to the pool
+     * of available instances.
+     */
+    public void ejbRemove() {
+    }
+
+    /**
+     * A container invokes this method when the instance
+     * is taken out of the pool of available instances to become associated
+     * with a specific EJB object. This method transitions the instance to
+     * the ready state.
+     */
+    public void ejbActivate() {
+        testAllowedOperations("ejbActivate");
+    }
+
+    /**
+     * A container invokes this method on an instance before the instance
+     * becomes disassociated with a specific EJB object. After this method
+     * completes, the container will place the instance into the pool of
+     * available instances.
+     */
+    public void ejbPassivate() {
+        testAllowedOperations("ejbPassivate");
+    }
+    //
+    // EntityBean interface methods
+    //================================
+
+    protected void testAllowedOperations(String methodName) {
+        OperationsPolicy policy = new OperationsPolicy();
+
+        /*[1] Test getEJBHome /////////////////*/
+        try {
+            ejbContext.getEJBHome();
+            policy.allow(OperationsPolicy.Context_getEJBHome);
+        } catch (IllegalStateException ise) {
+        }
+
+        /*[2] Test getCallerPrincipal /////////*/
+        try {
+            ejbContext.getCallerPrincipal();
+            policy.allow(OperationsPolicy.Context_getCallerPrincipal);
+        } catch (IllegalStateException ise) {
+        }
+
+        /*[3] Test isCallerInRole /////////////*/
+        try {
+            ejbContext.isCallerInRole("ROLE");
+            policy.allow(OperationsPolicy.Context_isCallerInRole);
+        } catch (IllegalStateException ise) {
+        }
+
+        /*[4] Test getRollbackOnly ////////////*/
+        try {
+            ejbContext.getRollbackOnly();
+            policy.allow(OperationsPolicy.Context_getRollbackOnly);
+        } catch (IllegalStateException ise) {
+        }
+
+        /*[5] Test setRollbackOnly ////////////*/
+        try {
+            ejbContext.setRollbackOnly();
+            policy.allow(OperationsPolicy.Context_setRollbackOnly);
+        } catch (IllegalStateException ise) {
+        }
+
+        /*[6] Test getUserTransaction /////////*/
+        try {
+            ejbContext.getUserTransaction();
+            policy.allow(OperationsPolicy.Context_getUserTransaction);
+        } catch (Exception e) {
+        }
+
+        /*[7] Test getEJBObject ///////////////*/
+        try {
+            ejbContext.getEJBObject();
+            policy.allow(OperationsPolicy.Context_getEJBObject);
+        } catch (IllegalStateException ise) {
+        }
+
+        /*[8] Test getPrimaryKey //////////////*/
+        try {
+            ejbContext.getPrimaryKey();
+            policy.allow(OperationsPolicy.Context_getPrimaryKey);
+        } catch (IllegalStateException ise) {
+        }
+
+        /* TO DO:
+         * Check for policy.Enterprise_bean_access
+         * Check for policy.JNDI_access_to_java_comp_env
+         * Check for policy.Resource_manager_access
+         */
+        allowedOperationsTable.put(methodName, policy);
+    }
+}

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml Tue Mar 20 19:03:17 2007
@@ -163,6 +163,30 @@
       </resource-ref>
     </entity>
 
+    <entity>
+      <ejb-name>ComplexCmp2Bean</ejb-name>
+      <home>org.apache.openejb.test.entity.cmp.ComplexCmpHome</home>
+      <remote>org.apache.openejb.test.entity.cmp.ComplexCmpObject</remote>
+      <ejb-class>org.apache.openejb.test.entity.cmp.ComplexCmp2Bean</ejb-class>
+      <persistence-type>Container</persistence-type>
+      <cmp-version>2.x</cmp-version>
+      <abstract-schema-name>ComplexCmp2Bean</abstract-schema-name>
+      <prim-key-class>org.apache.openejb.test.entity.cmp.ComplexCmpBeanPk</prim-key-class>
+      <reentrant>false</reentrant>
+      <cmp-field>
+        <field-name>firstName</field-name>
+      </cmp-field>
+      <cmp-field>
+        <field-name>lastName</field-name>
+      </cmp-field>
+      <resource-ref>
+        <description>This is a reference to a JDBC database.</description>
+        <res-ref-name>jdbc/basic/entityDatabase</res-ref-name>
+        <res-type>javax.sql.DataSource</res-type>
+        <res-auth>Container</res-auth>
+      </resource-ref>
+    </entity>
+
     <!--
     ########################################################
     ID:  client/tests/entity/cmp/allowed_operations/EntityHome

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml Tue Mar 20 19:03:17 2007
@@ -93,6 +93,25 @@
       <object-ql>SELECT o FROM BasicCmp2Bean o WHERE 'true' = 'false'</object-ql>
     </query>
   </ejb-deployment>
+  <ejb-deployment ejb-name="ComplexCmp2Bean" deployment-id="client/tests/entity/cmp2/ComplexCmpHome" container-id="Default CMP Container">
+    <resource-link res-ref-name="jdbc/basic/entityDatabase" res-id="Default JDBC Database"/>
+    <query>
+      <query-method>
+        <method-name>findByLastName</method-name>
+        <method-params>
+          <method-param>java.lang.String</method-param>
+        </method-params>
+      </query-method>
+      <object-ql>SELECT o FROM ComplexCmp2Bean o WHERE o.lastName = ?1</object-ql>
+    </query>
+    <query>
+      <query-method>
+        <method-name>findEmptyCollection</method-name>
+        <method-params/>
+      </query-method>
+      <object-ql>SELECT o FROM ComplexCmp2Bean o WHERE 'true' = 'false'</object-ql>
+    </query>
+  </ejb-deployment>
   <ejb-deployment ejb-name="AOBasicCmpBean" deployment-id="client/tests/entity/cmp/allowed_operations/EntityHome" container-id="Default CMP Container">
     <resource-link res-ref-name="jdbc/basic/entityDatabase" res-id="Default JDBC Database"/>
     <query>

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/HsqldbTestDatabase.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/HsqldbTestDatabase.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/HsqldbTestDatabase.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/HsqldbTestDatabase.java Tue Mar 20 19:03:17 2007
@@ -66,6 +66,7 @@
             "UnknownCmpBean",
             "UnknownCmpBeanX",
             "BasicCmp2Bean",
+            "ComplexCmp2Bean",
             "AllowedOperationsCmpBean",
             "AllowedOperationsCmp2Bean",
             "EncCmpBean",

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/BasicCmp2TestClient.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/BasicCmp2TestClient.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/BasicCmp2TestClient.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/BasicCmp2TestClient.java Tue Mar 20 19:03:17 2007
@@ -19,11 +19,7 @@
 import org.apache.openejb.test.entity.cmp.BasicCmpHome;
 import org.apache.openejb.test.entity.cmp.BasicCmpObject;
 
-/**
- * 
- */
 public abstract class BasicCmp2TestClient extends Cmp2TestClient {
-
     protected BasicCmpHome ejbHome;
     protected BasicCmpObject ejbObject;
 

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2EjbHomeTests.java Tue Mar 20 19:03:17 2007
@@ -66,7 +66,6 @@
                 assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
             } catch (Exception e) {
                 assertTrue(true);
-                return;
             }
         } catch (Exception e) {
             fail("Received Exception " + e.getClass() + " : " + e.getMessage());

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2TestSuite.java?view=diff&rev=520702&r1=520701&r2=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2TestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Cmp2TestSuite.java Tue Mar 20 19:03:17 2007
@@ -42,6 +42,22 @@
         this.addTest(new Cmp2JndiEncTests());
         this.addTest(new Cmp2RmiIiopTests());
         this.addTest(new CmrTestSuite());
+
+        this.addTest(new Complex2HomeIntfcTests());
+        this.addTest(new Complex2EjbHomeTests());
+        this.addTest(new Complex2EjbObjectTests());
+        this.addTest(new Complex2RemoteIntfcTests());
+        this.addTest(new Complex2HomeHandleTests());
+        this.addTest(new Complex2HandleTests());
+        this.addTest(new Complex2EjbMetaDataTests());
+//
+//        this.addTest(new Unknown2HomeIntfcTests());
+//        this.addTest(new Unknown2EjbHomeTests());
+//        this.addTest(new Unknown2EjbObjectTests());
+//        this.addTest(new Unknown2RemoteIntfcTests());
+//        this.addTest(new Unknown2HomeHandleTests());
+//        this.addTest(new Unknown2HandleTests());
+//        this.addTest(new Unknown2EjbMetaDataTests());
     }
 
     public static junit.framework.Test suite() {

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbHomeTests.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,87 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp2;
+
+import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+
+import javax.ejb.EJBMetaData;
+
+/**
+ * [3] Should be run as the third test suite of the BasicCmpTestClients
+ */
+public class Complex2EjbHomeTests extends ComplexCmp2TestClient {
+
+    public Complex2EjbHomeTests() {
+        super("EJBHome.");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object obj = initialContext.lookup("client/tests/entity/cmp2/ComplexCmpHome");
+        ejbHome = (ComplexCmpHome) javax.rmi.PortableRemoteObject.narrow(obj, ComplexCmpHome.class);
+        ejbObject = ejbHome.createObject("Second Bean");
+        ejbPrimaryKey = ejbObject.getPrimaryKey();
+    }
+
+    //===============================
+    // Test ejb home methods
+    //
+    public void test01_getEJBMetaData() {
+        try {
+            EJBMetaData ejbMetaData = ejbHome.getEJBMetaData();
+            assertNotNull("The EJBMetaData is null", ejbMetaData);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test02_getHomeHandle() {
+        try {
+            ejbHomeHandle = ejbHome.getHomeHandle();
+            assertNotNull("The HomeHandle is null", ejbHomeHandle);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test03_remove() {
+        try {
+            ejbHome.remove(ejbPrimaryKey);
+            try {
+                ejbObject.businessMethod("Should throw an exception");
+                assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
+            } catch (Exception e) {
+                assertTrue(true);
+            }
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void Xtest04_ejbHomeMethod() {
+        try {
+            assertEquals(8+9, ejbHome.sum(8, 9));
+        } catch (Throwable e) {
+            e.printStackTrace();
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+    //
+    // Test ejb home methods
+    //===============================
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbMetaDataTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbMetaDataTests.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbMetaDataTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbMetaDataTests.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,102 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp2;
+
+import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+import org.apache.openejb.test.entity.cmp.ComplexCmpObject;
+import org.apache.openejb.test.entity.cmp.ComplexCmpBeanPk;
+
+import javax.ejb.EJBHome;
+
+/**
+ * [8] Should be run as the eigth test suite of the BasicCmpTestClients
+ */
+public class Complex2EjbMetaDataTests extends ComplexCmp2TestClient {
+
+    public Complex2EjbMetaDataTests() {
+        super("EJBMetaData.");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object obj = initialContext.lookup("client/tests/entity/cmp2/ComplexCmpHome");
+        ejbHome = (ComplexCmpHome) javax.rmi.PortableRemoteObject.narrow(obj, ComplexCmpHome.class);
+        ejbMetaData = ejbHome.getEJBMetaData();
+    }
+
+    //=================================
+    // Test meta data methods
+    //
+    public void test01_getEJBHome() {
+        try {
+            EJBHome home = ejbMetaData.getEJBHome();
+            assertNotNull("The EJBHome is null", home);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test02_getHomeInterfaceClass() {
+        try {
+            Class clazz = ejbMetaData.getHomeInterfaceClass();
+            assertNotNull("The Home Interface class is null", clazz);
+            assertEquals(clazz, ComplexCmpHome.class);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test03_getPrimaryKeyClass() {
+        try {
+            Class clazz = ejbMetaData.getPrimaryKeyClass();
+            assertNotNull("The EJBMetaData is null", clazz);
+            assertEquals(clazz, ComplexCmpBeanPk.class);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test04_getRemoteInterfaceClass() {
+        try {
+            Class clazz = ejbMetaData.getRemoteInterfaceClass();
+            assertNotNull("The Remote Interface class is null", clazz);
+            assertEquals(clazz, ComplexCmpObject.class);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test05_isSession() {
+        try {
+            assertTrue("EJBMetaData says this is a session bean", !ejbMetaData.isSession());
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test06_isStatelessSession() {
+        try {
+            assertTrue("EJBMetaData says this is a stateless session bean", !ejbMetaData.isStatelessSession());
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+    //
+    // Test meta data methods
+    //=================================
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2EjbObjectTests.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,112 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp2;
+
+import org.apache.openejb.test.entity.cmp.BasicCmpHome;
+import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+
+import javax.ejb.EJBHome;
+
+/**
+ * [4] Should be run as the fourth test suite of the BasicCmpTestClients
+ */
+public class Complex2EjbObjectTests extends ComplexCmp2TestClient {
+
+    public Complex2EjbObjectTests() {
+        super("EJBObject.");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object obj = initialContext.lookup("client/tests/entity/cmp2/ComplexCmpHome");
+        ejbHome = (ComplexCmpHome) javax.rmi.PortableRemoteObject.narrow(obj, ComplexCmpHome.class);
+        ejbObject = ejbHome.createObject("Third Bean");
+    }
+
+    protected void tearDown() throws Exception {
+        if (ejbObject != null) {// set to null by test05_remove() method
+            try {
+                ejbObject.remove();
+            } catch (Exception e) {
+                throw e;
+            }
+        }
+        super.tearDown();
+    }
+
+    //===============================
+    // Test ejb object methods
+    //
+    public void test01_getHandle() {
+        try {
+            ejbHandle = ejbObject.getHandle();
+            assertNotNull("The Handle is null", ejbHandle);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test02_getPrimaryKey() {
+        try {
+            ejbPrimaryKey = ejbObject.getPrimaryKey();
+            assertNotNull("The primary key is null", ejbPrimaryKey);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test03_isIdentical() {
+        try {
+            assertTrue("The EJBObjects are not equal", ejbObject.isIdentical(ejbObject));
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test04_getEjbHome() {
+        try {
+            EJBHome home = ejbObject.getEJBHome();
+            assertNotNull("The EJBHome is null", home);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test05_remove() {
+        try {
+            ejbObject.remove();
+            try {
+                ejbObject.businessMethod("Should throw an exception");
+                assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
+            } catch (Exception e) {
+                assertTrue(true);
+                return;
+            }
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        } finally {
+            ejbObject = null;
+        }
+    }
+    //
+    // Test ejb object methods
+    //===============================
+
+
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HandleTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HandleTests.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HandleTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HandleTests.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,124 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp2;
+
+import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+import java.rmi.MarshalledObject;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+/**
+ * [7] Should be run as the seventh test suite of the BasicCmpTestClients
+ */
+public class Complex2HandleTests extends ComplexCmp2TestClient {
+    public Complex2HandleTests() {
+        super("Handle.");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object obj = initialContext.lookup("client/tests/entity/cmp2/ComplexCmpHome");
+        ejbHome = (ComplexCmpHome) javax.rmi.PortableRemoteObject.narrow(obj, ComplexCmpHome.class);
+        ejbObject = ejbHome.createObject("Fifth Bean");
+        ejbHandle = ejbObject.getHandle();
+    }
+
+    protected void tearDown() throws Exception {
+        if (ejbObject != null) {
+            ejbObject.remove();
+        }
+        super.tearDown();
+    }
+
+    //=================================
+    // Test handle methods
+    //
+    public void test01_getEJBObject() {
+
+        try {
+            EJBObject object = ejbHandle.getEJBObject();
+            assertNotNull("The EJBObject is null", object);
+            // Wait until isIdentical is working.
+            //assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void Xtest02_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 Xtest03_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 test04_EJBHome_remove() {
+        try {
+            ejbHome.remove(ejbHandle);
+            try {
+                ejbObject.businessMethod("Should throw an exception");
+                assertTrue("Calling business method after removing the EJBObject does not throw an exception", false);
+            } catch (Exception e) {
+                assertTrue(true);
+            }
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        } finally {
+            ejbObject = null;
+        }
+    }
+
+    //
+    // Test handle methods
+    //=================================
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeHandleTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeHandleTests.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeHandleTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeHandleTests.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,93 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp2;
+
+import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+
+import javax.ejb.EJBHome;
+import javax.ejb.HomeHandle;
+import java.rmi.MarshalledObject;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+/**
+ * [6] Should be run as the sixth test suite of the BasicCmpTestClients
+ */
+public class Complex2HomeHandleTests extends ComplexCmp2TestClient {
+
+    public Complex2HomeHandleTests() {
+        super("HomeHandle.");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object obj = initialContext.lookup("client/tests/entity/cmp2/ComplexCmpHome");
+        ejbHome = (ComplexCmpHome) javax.rmi.PortableRemoteObject.narrow(obj, ComplexCmpHome.class);
+        ejbHomeHandle = ejbHome.getHomeHandle();
+    }
+
+    //=================================
+    // Test home handle methods
+    //
+    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 Xtest02_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 Xtest03_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());
+        }
+    }
+    //
+    // Test home handle methods
+    //=================================
+
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeIntfcTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeIntfcTests.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeIntfcTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2HomeIntfcTests.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,116 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp2;
+
+
+import org.apache.openejb.test.entity.cmp.ComplexCmpBeanPk;
+import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+import org.apache.openejb.test.entity.cmp.ComplexCmpObject;
+
+import javax.rmi.PortableRemoteObject;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * [2] Should be run as the second test suite of the BasicCmpTestClients
+ */
+public class Complex2HomeIntfcTests extends ComplexCmp2TestClient {
+    public Complex2HomeIntfcTests() {
+        super("HomeIntfc.");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object obj = initialContext.lookup("client/tests/entity/cmp2/ComplexCmpHome");
+        ejbHome = (ComplexCmpHome) javax.rmi.PortableRemoteObject.narrow(obj, ComplexCmpHome.class);
+    }
+
+    //===============================
+    // Test home interface methods
+    //
+    public void test01_create() throws Exception {
+        ejbObject = ejbHome.createObject("First Bean");
+        assertNotNull("The EJBObject is null", ejbObject);
+    }
+
+    public void test02_findByPrimaryKey() throws Exception {
+        ejbPrimaryKey = ejbObject.getPrimaryKey();
+        assertTrue("Expected (ejbPrimaryKey instanceof ComplexCmpBeanPk) but was instanceof " + ejbPrimaryKey.getClass().getName(), ejbPrimaryKey instanceof ComplexCmpBeanPk);
+        ejbObject = ejbHome.findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
+        assertNotNull("The EJBObject is null", ejbObject);
+    }
+
+    public void test03_findByLastName() throws Exception {
+        Set<ComplexCmpBeanPk> keys = new HashSet<ComplexCmpBeanPk>();
+        try {
+            ejbObject = ejbHome.createObject("David Blevins");
+            ejbPrimaryKey = ejbObject.getPrimaryKey();
+            assertTrue("Expected (ejbPrimaryKey instanceof ComplexCmpBeanPk) but was instanceof " + ejbPrimaryKey.getClass().getName(), ejbPrimaryKey instanceof ComplexCmpBeanPk);
+            keys.add((ComplexCmpBeanPk) ejbObject.getPrimaryKey());
+
+            ejbObject = ejbHome.createObject("Dennis Blevins");
+            ejbPrimaryKey = ejbObject.getPrimaryKey();
+            assertTrue("Expected (ejbPrimaryKey instanceof ComplexCmpBeanPk) but was instanceof " + ejbPrimaryKey.getClass().getName(), ejbPrimaryKey instanceof ComplexCmpBeanPk);
+            keys.add((ComplexCmpBeanPk) ejbObject.getPrimaryKey());
+
+            ejbObject = ejbHome.createObject("Claude Blevins");
+            ejbPrimaryKey = ejbObject.getPrimaryKey();
+            assertTrue("Expected (ejbPrimaryKey instanceof ComplexCmpBeanPk) but was instanceof " + ejbPrimaryKey.getClass().getName(), ejbPrimaryKey instanceof ComplexCmpBeanPk);
+            keys.add((ComplexCmpBeanPk) ejbObject.getPrimaryKey());
+        } catch (Exception e) {
+            fail("Received exception while preparing the test: " + e.getClass() + " : " + e.getMessage());
+        }
+
+        try {
+            Collection objects = ejbHome.findByLastName("Blevins");
+            Set<ComplexCmpBeanPk> foundKeys = new HashSet<ComplexCmpBeanPk>();
+            assertNotNull("The Collection is null", objects);
+            assertEquals("The Collection is not the right size.", keys.size(), objects.size());
+            for (Object object : objects) {
+                ejbObject = (ComplexCmpObject) PortableRemoteObject.narrow(object, ComplexCmpObject.class);
+
+                // This could be problematic, it assumes the order of the collection.
+                ComplexCmpBeanPk foundKey = (ComplexCmpBeanPk) ejbObject.getPrimaryKey();
+                assertTrue("Extra ejb found " + ejbObject.getPrimaryKey(), keys.contains(foundKey));
+                foundKeys.add(foundKey);
+            }
+
+            keys.removeAll(foundKeys);
+            assertEquals("Some keys were not found", Collections.EMPTY_SET, keys);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test04_homeMethod() {
+        try {
+            int expected = 8;
+            int actual = ejbHome.sum(5, 3);
+            assertEquals("home method returned wrong result", expected, actual);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+    //
+    // Test home interface methods
+    //===============================
+
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2RemoteIntfcTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2RemoteIntfcTests.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2RemoteIntfcTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/Complex2RemoteIntfcTests.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,119 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp2;
+
+import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+
+/**
+ * [5] Should be run as the fifth test suite of the BasicCmpTestClients
+ */
+public class Complex2RemoteIntfcTests extends ComplexCmp2TestClient {
+
+    public Complex2RemoteIntfcTests() {
+        super("RemoteIntfc.");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object obj = initialContext.lookup("client/tests/entity/cmp2/ComplexCmpHome");
+        ejbHome = (ComplexCmpHome) javax.rmi.PortableRemoteObject.narrow(obj, ComplexCmpHome.class);
+        ejbObject = ejbHome.createObject("Forth Bean");
+    }
+
+    //=================================
+    // Test remote interface methods
+    //
+    public void test01_businessMethod() {
+        try {
+            String expected = "Success";
+            String actual = ejbObject.businessMethod("sseccuS");
+            assertEquals(expected, actual);
+        } catch (Exception e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    /**
+     * Throw an application exception and make sure the exception
+     * reaches the bean nicely.
+     */
+    public void test02_throwApplicationException() {
+        try {
+            ejbObject.throwApplicationException();
+        } catch (org.apache.openejb.test.ApplicationException e) {
+            //Good.  This is the correct behaviour
+            return;
+        } catch (Throwable e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+        fail("An ApplicationException should have been thrown.");
+    }
+
+    /**
+     * After an application exception we should still be able to
+     * use our bean
+     */
+    public void test03_invokeAfterApplicationException() {
+        try {
+            String expected = "Success";
+            String actual = ejbObject.businessMethod("sseccuS");
+            assertEquals(expected, actual);
+        } catch (Throwable e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+
+    public void test04_throwSystemException() {
+        try {
+            ejbObject.throwSystemException_NullPointer();
+        } catch (java.rmi.RemoteException e) {
+            //Good, so far.
+            Throwable n = e.detail;
+            assertNotNull("Nested exception should not be is null", n);
+            assertTrue("Nested exception should be an instance of NullPointerException, but exception is " + n.getClass().getName(), (n instanceof NullPointerException));
+            return;
+        } catch (Throwable e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+        fail("A NullPointerException should have been thrown.");
+    }
+
+    /**
+     * After a system exception the intance should be garbage collected
+     * and the remote reference should be invalidated.
+     * <p/>
+     * The Remote Server fails this one, that should be fixed.
+     */
+    public void BUG_test05_invokeAfterSystemException() {
+        try {
+            ejbObject.businessMethod("This refernce is invalid");
+            fail("A java.rmi.NoSuchObjectException should have been thrown.");
+        } catch (java.rmi.NoSuchObjectException e) {
+            // Good.
+        } catch (Throwable e) {
+            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+        }
+    }
+    //
+    // Test remote interface methods
+    //=================================
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/ComplexCmp2TestClient.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/ComplexCmp2TestClient.java?view=auto&rev=520702
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/ComplexCmp2TestClient.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp2/ComplexCmp2TestClient.java Tue Mar 20 19:03:17 2007
@@ -0,0 +1,30 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.entity.cmp2;
+
+import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
+import org.apache.openejb.test.entity.cmp.ComplexCmpObject;
+
+public abstract class ComplexCmp2TestClient extends Cmp2TestClient {
+    protected ComplexCmpHome ejbHome;
+    protected ComplexCmpObject ejbObject;
+
+    public ComplexCmp2TestClient(String name) {
+        super(name);
+    }
+}