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 20:16:55 UTC
svn commit: r518731 [1/2] - in /incubator/openejb/trunk/openejb3:
container/openejb-core/src/main/java/org/apache/openejb/config/
container/openejb-core/src/main/java/org/apache/openejb/core/cmp/
container/openejb-core/src/test/java/org/apache/openejb/...
Author: dain
Date: Thu Mar 15 12:16:53 2007
New Revision: 518731
URL: http://svn.apache.org/viewvc?view=rev&rev=518731
Log:
Complex primary key support for CMP 1.x beans
Added:
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/Bill.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BillPk.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/ComplexCmpBean_Subclass.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBill.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBillPk.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBean.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBeanPk.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpHome.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpObject.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpTestClient.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbMetaDataTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHandleTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHomeHandleTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHomeIntfcTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexRemoteIntfcTests.java
Modified:
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/ComplexKeyGenerator.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTest.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTestObject.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/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/IdClass.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/cmp/CmpLocalTestSuite.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpTestSuite.java
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=518731&r1=518730&r2=518731
==============================================================================
--- 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 12:16:53 2007
@@ -50,6 +50,7 @@
import org.apache.openejb.jee.jpa.AttributeOverride;
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.unit.Persistence;
import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
import org.apache.openejb.jee.jpa.unit.TransactionType;
@@ -60,6 +61,8 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import java.util.HashSet;
+import java.lang.reflect.Modifier;
public class CmpJpaConversion implements DynamicDeployer {
private static final String CMP_PERSISTENCE_UNIT_NAME = "cmp";
@@ -424,6 +427,11 @@
// class: the java class for the entity
mapping.setClazz(className);
+ Set<String> allFields = new TreeSet<String>();
+ for (CmpField cmpField : bean.getCmpField()) {
+ allFields.add(cmpField.getFieldName());
+ }
+
//
// Map fields remembering the names of the mapped fields
//
@@ -432,6 +440,7 @@
//
// id: the primary key
//
+ Set<String> primaryKeyFields = new HashSet<String>();
if (bean.getPrimkeyField() != null) {
Field field;
if (!createOverrides) {
@@ -441,16 +450,41 @@
}
mapping.addField(field);
persistantFields.add(bean.getPrimkeyField());
- } else {
+ primaryKeyFields.add(bean.getPrimkeyField());
+ } else if (bean.getPrimKeyClass() != null) {
+ Class<?> pkClass = null;
+ try {
+ pkClass = classLoader.loadClass(bean.getPrimKeyClass());
+ if (!createOverrides) {
+ mapping.setIdClass(new IdClass(bean.getPrimKeyClass()));
+ }
+ for (java.lang.reflect.Field pkField : pkClass.getFields()) {
+ String pkFieldName = pkField.getName();
+ int modifiers = pkField.getModifiers();
+ if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers) && allFields.contains(pkFieldName)) {
+ Field field;
+ if (!createOverrides) {
+ field = new Id(pkFieldName);
+ } else {
+ field = new AttributeOverride(pkFieldName);
+ }
+ mapping.addField(field);
+ persistantFields.add(pkFieldName);
+ primaryKeyFields.add(pkFieldName);
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ // todo throw exception
+ }
+
// todo complex primary key
- // todo unknown primary key
}
//
// basic: cmp-fields
//
for (CmpField cmpField : bean.getCmpField()) {
- if (!cmpField.getFieldName().equals(bean.getPrimkeyField())) {
+ if (!primaryKeyFields.contains(cmpField.getFieldName())) {
Field field;
if (!createOverrides) {
field = new Basic(cmpField.getFieldName());
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/ComplexKeyGenerator.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/ComplexKeyGenerator.java?view=diff&rev=518731&r1=518730&r2=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/ComplexKeyGenerator.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/ComplexKeyGenerator.java Thu Mar 15 12:16:53 2007
@@ -34,12 +34,12 @@
this.pkClass = pkClass;
List<org.apache.openejb.core.cmp.ComplexKeyGenerator.PkField> fields = new ArrayList<PkField>();
for (Field pkObjectField : pkClass.getFields()) {
- if (!isValidPkField(pkObjectField)) {
+ if (isValidPkField(pkObjectField)) {
Field entityBeanField = getField(entityBeanClass, pkObjectField.getName());
if (!isValidPkField(entityBeanField)) {
- throw new OpenEJBException("Invalid primray key field on entity bean class: " + entityBeanClass.getName());
+ throw new OpenEJBException("Invalid primray key field: " + entityBeanField);
}
- org.apache.openejb.core.cmp.ComplexKeyGenerator.PkField pkField = new org.apache.openejb.core.cmp.ComplexKeyGenerator.PkField(entityBeanField, pkObjectField);
+ PkField pkField = new PkField(entityBeanField, pkObjectField);
fields.add(pkField);
}
}
@@ -53,7 +53,8 @@
} catch (Exception e) {
throw new EJBException("Unable to create complex primary key instance: " + pkClass.getName(), e);
}
- for (org.apache.openejb.core.cmp.ComplexKeyGenerator.PkField pkField : fields) {
+
+ for (PkField pkField : fields) {
pkField.copyToPkObject(bean, pkObject);
}
return pkObject;
@@ -64,13 +65,16 @@
private final Field pkObjectField;
public PkField(Field entityBeanField, Field pkObjectField) {
+ entityBeanField.setAccessible(true);
+ pkObjectField.setAccessible(true);
+
this.entityBeanField = entityBeanField;
this.pkObjectField = pkObjectField;
}
public void copyToPkObject(EntityBean bean, Object pkObject) {
Object value = getFieldValue(entityBeanField, bean);
- setFieldValue(pkObjectField, bean, value);
+ setFieldValue(pkObjectField, pkObject, value);
}
public Object getPkFieldValue(Object pkObject) {
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/Bill.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/Bill.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/Bill.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/Bill.java Thu Mar 15 12:16:53 2007
@@ -0,0 +1,70 @@
+/**
+ *
+ * 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.core.cmp.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="bill")
+@IdClass(BillPk.class)
+public class Bill implements java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private long billNumber;
+ private long billVersion;
+ private long billRevision;
+ private String billDescription;
+
+ @Id
+ public long getBillNumber() {
+ return billNumber;
+ }
+
+ public void setBillNumber(long number) {
+ billNumber = number;
+ }
+
+ @Id
+ public long getBillVersion() {
+ return billVersion;
+ }
+
+ public void setBillVersion(long version) {
+ billVersion = version;
+ }
+
+ @Id
+ public long getBillRevision() {
+ return billRevision;
+ }
+
+ public void setBillRevision(long revision) {
+ billRevision = revision;
+ }
+
+ public String getBillDescription() {
+ return billDescription;
+ }
+
+ public void setBillDescription(String description) {
+ billDescription = description;
+ }
+}
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BillPk.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BillPk.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BillPk.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BillPk.java Thu Mar 15 12:16:53 2007
@@ -0,0 +1,83 @@
+/**
+ *
+ * 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.core.cmp.jpa;
+
+public class BillPk {
+ private long billNumber;
+ private long billVersion;
+ private long billRevision;
+
+ public BillPk() {
+
+ }
+
+ public BillPk(long number, long version, long revision) {
+ this.billNumber = number;
+ this.billVersion = version;
+ this.billRevision = revision;
+ }
+
+ public long getBillNumber() {
+ return this.billNumber;
+ }
+
+ public void setBillNumber(long number) {
+ this.billNumber = number;
+ }
+
+ public long getBillVersion() {
+ return this.billVersion;
+ }
+
+ public void setBillVersion(long version) {
+ this.billVersion = version;
+ }
+
+ public long getBillRevision() {
+ return this.billRevision;
+ }
+
+ public void setBillRevision(long revision) {
+ this.billRevision = revision;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this)
+ return true;
+
+ if (!(obj instanceof BillPk))
+ return false;
+
+ BillPk pk = (BillPk)obj;
+
+ if (billNumber != pk.billNumber)
+ return false;
+
+ if (billVersion != pk.billVersion)
+ return false;
+
+ if (billRevision != pk.billRevision)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ return (billNumber + "." + billVersion + "." + billRevision).hashCode();
+ }
+}
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/ComplexCmpBean_Subclass.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/ComplexCmpBean_Subclass.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/ComplexCmpBean_Subclass.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/ComplexCmpBean_Subclass.java Thu Mar 15 12:16:53 2007
@@ -0,0 +1,24 @@
+/**
+ *
+ * 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.core.cmp.jpa;
+
+import org.apache.openejb.test.entity.cmp.ComplexCmpBean;
+
+public class ComplexCmpBean_Subclass extends ComplexCmpBean {
+
+}
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBill.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBill.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBill.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBill.java Thu Mar 15 12:16:53 2007
@@ -0,0 +1,46 @@
+/**
+ *
+ * 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.core.cmp.jpa;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+
+@Entity
+public class EmbeddedBill {
+ private static final long serialVersionUID = 1L;
+
+ private EmbeddedBillPk pk;
+ private String billDescription;
+
+ @EmbeddedId
+ public EmbeddedBillPk getPk() {
+ return pk;
+ }
+
+ public void setPk(EmbeddedBillPk key) {
+ pk = key;
+ }
+
+ public String getBillDescription() {
+ return billDescription;
+ }
+
+ public void setBillDescription(String description) {
+ billDescription = description;
+ }
+}
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBillPk.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBillPk.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBillPk.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/EmbeddedBillPk.java Thu Mar 15 12:16:53 2007
@@ -0,0 +1,90 @@
+/**
+ *
+ * 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.core.cmp.jpa;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class EmbeddedBillPk {
+ private long billNumber;
+ private long billVersion;
+ private long billRevision;
+
+ public EmbeddedBillPk() {
+
+ }
+
+ public EmbeddedBillPk(long number, long version, long revision) {
+ this.billNumber = number;
+ this.billVersion = version;
+ this.billRevision = revision;
+ }
+
+ @Column(name="billNumber")
+ public long getBillNumber() {
+ return this.billNumber;
+ }
+
+ public void setBillNumber(long number) {
+ this.billNumber = number;
+ }
+
+ @Column(name="billVersion")
+ public long getBillVersion() {
+ return this.billVersion;
+ }
+
+ public void setBillVersion(long version) {
+ this.billVersion = version;
+ }
+
+ @Column(name="billRevision")
+ public long getBillRevision() {
+ return this.billRevision;
+ }
+
+ public void setBillRevision(long revision) {
+ this.billRevision = revision;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this)
+ return true;
+
+ if (!(obj instanceof EmbeddedBillPk))
+ return false;
+
+ EmbeddedBillPk pk = (EmbeddedBillPk)obj;
+
+ if (billNumber != pk.billNumber)
+ return false;
+
+ if (billVersion != pk.billVersion)
+ return false;
+
+ if (billRevision != pk.billRevision)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ return (billNumber + "." + billVersion + "." + billRevision).hashCode();
+ }
+}
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTest.java?view=diff&rev=518731&r1=518730&r2=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTest.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTest.java Thu Mar 15 12:16:53 2007
@@ -185,6 +185,8 @@
unitInfo.setJtaDataSource(jtaDs);
unitInfo.setNonJtaDataSource(nonJtaDs);
unitInfo.addManagedClassName("org.apache.openejb.core.cmp.jpa.Employee");
+ unitInfo.addManagedClassName("org.apache.openejb.core.cmp.jpa.Bill");
+ unitInfo.addManagedClassName("org.apache.openejb.core.cmp.jpa.EmbeddedBill");
unitInfo.getMappingFileNames().add("META-INF/jpa-test-mappings.xml");
// Handle Properties
@@ -234,9 +236,19 @@
}
private void initializeDatabase(DataSource dataSource) throws SQLException {
+ // employee
createTable(dataSource, "employee", "CREATE TABLE employee ( id IDENTITY PRIMARY KEY, first_name VARCHAR(255), last_name VARCHAR(255))");
execute(dataSource, "INSERT INTO employee (first_name, last_name) VALUES ('David', 'Blevins')");
+ // bill
+ createTable(dataSource, "bill", "CREATE TABLE bill ( billNumber BIGINT NOT NULL, billVersion BIGINT NOT NULL, billRevision BIGINT NOT NULL, billDescription VARCHAR(255) )");
+ execute(dataSource, "INSERT INTO bill (billNumber, billVersion, billRevision, billDescription) VALUES (1, 0, 0, 'Basic Model')");
+
+ // embedded bill
+ createTable(dataSource, "embeddedBill", "CREATE TABLE embeddedBill ( billNumber BIGINT NOT NULL, billVersion BIGINT NOT NULL, billRevision BIGINT NOT NULL, billDescription VARCHAR(255) )");
+ execute(dataSource, "INSERT INTO embeddedBill (billNumber, billVersion, billRevision, billDescription) VALUES (2, 0, 0, 'Advanced Model')");
+
+ // relationship bean
createTable(dataSource, "OneToOneA", "CREATE TABLE OneToOneA(A1 INTEGER, A2 VARCHAR(255))");
createTable(dataSource, "OneToOneB", " CREATE TABLE OneToOneB(B1 INTEGER, B2 VARCHAR(255), B3 INTEGER, B4 VARCHAR(255), FKA1 INTEGER)");
execute(dataSource, "INSERT INTO OneToOneA(A1, A2) VALUES(1, 'value1')");
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTestObject.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTestObject.java?view=diff&rev=518731&r1=518730&r2=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTestObject.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/JpaTestObject.java Thu Mar 15 12:16:53 2007
@@ -17,6 +17,8 @@
*/
package org.apache.openejb.core.cmp.jpa;
+import org.apache.openejb.test.entity.cmp.ComplexCmpBean;
+
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
@@ -95,6 +97,41 @@
}
public void jpaLifecycle() throws Exception {
+ employeeTest();
+ billTest();
+ cmpText();
+ complexCmpText();
+
+
+// beginTx();
+// ABean_ABean a = new ABean_ABean();
+// a.setField1(2);
+// entityManager.persist(a);
+// BBean_BBean b = new BBean_BBean();
+// b.setField1(22);
+// entityManager.persist(b);
+// commitTx();
+//
+// beginTx();
+// b = entityManager.find(BBean_BBean.class, 22);
+// a = entityManager.find(ABean_ABean.class, 2);
+// a.OpenEJB_addCmr("b", b);
+// b.OpenEJB_addCmr("a", a);
+// commitTx();
+//
+//// dump();
+//
+// beginTx();
+// b = entityManager.find(BBean_BBean.class, 22);
+// assertNotNull(b);
+// assertEquals(new Integer(22), b.getField1());
+//// a = (ABean_ABean) b.OpenEJB_getCmr("a");
+//// assertNotNull(a);
+//// assertEquals(new Integer(2), a.getField1());
+// commitTx();
+ }
+
+ private void employeeTest() throws Exception {
// get the pk for the inserted row
int davidPk = -1;
{
@@ -191,6 +228,111 @@
assertEquals(dain.getLastName(), "Sundstrom");
commitTx();
+ }
+
+ public void billTest() throws Exception {
+ // get the pk for the inserted row
+ BillPk basicPk;
+
+ {
+ Connection connection = null;
+ Statement statement = null;
+ try {
+ connection = nonJtaDs.getConnection();
+ statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery("select * from bill");
+ resultSet.next();
+
+ basicPk = new BillPk(resultSet.getLong("billNumber"), resultSet.getLong("billVersion"), resultSet.getLong("billRevision"));
+ } finally {
+ close(statement);
+ close(connection);
+ }
+ }
+
+ beginTx();
+ assertTrue(entityManager.isOpen());
+
+ Bill basic = entityManager.find(Bill.class, basicPk);
+ assertTrue(entityManager.contains(basic));
+
+ assertTrue(basicPk.equals(new BillPk(1, 0, 0)));
+
+ assertEquals(basic.getBillNumber(), 1);
+ assertEquals(basic.getBillVersion(), 0);
+ assertEquals(basic.getBillRevision(), 0);
+ assertEquals(basic.getBillDescription(), "Basic Model");
+
+ commitTx();
+ beginTx();
+
+ basic = (Bill) entityManager.createQuery("select e from Bill e where e.billDescription='Basic Model'").getSingleResult();
+ assertTrue(entityManager.contains(basic));
+
+ assertTrue(basicPk.equals(new BillPk(1, 0, 0)));
+
+ assertEquals(basic.getBillNumber(), 1);
+ assertEquals(basic.getBillVersion(), 0);
+ assertEquals(basic.getBillRevision(), 0);
+ assertEquals(basic.getBillDescription(), "Basic Model");
+
+ commitTx();
+ beginTx();
+
+ basic = entityManager.find(Bill.class, basicPk);
+ entityManager.remove(basic);
+ assertFalse(entityManager.contains(basic));
+ basic = entityManager.find(Bill.class, basicPk);
+ assertNull(basic);
+
+ commitTx();
+ beginTx();
+
+ Bill advanced = new Bill();
+ advanced.setBillNumber(1000);
+ advanced.setBillVersion(2000);
+ advanced.setBillRevision(3000);
+ advanced.setBillDescription("This is so advanced!!");
+ assertFalse(entityManager.contains(advanced));
+
+ entityManager.persist(advanced);
+
+ // extract primary key seems to require a flush followed by a merge
+ entityManager.flush();
+ advanced = entityManager.merge(advanced);
+
+ BillPk advancedPk = new BillPk(advanced.getBillNumber(), advanced.getBillVersion(), advanced.getBillRevision());
+
+ assertTrue(entityManager.contains(advanced));
+
+ commitTx();
+ beginTx();
+
+ advanced = entityManager.find(Bill.class, advancedPk);
+ assertTrue(entityManager.contains(advanced));
+
+ assertTrue(advancedPk.equals(new BillPk(1000, 2000, 3000)));
+ assertEquals(advanced.getBillNumber(), 1000);
+ assertEquals(advanced.getBillVersion(), 2000);
+ assertEquals(advanced.getBillRevision(), 3000);
+ assertEquals(advanced.getBillDescription(), "This is so advanced!!");
+
+ commitTx();
+ beginTx();
+
+ advanced = (Bill) entityManager.createQuery("select e from Bill e").getSingleResult();
+ assertTrue(entityManager.contains(advanced));
+
+ assertTrue(advancedPk.equals(new BillPk(1000, 2000, 3000)));
+ assertEquals(advanced.getBillNumber(), 1000);
+ assertEquals(advanced.getBillVersion(), 2000);
+ assertEquals(advanced.getBillRevision(), 3000);
+ assertEquals(advanced.getBillDescription(), "This is so advanced!!");
+
+ commitTx();
+ }
+
+ private void cmpText() throws Exception {
beginTx();
BasicCmpBean_Subclass basicCmpBean = new BasicCmpBean_Subclass();
@@ -241,34 +383,55 @@
assertEquals(lloyd.getLastName(), "Dobler");
commitTx();
+ }
+ private void complexCmpText() throws Exception {
+ beginTx();
-// beginTx();
-// ABean_ABean a = new ABean_ABean();
-// a.setField1(2);
-// entityManager.persist(a);
-// BBean_BBean b = new BBean_BBean();
-// b.setField1(22);
-// entityManager.persist(b);
-// commitTx();
-//
-// beginTx();
-// b = entityManager.find(BBean_BBean.class, 22);
-// a = entityManager.find(ABean_ABean.class, 2);
-// a.OpenEJB_addCmr("b", b);
-// b.OpenEJB_addCmr("a", a);
-// commitTx();
-//
-//// dump();
-//
-// beginTx();
-// b = entityManager.find(BBean_BBean.class, 22);
-// assertNotNull(b);
-// assertEquals(new Integer(22), b.getField1());
-//// a = (ABean_ABean) b.OpenEJB_getCmr("a");
-//// assertNotNull(a);
-//// assertEquals(new Integer(2), a.getField1());
-// commitTx();
+ ComplexCmpBean complexCmpBean = new ComplexCmpBean_Subclass();
+ complexCmpBean.ejbCreateObject("Joe Blow");
+ assertFalse(entityManager.contains(complexCmpBean));
+
+ entityManager.persist(complexCmpBean);
+
+ // extract primary key seems to require a flush followed by a merge
+ entityManager.flush();
+ complexCmpBean = entityManager.merge(complexCmpBean);
+
+ assertTrue(entityManager.contains(complexCmpBean));
+
+ commitTx();
+ beginTx();
+
+ complexCmpBean = new ComplexCmpBean_Subclass();
+ complexCmpBean.ejbCreateObject("Lloyd Dobler");
+ assertFalse(entityManager.contains(complexCmpBean));
+
+ entityManager.persist(complexCmpBean);
+
+ // extract primary key seems to require a flush followed by a merge
+ entityManager.flush();
+ complexCmpBean = entityManager.merge(complexCmpBean);
+
+ assertTrue(entityManager.contains(complexCmpBean));
+ commitTx();
+
+
+ beginTx();
+
+ ComplexCmpBean joe = (ComplexCmpBean_Subclass) entityManager.createQuery("select e from ComplexCmpBean_Subclass e where e.firstName='Joe'").getSingleResult();
+ assertTrue(entityManager.contains(joe));
+
+ assertEquals(joe.getFirstName(), "Joe");
+ assertEquals(joe.getLastName(), "Blow");
+
+ ComplexCmpBean lloyd = (ComplexCmpBean_Subclass) entityManager.createQuery("select e from ComplexCmpBean_Subclass e where e.firstName='Lloyd'").getSingleResult();
+ assertTrue(entityManager.contains(lloyd));
+
+ assertEquals(lloyd.getFirstName(), "Lloyd");
+ assertEquals(lloyd.getLastName(), "Dobler");
+
+ commitTx();
}
private void createEntityManager() {
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=518731&r1=518730&r2=518731
==============================================================================
--- 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 12:16:53 2007
@@ -30,11 +30,29 @@
<transient name="allowedOperationsTable"/>
</attributes>
</mapped-superclass>
+ <mapped-superclass class="org.apache.openejb.test.entity.cmp.ComplexCmpBean">
+ <id-class class="org.apache.openejb.test.entity.cmp.ComplexCmpBeanPk"/>
+ <attributes>
+ <id name="firstName"/>
+ <id name="lastName"/>
+ <transient name="ejbContext"/>
+ <transient name="allowedOperationsTable"/>
+ </attributes>
+ </mapped-superclass>
<entity class="org.apache.openejb.core.cmp.jpa.BasicCmpBean_Subclass">
<table name="BasicCmpBean"/>
<attribute-override name="primaryKey">
<column name="primaryKey"/>
</attribute-override>
+ <attribute-override name="firstName">
+ <column name="firstName"/>
+ </attribute-override>
+ <attribute-override name="lastName">
+ <column name="lastName"/>
+ </attribute-override>
+ </entity>
+ <entity class="org.apache.openejb.core.cmp.jpa.ComplexCmpBean_Subclass">
+ <table name="ComplexCmpBean"/>
<attribute-override name="firstName">
<column name="firstName"/>
</attribute-override>
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=518731&r1=518730&r2=518731
==============================================================================
--- 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 12:16:53 2007
@@ -274,6 +274,7 @@
<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"/>
Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/IdClass.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/IdClass.java?view=diff&rev=518731&r1=518730&r2=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/IdClass.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/IdClass.java Thu Mar 15 12:16:53 2007
@@ -56,6 +56,13 @@
@XmlAttribute(name = "class", required = true)
protected String clazz;
+ public IdClass() {
+ }
+
+ public IdClass(String clazz) {
+ this.clazz = clazz;
+ }
+
/**
* Gets the value of the clazz property.
*
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBean.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBean.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBean.java Thu Mar 15 12:16:53 2007
@@ -0,0 +1,296 @@
+/**
+ *
+ * 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.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+import java.rmi.RemoteException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * @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 ComplexCmpBean implements EntityBean {
+ public String firstName;
+ public String lastName;
+ public EntityContext ejbContext;
+ public Map<String, OperationsPolicy> allowedOperationsTable = new HashMap<String, OperationsPolicy>();
+
+ //=============================
+ // Home interface methods
+ //
+
+ /**
+ * Maps to BasicCmpHome.sum
+ * <p/>
+ * Adds x and y and returns the result.
+ *
+ * @param x
+ * @param y
+ * @return x + y
+ * @see org.apache.openejb.test.entity.cmp.BasicCmpHome#sum
+ */
+ public int ejbHomeSum(int x, int y) {
+ testAllowedOperations("ejbHome");
+ return x + y;
+ }
+
+ /**
+ * Maps to BasicCmpHome.create
+ */
+ public ComplexCmpBeanPk ejbCreateObject(String name) throws CreateException {
+ StringTokenizer st = new StringTokenizer(name, " ");
+ firstName = st.nextToken();
+ lastName = st.nextToken();
+ return null;
+ }
+
+ public void ejbPostCreateObject(String name) throws CreateException {
+ }
+
+ public ComplexCmpBeanPk getPrimaryKey() {
+ return new ComplexCmpBeanPk(firstName, lastName);
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+ //
+ // Home interface methods
+ //=============================
+
+ //=============================
+ // Remote interface methods
+ //
+
+ /**
+ * Maps to BasicCmpObject.businessMethod
+ *
+ * @return
+ * @see org.apache.openejb.test.entity.cmp.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
+ * <p/>
+ * Returns a report of the bean's
+ * runtime permissions
+ *
+ * @return
+ * @see org.apache.openejb.test.entity.cmp.BasicCmpObject#getPermissionsReport
+ */
+ public Properties getPermissionsReport() {
+ /* TO DO: */
+ return null;
+ }
+
+ /**
+ * Maps to BasicCmpObject.getAllowedOperationsReport
+ * <p/>
+ * 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
+ * @return
+ * @see org.apache.openejb.test.entity.cmp.BasicCmpObject#getAllowedOperationsReport
+ */
+ 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() throws EJBException, RemoteException {
+ }
+
+ /**
+ * Set the associated entity context. The container invokes this method
+ * on an instance after the instance has been created.
+ */
+ public void setEntityContext(EntityContext ctx) throws EJBException, RemoteException {
+ ejbContext = ctx;
+ testAllowedOperations("setEntityContext");
+ }
+
+ /**
+ * Unset the associated entity context. The container calls this method
+ * before removing the instance.
+ */
+ public void unsetEntityContext() throws EJBException, RemoteException {
+ 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() throws EJBException, RemoteException {
+ }
+
+ /**
+ * 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() throws RemoveException, EJBException, RemoteException {
+ }
+
+ /**
+ * 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() throws EJBException, RemoteException {
+ 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() throws EJBException, RemoteException {
+ 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);
+ }
+
+}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBeanPk.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBeanPk.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBeanPk.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpBeanPk.java Thu Mar 15 12:16:53 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 java.io.Serializable;
+
+public class ComplexCmpBeanPk implements Serializable {
+ private static final long serialVersionUID = 6963768936882986623L;
+ public String firstName;
+ public String lastName;
+
+ public ComplexCmpBeanPk() {
+ }
+
+ public ComplexCmpBeanPk(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ComplexCmpBeanPk that = (ComplexCmpBeanPk) o;
+
+ if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) return false;
+ if (lastName != null ? !lastName.equals(that.lastName) : that.lastName != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (firstName != null ? firstName.hashCode() : 0);
+ result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "ComplexCmpBeanPk[ " + firstName + " " + lastName + " ]";
+ }
+}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpHome.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpHome.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpHome.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpHome.java Thu Mar 15 12:16:53 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 ComplexCmpHome extends EJBHome {
+ ComplexCmpObject createObject(String name) throws CreateException, RemoteException;
+
+ ComplexCmpObject findByPrimaryKey(ComplexCmpBeanPk primarykey) throws FinderException, RemoteException;
+
+ Collection findEmptyCollection() throws FinderException, RemoteException;
+
+ Collection findByLastName(String lastName) throws FinderException, RemoteException;
+
+ 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/ComplexCmpObject.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpObject.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpObject.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpObject.java Thu Mar 15 12:16:53 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 ComplexCmpObject 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=518731&r1=518730&r2=518731
==============================================================================
--- 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 12:16:53 2007
@@ -81,6 +81,30 @@
</resource-ref>
</entity>
+ <entity>
+ <ejb-name>ComplexCmpBean</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.ComplexCmpBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <cmp-version>1.x</cmp-version>
+ <abstract-schema-name>ComplexCmpBeanX</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/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=518731&r1=518730&r2=518731
==============================================================================
--- 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 12:16:53 2007
@@ -36,6 +36,25 @@
<object-ql>SELECT o FROM BasicCmpBean o WHERE 'true' = 'false'</object-ql>
</query>
</ejb-deployment>
+ <ejb-deployment ejb-name="ComplexCmpBean" deployment-id="client/tests/entity/cmp/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 ComplexCmpBeanX 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 ComplexCmpBean 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=518731&r1=518730&r2=518731
==============================================================================
--- 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 12:16:53 2007
@@ -61,6 +61,8 @@
private static final String[] AUTO_CREATED_TABLES = new String[] {
"BasicCmpBean",
"BasicCmpBeanX",
+ "ComplexCmpBean",
+ "ComplexCmpBeanX",
"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=518731&r1=518730&r2=518731
==============================================================================
--- 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 12:16:53 2007
@@ -44,6 +44,13 @@
this.addTest(new CmpContextLookupTests());
this.addTest(new CmpRmiIiopTests());
+ this.addTest(new ComplexHomeIntfcTests());
+ this.addTest(new ComplexEjbHomeTests());
+ this.addTest(new ComplexEjbObjectTests());
+ this.addTest(new ComplexRemoteIntfcTests());
+ this.addTest(new ComplexHomeHandleTests());
+ this.addTest(new ComplexHandleTests());
+ this.addTest(new ComplexEjbMetaDataTests());
}
public static junit.framework.Test suite() {
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpTestSuite.java?view=diff&rev=518731&r1=518730&r2=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpTestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/CmpTestSuite.java Thu Mar 15 12:16:53 2007
@@ -44,7 +44,8 @@
this.addTest(new CmpJndiEncTests());
this.addTest(new CmpContextLookupTests());
this.addTest(new CmpRmiIiopTests());
-
+
+ this.addTest(new ComplexHomeIntfcTests());
}
public static junit.framework.Test suite() {
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpTestClient.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpTestClient.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpTestClient.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexCmpTestClient.java Thu Mar 15 12:16:53 2007
@@ -0,0 +1,33 @@
+/**
+ *
+ * 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 ComplexCmpTestClient extends CmpTestClient{
+
+ protected ComplexCmpHome ejbHome;
+ protected ComplexCmpObject ejbObject;
+
+ public ComplexCmpTestClient(String name){
+ super(name);
+ }
+}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbHomeTests.java Thu Mar 15 12:16:53 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.ejb.EJBMetaData;
+import javax.rmi.PortableRemoteObject;
+
+/**
+ * [3] Should be run as the third test suite of the ComplexCmpTestClients
+ *
+ * @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 ComplexEjbHomeTests extends ComplexCmpTestClient {
+
+ public ComplexEjbHomeTests() {
+ super("EJBHome.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/ComplexCmpHome");
+ ejbHome = (ComplexCmpHome) 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());
+ }
+ }
+ //
+ // Test ejb home methods
+ //===============================
+}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbMetaDataTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbMetaDataTests.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbMetaDataTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbMetaDataTests.java Thu Mar 15 12:16:53 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.ejb.EJBHome;
+import javax.rmi.PortableRemoteObject;
+
+/**
+ * [8] Should be run as the eigth test suite of the ComplexCmpTestClients
+ *
+ * @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 ComplexEjbMetaDataTests extends ComplexCmpTestClient {
+
+ public ComplexEjbMetaDataTests() {
+ super("EJBMetaData.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/ComplexCmpHome");
+ ejbHome = (ComplexCmpHome) 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/cmp/ComplexEjbObjectTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexEjbObjectTests.java Thu Mar 15 12:16:53 2007
@@ -0,0 +1,114 @@
+/**
+ *
+ * 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.rmi.PortableRemoteObject;
+
+/**
+ * [4] Should be run as the fourth test suite of the ComplexCmpTestClients
+ *
+ * @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 ComplexEjbObjectTests extends ComplexCmpTestClient {
+
+ public ComplexEjbObjectTests() {
+ super("EJBObject.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/ComplexCmpHome");
+ ejbHome = (ComplexCmpHome) PortableRemoteObject.narrow(obj, ComplexCmpHome.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);
+ assertTrue("Expected (ejbPrimaryKey instanceof ComplexCmpBeanPk) but was instanceof " + ejbPrimaryKey.getClass().getName(), ejbPrimaryKey instanceof ComplexCmpBeanPk);
+ } 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/ComplexHandleTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHandleTests.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHandleTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHandleTests.java Thu Mar 15 12:16:53 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.ejb.EJBObject;
+import javax.rmi.PortableRemoteObject;
+
+/**
+ * [7] Should be run as the seventh test suite of the ComplexCmpTestClients
+ *
+ * @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 ComplexHandleTests extends ComplexCmpTestClient {
+
+ public ComplexHandleTests() {
+ super("Handle.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/ComplexCmpHome");
+ ejbHome = (ComplexCmpHome) 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());
+ }
+ }
+
+ /**
+ * 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/ComplexHomeHandleTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHomeHandleTests.java?view=auto&rev=518731
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHomeHandleTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmp/ComplexHomeHandleTests.java Thu Mar 15 12:16:53 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.ejb.EJBHome;
+import javax.rmi.PortableRemoteObject;
+
+/**
+ * [6] Should be run as the sixth test suite of the ComplexCmpTestClients
+ *
+ * @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 ComplexHomeHandleTests extends ComplexCmpTestClient {
+
+ public ComplexHomeHandleTests() {
+ super("HomeHandle.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object obj = initialContext.lookup("client/tests/entity/cmp/ComplexCmpHome");
+ ejbHome = (ComplexCmpHome) 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());
+ }
+ }
+ //
+ // Test home handle methods
+ //=================================
+
+}