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/15 23:35:47 UTC
svn commit: r518791 - 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/config/
container/openejb-core/src/main/java/org/apache/opene...
Author: dain
Date: Thu Mar 15 15:35:42 2007
New Revision: 518791
URL: http://svn.apache.org/viewvc?view=rev&rev=518791
Log:
Added support for CMP 1.x Unknown Pk
Added:
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpHome.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpObject.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpTestClient.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbMetaDataTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHandleTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeHandleTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeIntfcTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownRemoteIntfcTests.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/config/CmpJpaConversion.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/jpa/JpaCmpEngine.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml
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/cmp/CmpLocalTestSuite.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=518791&r1=518790&r2=518791
==============================================================================
--- 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 Thu Mar 15 15:35:42 2007
@@ -103,6 +103,9 @@
byte[] bytes = null;
if (entityBeanInfo.cmpVersion != 2) {
Cmp1Generator cmp1Generator = new Cmp1Generator(cmpImplClass, beanClass);
+ if ("java.lang.Object".equals(entityBeanInfo.primKeyClass)) {
+ cmp1Generator.setUnknownPk(true);
+ }
bytes = cmp1Generator.generate();
} else {
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java?view=diff&rev=518791&r1=518790&r2=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java Thu Mar 15 15:35:42 2007
@@ -51,6 +51,8 @@
import org.apache.openejb.jee.jpa.Field;
import org.apache.openejb.jee.jpa.NamedQuery;
import org.apache.openejb.jee.jpa.IdClass;
+import org.apache.openejb.jee.jpa.GeneratedValue;
+import org.apache.openejb.jee.jpa.GenerationType;
import org.apache.openejb.jee.jpa.unit.Persistence;
import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
import org.apache.openejb.jee.jpa.unit.TransactionType;
@@ -442,15 +444,25 @@
//
Set<String> primaryKeyFields = new HashSet<String>();
if (bean.getPrimkeyField() != null) {
+ String fieldName = bean.getPrimkeyField();
Field field;
if (!createOverrides) {
- field = new Id(bean.getPrimkeyField());
+ field = new Id(fieldName);
} else {
- field = new AttributeOverride(bean.getPrimkeyField());
+ field = new AttributeOverride(fieldName);
}
mapping.addField(field);
- persistantFields.add(bean.getPrimkeyField());
- primaryKeyFields.add(bean.getPrimkeyField());
+ persistantFields.add(fieldName);
+ primaryKeyFields.add(fieldName);
+ } else if ("java.lang.Object".equals(bean.getPrimKeyClass())) {
+ if (createOverrides) {
+ String fieldName = "OpenEJB_pk";
+ Id field = new Id(fieldName);
+ field.setGeneratedValue(new GeneratedValue(GenerationType.AUTO));
+ mapping.addField(field);
+ persistantFields.add(fieldName);
+ primaryKeyFields.add(fieldName);
+ }
} else if (bean.getPrimKeyClass() != null) {
Class<?> pkClass = null;
try {
@@ -476,8 +488,6 @@
} catch (ClassNotFoundException e) {
// todo throw exception
}
-
- // todo complex primary key
}
//
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=518791&r1=518790&r2=518791
==============================================================================
--- 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 Thu Mar 15 15:35:42 2007
@@ -25,6 +25,7 @@
private String implClassName;
private String beanClassName;
private ClassWriter cw;
+ private boolean unknownPk;
public Cmp1Generator(String cmpImplClass, Class beanClass) {
beanClassName = Type.getInternalName(beanClass);
@@ -36,6 +37,10 @@
public byte[] generate() {
cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, implClassName, null, beanClassName, new String[0]);
+ if (unknownPk) {
+ cw.visitField(ACC_PUBLIC + ACC_TRANSIENT, "OpenEJB_pk", "Ljava/lang/Long;", null, null);
+ }
+
createConstructor();
cw.visitEnd();
@@ -52,5 +57,13 @@
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
+ }
+
+ public boolean isUnknownPk() {
+ return unknownPk;
+ }
+
+ public void setUnknownPk(boolean unknownPk) {
+ this.unknownPk = unknownPk;
}
}
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java?view=diff&rev=518791&r1=518790&r2=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java Thu Mar 15 15:35:42 2007
@@ -242,6 +242,8 @@
Class cmpBeanImpl = di.getCmpImplClass();
if (primaryKeyField != null) {
di.setKeyGenerator(new SimpleKeyGenerator(cmpBeanImpl, primaryKeyField));
+ } else if (Object.class.equals(di.getPrimaryKeyClass())) {
+ di.setKeyGenerator(new SimpleKeyGenerator(cmpBeanImpl, "OpenEJB_pk"));
} else {
di.setKeyGenerator(new ComplexKeyGenerator(cmpBeanImpl, di.getPrimaryKeyClass()));
}
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml?view=diff&rev=518791&r1=518790&r2=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml Thu Mar 15 15:35:42 2007
@@ -78,7 +78,7 @@
</attribute-override>
<attributes>
<id name="OpenEJB_pk">
- <generated-value strategy="IDENTITY"/>
+ <generated-value strategy="AUTO"/>
</id>
</attributes>
</entity>
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml?view=diff&rev=518791&r1=518790&r2=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml Thu Mar 15 15:35:42 2007
@@ -274,7 +274,6 @@
<entity name="Address" class="openejb.org.apache.openejb.test.entity.cmp2.petstore.Address">
<description>AddressEJB</description>
<table name="address"/>
- <id-class class="java.lang.Object"/>
<attributes>
<basic name="street">
<column name="street"/>
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpHome.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpHome.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpHome.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpHome.java Thu Mar 15 15:35:42 2007
@@ -0,0 +1,40 @@
+/**
+ *
+ * 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 javax.ejb.EJBHome;
+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 UnknownCmpHome extends EJBHome {
+ UnknownCmpObject createObject(String name) throws CreateException, RemoteException;
+
+ UnknownCmpObject findByPrimaryKey(Object primarykey) throws FinderException, RemoteException;
+
+ Collection findEmptyCollection() throws FinderException, RemoteException;
+
+ Collection findByLastName(String lastName) throws FinderException, RemoteException;
+
+ public int sum(int x, int y) throws RemoteException;
+}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpObject.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpObject.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpObject.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpObject.java Thu Mar 15 15:35:42 2007
@@ -0,0 +1,63 @@
+/**
+ *
+ * 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.EJBObject;
+import java.rmi.RemoteException;
+import java.util.Properties;
+
+/**
+ * @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 UnknownCmpObject extends EJBObject {
+ /**
+ * Reverses the string passed in then returns it
+ */
+ String businessMethod(String text) throws RemoteException;
+
+ /**
+ * Throws an ApplicationException when invoked
+ */
+ 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.
+ */
+ void throwSystemException_NullPointer() throws RemoteException;
+
+ /**
+ * Returns a report of the bean's
+ * runtime permissions
+ */
+ Properties getPermissionsReport() throws RemoteException;
+
+ /**
+ * 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
+ */
+ OperationsPolicy getAllowedOperationsReport(String methodName) throws RemoteException;
+}
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=518791&r1=518790&r2=518791
==============================================================================
--- 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 Thu Mar 15 15:35:42 2007
@@ -105,6 +105,30 @@
</resource-ref>
</entity>
+ <entity>
+ <ejb-name>UnknownCmpBean</ejb-name>
+ <home>org.apache.openejb.test.entity.cmp.UnknownCmpHome</home>
+ <remote>org.apache.openejb.test.entity.cmp.UnknownCmpObject</remote>
+ <ejb-class>org.apache.openejb.test.entity.cmp.UnknownCmpBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <cmp-version>1.x</cmp-version>
+ <abstract-schema-name>UnknownCmpBeanX</abstract-schema-name>
+ <prim-key-class>java.lang.Object</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/cmp2/BasicCmpHome
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=518791&r1=518790&r2=518791
==============================================================================
--- 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 Thu Mar 15 15:35:42 2007
@@ -55,6 +55,25 @@
<object-ql>SELECT o FROM ComplexCmpBean o WHERE 'true' = 'false'</object-ql>
</query>
</ejb-deployment>
+ <ejb-deployment ejb-name="UnknownCmpBean" deployment-id="client/tests/entity/cmp/UnknownCmpHome" 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 UnknownCmpBeanX 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 UnknownCmpBean o WHERE 'true' = 'false'</object-ql>
+ </query>
+ </ejb-deployment>
<ejb-deployment ejb-name="BasicCmp2Bean" deployment-id="client/tests/entity/cmp2/BasicCmpHome" 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=518791&r1=518790&r2=518791
==============================================================================
--- 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 Thu Mar 15 15:35:42 2007
@@ -63,6 +63,8 @@
"BasicCmpBeanX",
"ComplexCmpBean",
"ComplexCmpBeanX",
+ "UnknownCmpBean",
+ "UnknownCmpBeanX",
"BasicCmp2Bean",
"AllowedOperationsCmpBean",
"AllowedOperationsCmp2Bean",
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpLocalTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpLocalTestSuite.java?view=diff&rev=518791&r1=518790&r2=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpLocalTestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpLocalTestSuite.java Thu Mar 15 15:35:42 2007
@@ -51,6 +51,14 @@
this.addTest(new ComplexHomeHandleTests());
this.addTest(new ComplexHandleTests());
this.addTest(new ComplexEjbMetaDataTests());
+
+ this.addTest(new UnknownHomeIntfcTests());
+ this.addTest(new UnknownEjbHomeTests());
+ this.addTest(new UnknownEjbObjectTests());
+ this.addTest(new UnknownRemoteIntfcTests());
+ this.addTest(new UnknownHomeHandleTests());
+ this.addTest(new UnknownHandleTests());
+ this.addTest(new UnknownEjbMetaDataTests());
}
public static junit.framework.Test suite() {
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpTestClient.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpTestClient.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpTestClient.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownCmpTestClient.java Thu Mar 15 15:35:42 2007
@@ -0,0 +1,31 @@
+/**
+ *
+ * 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;
+
+/**
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public abstract class UnknownCmpTestClient extends CmpTestClient {
+ protected UnknownCmpHome ejbHome;
+ protected UnknownCmpObject ejbObject;
+
+ public UnknownCmpTestClient(String name) {
+ super(name);
+ }
+}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbHomeTests.java Thu Mar 15 15:35:42 2007
@@ -0,0 +1,80 @@
+/**
+ *
+ * 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 javax.rmi.PortableRemoteObject;
+import javax.ejb.EJBMetaData;
+
+/**
+ * [3] Should be run as the third test suite of the UnknownCmpTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class UnknownEjbHomeTests extends UnknownCmpTestClient {
+
+ public UnknownEjbHomeTests() {
+ super("EJBHome.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/UnknownCmpHome");
+ ejbHome = (UnknownCmpHome) PortableRemoteObject.narrow(obj, UnknownCmpHome.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());
+ }
+ }
+ //
+ // Test ejb home methods
+ //===============================
+}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbMetaDataTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbMetaDataTests.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbMetaDataTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbMetaDataTests.java Thu Mar 15 15:35:42 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.cmp;
+
+import javax.rmi.PortableRemoteObject;
+import javax.ejb.EJBHome;
+
+/**
+ * [8] Should be run as the eigth test suite of the UnknownCmpTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class UnknownEjbMetaDataTests extends UnknownCmpTestClient {
+
+ public UnknownEjbMetaDataTests() {
+ super("EJBMetaData.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/UnknownCmpHome");
+ ejbHome = (UnknownCmpHome) PortableRemoteObject.narrow(obj, UnknownCmpHome.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, UnknownCmpHome.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, Object.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, UnknownCmpObject.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/cmp/UnknownEjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownEjbObjectTests.java Thu Mar 15 15:35:42 2007
@@ -0,0 +1,113 @@
+/**
+ *
+ * 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 javax.rmi.PortableRemoteObject;
+import javax.ejb.EJBHome;
+
+/**
+ * [4] Should be run as the fourth test suite of the UnknownCmpTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class UnknownEjbObjectTests extends UnknownCmpTestClient {
+
+ public UnknownEjbObjectTests() {
+ super("EJBObject.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/UnknownCmpHome");
+ ejbHome = (UnknownCmpHome) PortableRemoteObject.narrow(obj, UnknownCmpHome.class);
+ ejbObject = ejbHome.createObject("Third Bean");
+ }
+
+ protected void tearDown() throws Exception {
+ // set to null by test05_remove() method
+ if (ejbObject != null) {
+ 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);
+ }
+ } 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/cmp/UnknownHandleTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHandleTests.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHandleTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHandleTests.java Thu Mar 15 15:35:42 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.cmp;
+
+import javax.rmi.PortableRemoteObject;
+import javax.ejb.EJBObject;
+
+/**
+ * [7] Should be run as the seventh test suite of the UnknownCmpTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class UnknownHandleTests extends UnknownCmpTestClient {
+
+ public UnknownHandleTests() {
+ super("Handle.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/UnknownCmpHome");
+ ejbHome = (UnknownCmpHome) PortableRemoteObject.narrow(obj, UnknownCmpHome.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());
+ }
+ }
+
+ /**
+ * 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() {
+ 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/cmp/UnknownHomeHandleTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeHandleTests.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeHandleTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeHandleTests.java Thu Mar 15 15:35:42 2007
@@ -0,0 +1,57 @@
+/**
+ *
+ * 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 javax.rmi.PortableRemoteObject;
+import javax.ejb.EJBHome;
+
+/**
+ * [6] Should be run as the sixth test suite of the UnknownCmpTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class UnknownHomeHandleTests extends UnknownCmpTestClient {
+
+ public UnknownHomeHandleTests() {
+ super("HomeHandle.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/UnknownCmpHome");
+ ejbHome = (UnknownCmpHome) PortableRemoteObject.narrow(obj, UnknownCmpHome.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());
+ }
+ }
+ //
+ // Test home handle methods
+ //=================================
+
+}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeIntfcTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeIntfcTests.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeIntfcTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownHomeIntfcTests.java Thu Mar 15 15:35:42 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.cmp;
+
+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 UnknownCmpTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class UnknownHomeIntfcTests extends UnknownCmpTestClient {
+
+ public UnknownHomeIntfcTests() {
+ super("UnknownPk.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/UnknownCmpHome");
+ ejbHome = (UnknownCmpHome) PortableRemoteObject.narrow(obj, UnknownCmpHome.class);
+ }
+
+ //===============================
+ // Test home interface methods
+ //
+ public void test01_create() {
+ try {
+ ejbObject = ejbHome.createObject("First Bean");
+ assertNotNull("The EJBObject is null", ejbObject);
+ } catch (Exception e) {
+ fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+ }
+ }
+
+ public void test02_findByPrimaryKey() {
+ try {
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ assertNotNull("ejbPrimaryKey is null", ejbPrimaryKey);
+ ejbObject = ejbHome.findByPrimaryKey(ejbPrimaryKey);
+ assertNotNull("The EJBObject is null", ejbObject);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Received Exception " + e.getClass() + " : " + e.getMessage());
+ }
+ }
+
+ public void test03_findByLastName() {
+ Set<Object> keys = new HashSet<Object>();
+ try {
+ ejbObject = ejbHome.createObject("David Blevins");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ assertNotNull("ejbPrimaryKey is null", ejbPrimaryKey);
+ keys.add(ejbPrimaryKey);
+
+ ejbObject = ejbHome.createObject("Dennis Blevins");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ assertNotNull("ejbPrimaryKey is null", ejbPrimaryKey);
+ keys.add(ejbPrimaryKey);
+
+ ejbObject = ejbHome.createObject("Claude Blevins");
+ ejbPrimaryKey = ejbObject.getPrimaryKey();
+ assertNotNull("ejbPrimaryKey is null", ejbPrimaryKey);
+ keys.add(ejbPrimaryKey);
+ } catch (Exception e) {
+ fail("Received exception while preparing the test: " + e.getClass() + " : " + e.getMessage());
+ }
+
+ try {
+ Collection objects = ejbHome.findByLastName("Blevins");
+ Set<Object> foundKeys = new HashSet<Object>();
+ assertNotNull("The Collection is null", objects);
+ assertEquals("The Collection is not the right size.", keys.size(), objects.size());
+ for (Object object : objects) {
+ ejbObject = (UnknownCmpObject) PortableRemoteObject.narrow(object, UnknownCmpObject.class);
+
+ // This could be problematic, it assumes the order of the collection.
+ Object foundKey = 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/cmp/UnknownRemoteIntfcTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownRemoteIntfcTests.java?view=auto&rev=518791
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownRemoteIntfcTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/UnknownRemoteIntfcTests.java Thu Mar 15 15:35:42 2007
@@ -0,0 +1,122 @@
+/**
+ *
+ * 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 javax.rmi.PortableRemoteObject;
+
+/**
+ * [5] Should be run as the fifth test suite of the UnknownCmpTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class UnknownRemoteIntfcTests extends UnknownCmpTestClient {
+
+ public UnknownRemoteIntfcTests() {
+ super("RemoteIntfc.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/UnknownCmpHome");
+ ejbHome = (UnknownCmpHome) PortableRemoteObject.narrow(obj, UnknownCmpHome.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();
+ }
+}