Adding further basic CMP tests
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/29ab1f47 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/29ab1f47 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/29ab1f47 Branch: refs/heads/tomee-7.0.x Commit: 29ab1f47719b4f63f12ccbc8dcc5df81aeddd6ab Parents: fd73c7c Author: Jonathan Gallimore <[email protected]> Authored: Fri Nov 16 15:06:17 2018 +0000 Committer: Otavio Santana <[email protected]> Committed: Mon Dec 17 09:00:00 2018 -0200 ---------------------------------------------------------------------- .../openejb/arquillian/tests/cmp/MyCmpBean.java | 53 +++++++++++++++++++ .../arquillian/tests/cmp/MyLocalHome.java | 14 +++++ .../arquillian/tests/cmp/MyLocalObject.java | 7 +++ .../arquillian/tests/cmp/MyRemoteHome.java | 14 +++++ .../arquillian/tests/cmp/MyRemoteObject.java | 9 ++++ .../openejb/arquillian/tests/cmp/ejb-jar.xml | 54 ++++++++++++++++++++ .../arquillian/tests/cmp/openejb-cmp-orm.xml | 32 ++++++++++++ .../apache/openejb/config/ReadDescriptors.java | 3 +- .../openejb/config/ReadDescriptorsTest.java | 10 ++++ .../openejb/config/test-openejb-cmp-orm.xml | 32 ++++++++++++ 10 files changed, 227 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyCmpBean.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyCmpBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyCmpBean.java new file mode 100644 index 0000000..20ecd76 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyCmpBean.java @@ -0,0 +1,53 @@ +package org.apache.openejb.arquillian.tests.cmp; + +import javax.ejb.CreateException; +import javax.ejb.EntityBean; +import javax.ejb.EntityContext; +import javax.ejb.LocalHome; +import javax.ejb.RemoteHome; +import javax.ejb.RemoveException; + +@LocalHome(MyLocalHome.class) +@RemoteHome(MyRemoteHome.class) +public abstract class MyCmpBean implements EntityBean { + + // CMP + public abstract Integer getId(); + + public abstract void setId(Integer id); + + public abstract String getName(); + + public abstract void setName(String number); + + public void doit() { + } + + public Integer ejbCreateObject(final String id) throws CreateException { + return null; + } + + public void ejbPostCreateObject(final String id) { + } + + public void setEntityContext(final EntityContext ctx) { + } + + public void unsetEntityContext() { + } + + public void ejbActivate() { + } + + public void ejbPassivate() { + } + + public void ejbLoad() { + } + + public void ejbStore() { + } + + public void ejbRemove() throws RemoveException { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyLocalHome.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyLocalHome.java new file mode 100644 index 0000000..8eb489e --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyLocalHome.java @@ -0,0 +1,14 @@ +package org.apache.openejb.arquillian.tests.cmp; + +public interface MyLocalHome extends javax.ejb.EJBLocalHome { + + public MyLocalObject createObject(String name) + throws javax.ejb.CreateException; + + public MyLocalObject findByPrimaryKey(Integer primarykey) + throws javax.ejb.FinderException; + + public java.util.Collection findEmptyCollection() + throws javax.ejb.FinderException; + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyLocalObject.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyLocalObject.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyLocalObject.java new file mode 100644 index 0000000..c007571 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyLocalObject.java @@ -0,0 +1,7 @@ +package org.apache.openejb.arquillian.tests.cmp; + +public interface MyLocalObject extends javax.ejb.EJBLocalObject { + + public void doit(); + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyRemoteHome.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyRemoteHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyRemoteHome.java new file mode 100644 index 0000000..9153ad6 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyRemoteHome.java @@ -0,0 +1,14 @@ +package org.apache.openejb.arquillian.tests.cmp; + +public interface MyRemoteHome extends javax.ejb.EJBHome { + + public MyRemoteObject createObject(String name) + throws javax.ejb.CreateException, java.rmi.RemoteException; + + public MyRemoteObject findByPrimaryKey(Integer primarykey) + throws javax.ejb.FinderException, java.rmi.RemoteException; + + public java.util.Collection findEmptyCollection() + throws javax.ejb.FinderException, java.rmi.RemoteException; + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyRemoteObject.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyRemoteObject.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyRemoteObject.java new file mode 100644 index 0000000..c745289 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/MyRemoteObject.java @@ -0,0 +1,9 @@ +package org.apache.openejb.arquillian.tests.cmp; + +import java.rmi.RemoteException; + +public interface MyRemoteObject extends javax.ejb.EJBObject { + + public void doit() throws RemoteException; + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/ejb-jar.xml ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/ejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/ejb-jar.xml new file mode 100644 index 0000000..d9b2065 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/ejb-jar.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. +--> +<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + version="3.1" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> + <enterprise-beans> + <entity> + <ejb-name>MyCmpBean</ejb-name> + <ejb-class>org.apache.openejb.arquillian.tests.cmp.MyCmpBean</ejb-class> + <persistence-type>Container</persistence-type> + <prim-key-class>java.lang.Integer</prim-key-class> + <reentrant>false</reentrant> + <cmp-field> + <field-name>name</field-name> + </cmp-field> + <primkey-field>id</primkey-field> + <query> + <query-method> + <method-name>findByPrimaryKey</method-name> + <method-params> + <method-param>java.lang.Integer</method-param> + </method-params> + </query-method> + <ejb-ql>SELECT OBJECT(DL) FROM License DL</ejb-ql> + </query> + </entity> + </enterprise-beans> + <assembly-descriptor> + <container-transaction> + <method> + <ejb-name>MyCmpBean</ejb-name> + <method-name>*</method-name> + </method> + <trans-attribute>Supports</trans-attribute> + </container-transaction> + </assembly-descriptor> +</ejb-jar> http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/openejb-cmp-orm.xml ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/openejb-cmp-orm.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/openejb-cmp-orm.xml new file mode 100644 index 0000000..19cf79d --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/openejb-cmp-orm.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. +--> +<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0"> + <entity class="org.apache.openejb.arquillian.tests.cmp.MyCmpBean" name="MyCmpBean"> + <description>MyCmpBean</description> + <named-query name="MyCmpBean.findByPrimaryKey(java.lang.Integer)"> + <query>SELECT OBJECT(DL) FROM License DL</query> + </named-query> + <attributes> + <id name="id"/> + <basic name="name"> + <column name="wNAME" length="300"/> + </basic> + </attributes> + </entity> +</entity-mappings> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java index b3942a0..683ca91 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java @@ -538,7 +538,8 @@ public class ReadDescriptors implements DynamicDeployer { return current; } - private void readCmpOrm(final EjbModule ejbModule) throws OpenEJBException { + // package scoped for testing + void readCmpOrm(final EjbModule ejbModule) throws OpenEJBException { final Object data = ejbModule.getAltDDs().get("openejb-cmp-orm.xml"); if (data != null && !(data instanceof EntityMappings)) { if (data instanceof URL) { http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java index c8d029d..a46e9a9 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java @@ -19,6 +19,8 @@ package org.apache.openejb.config; import org.apache.openejb.config.sys.Resource; import org.apache.openejb.config.sys.Resources; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.jpa.EntityMappings; import org.junit.Assert; import org.junit.Test; @@ -92,4 +94,12 @@ public class ReadDescriptorsTest { Assert.assertNull(res.getProperties().getProperty("InitializeAfterDeployment")); } + @Test + public void testReadCmpOrmDescriptor() throws Exception { + final EjbModule ejbModule = new EjbModule(new EjbJar()); + ejbModule.getAltDDs().put("openejb-cmp-orm.xml", getClass().getResource("test-openejb-cmp-orm.xml")); + new ReadDescriptors().readCmpOrm(ejbModule); + Assert.assertNotNull(ejbModule.getAltDDs().get("openejb-cmp-orm.xml")); + Assert.assertTrue(EntityMappings.class.isInstance(ejbModule.getAltDDs().get("openejb-cmp-orm.xml"))); + } } http://git-wip-us.apache.org/repos/asf/tomee/blob/29ab1f47/container/openejb-core/src/test/resources/org/apache/openejb/config/test-openejb-cmp-orm.xml ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/resources/org/apache/openejb/config/test-openejb-cmp-orm.xml b/container/openejb-core/src/test/resources/org/apache/openejb/config/test-openejb-cmp-orm.xml new file mode 100644 index 0000000..f26eb72 --- /dev/null +++ b/container/openejb-core/src/test/resources/org/apache/openejb/config/test-openejb-cmp-orm.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. +--> +<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0"> + <entity class="MyCmpBean" name="MyCmpBean"> + <description>MyCmpBean</description> + <named-query name="MyCmpBean.findByPrimaryKey(java.lang.Integer)"> + <query>SELECT OBJECT(DL) FROM License DL</query> + </named-query> + <attributes> + <id name="id"/> + <basic name="name"> + <column name="wNAME" length="300"/> + </basic> + </attributes> + </entity> +</entity-mappings> \ No newline at end of file
