You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/11/19 15:09:25 UTC

[1/5] tomee git commit: Add simple test to ensure overrides from openejb-cmp-orm.xml work

Repository: tomee
Updated Branches:
  refs/heads/master 511db23be -> 9939dff9f


Add simple test to ensure overrides from openejb-cmp-orm.xml work


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e8ef7742
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e8ef7742
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e8ef7742

Branch: refs/heads/master
Commit: e8ef7742ea599f2506abac821dacb242b83919b4
Parents: 60ef186
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Fri Nov 16 12:39:20 2018 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Fri Nov 16 12:39:20 2018 +0000

----------------------------------------------------------------------
 .../openejb/core/LegacyInterfaceTest.java       | 76 ++++++++++++++++++++
 1 file changed, 76 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/e8ef7742/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
index a7f7494..f450f2c 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
@@ -24,6 +24,7 @@ import org.apache.openejb.assembler.classic.TransactionServiceInfo;
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.config.PersistenceModule;
 import org.apache.openejb.core.ivm.naming.InitContextFactory;
 import org.apache.openejb.jee.CmpField;
 import org.apache.openejb.jee.ContainerTransaction;
@@ -34,6 +35,7 @@ import org.apache.openejb.jee.Query;
 import org.apache.openejb.jee.QueryMethod;
 import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.jee.TransAttribute;
+import org.apache.openejb.jee.jpa.*;
 import org.junit.AfterClass;
 
 import javax.ejb.CreateException;
@@ -140,6 +142,80 @@ public class LegacyInterfaceTest extends TestCase {
 
     }
 
+    public void testCustomCmpMappings() throws Exception {
+
+        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
+
+        final ConfigurationFactory config = new ConfigurationFactory();
+        final Assembler assembler = new Assembler();
+
+        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+        final EjbJar ejbJar = new EjbJar();
+        ejbJar.addEnterpriseBean(new SingletonBean(MySingletonBean.class));
+        ejbJar.addEnterpriseBean(new EntityBean(MyBmpBean.class, PersistenceType.BEAN));
+
+        final EntityBean cmp = ejbJar.addEnterpriseBean(new EntityBean(MyCmpBean.class, PersistenceType.CONTAINER));
+        cmp.setPrimKeyClass(Integer.class.getName());
+        cmp.setPrimkeyField("id");
+        cmp.getCmpField().add(new CmpField("id"));
+        cmp.getCmpField().add(new CmpField("name"));
+        final Query query = new Query();
+        query.setQueryMethod(new QueryMethod("findByPrimaryKey", Integer.class.getName()));
+        query.setEjbQl("SELECT OBJECT(DL) FROM License DL");
+        cmp.getQuery().add(query);
+        final List<ContainerTransaction> transactions = ejbJar.getAssemblyDescriptor().getContainerTransaction();
+
+        transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MyBmpBean", "*"));
+        transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MyCmpBean", "*"));
+        transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MySingletonBean", "*"));
+
+        final File f = new File("test").getAbsoluteFile();
+        if (!f.exists() && !f.mkdirs()) {
+            throw new Exception("Failed to create test directory: " + f);
+        }
+
+        final EntityMappings entityMappings = new EntityMappings();
+
+        final Entity entity = new Entity();
+        entity.setClazz("openejb.org.apache.openejb.core.MyCmpBean");
+        entity.setName("MyCmpBean");
+        entity.setDescription("MyCmpBean");
+        entity.setAttributes(new Attributes());
+
+        final NamedQuery namedQuery = new NamedQuery();
+        namedQuery.setQuery("SELECT OBJECT(DL) FROM License DL");
+        entity.getNamedQuery().add(namedQuery);
+
+        final Id id = new Id();
+        id.setName("id");
+        entity.getAttributes().getId().add(id);
+
+        final Basic basic = new Basic();
+        basic.setName("name");
+        final Column column = new Column();
+        column.setName("wNAME");
+        column.setLength(300);
+        basic.setColumn(column);
+        entity.getAttributes().getBasic().add(basic);
+
+        entityMappings.getEntity().add(entity);
+
+        final AppModule module = new AppModule(this.getClass().getClassLoader(), f.getAbsolutePath());
+        final EjbModule ejbModule = new EjbModule(ejbJar);
+        ejbModule.getAltDDs().put("openejb-cmp-orm.xml", entityMappings);
+        module.getEjbModules().add(ejbModule);
+
+        assertNull(module.getCmpMappings());
+        assembler.createApplication(config.configureApplication(module));
+        assertNotNull(module.getCmpMappings());
+        final List<Basic> basicList = module.getCmpMappings().getEntityMap().get("openejb.org.apache.openejb.core.MyCmpBean").getAttributes().getBasic();
+        assertEquals(1, basicList.size());
+        assertEquals(300, basicList.get(0).getColumn().getLength().intValue());
+        assertEquals("wNAME", basicList.get(0).getColumn().getName());
+    }
+
     @LocalHome(MyLocalHome.class)
     @RemoteHome(MyRemoteHome.class)
     public static abstract class MyCmpBean implements javax.ejb.EntityBean {


[2/5] tomee git commit: Adding further basic CMP tests

Posted by jg...@apache.org.
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/f668add7
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/f668add7
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/f668add7

Branch: refs/heads/master
Commit: f668add70884ff2038e15b0eb52bff8547c7c3dc
Parents: e8ef774
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Fri Nov 16 15:06:17 2018 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Fri Nov 16 15:06:17 2018 +0000

----------------------------------------------------------------------
 .gitignore                                      |  1 +
 .../arquillian/tests/cmp/CmpMappingTest.java    | 58 ++++++++++++++++++++
 .../arquillian/tests/cmp/CmpServlet.java        | 30 ++++++++++
 .../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 +++++++++++
 13 files changed, 316 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/f668add7/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 548c9c3..fa39aa3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ quick.bat
 /temp
 /report.txt
 nb-configuration.xml
+.factorypath

http://git-wip-us.apache.org/repos/asf/tomee/blob/f668add7/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/CmpMappingTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/CmpMappingTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/CmpMappingTest.java
new file mode 100644
index 0000000..4c8cf41
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/CmpMappingTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.arquillian.tests.cmp;
+
+import org.apache.ziplock.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(Arquillian.class)
+public class CmpMappingTest {
+
+    @ArquillianResource
+    private URL url;
+
+    @Deployment(testable = false)
+    public static WebArchive createDeployment() {
+        WebArchive archive = ShrinkWrap.create(WebArchive.class, CmpMappingTest.class.getSimpleName() + ".war")
+                .addClasses(CmpServlet.class, MyCmpBean.class, MyLocalHome.class, MyLocalObject.class, MyRemoteHome.class, MyRemoteObject.class)
+                .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/openejb-cmp-orm.xml"), "openejb-cmp-orm.xml")
+                .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/ejb-jar.xml"), "ejb-jar.xml");
+
+        System.out.println(archive.toString(true));
+        return archive;
+    }
+
+    @Test
+    @RunAsClient
+    public void checkCmpJpaEntityORMMappings() throws Exception {
+        final String output = IO.readString(new URL(url.toExternalForm()));
+        System.out.println(output);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/f668add7/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/CmpServlet.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/CmpServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/CmpServlet.java
new file mode 100644
index 0000000..c843a9c
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/CmpServlet.java
@@ -0,0 +1,30 @@
+package org.apache.openejb.arquillian.tests.cmp;
+
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.loader.SystemInstance;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collection;
+
+@WebServlet(name="Cmp", urlPatterns = "/*")
+public class CmpServlet extends HttpServlet {
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+        final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
+        final Collection<AppInfo> deployedApplications = assembler.getDeployedApplications();
+
+        for (final AppInfo deployedApplication : deployedApplications) {
+            if ("CmpMappingTest".equals(deployedApplication.appId)) {
+                final String cmpMappingsXml = deployedApplication.cmpMappingsXml;
+                resp.getWriter().write(cmpMappingsXml == null ? "null" : cmpMappingsXml);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/f668add7/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/f668add7/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/f668add7/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/f668add7/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/f668add7/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/f668add7/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/f668add7/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/f668add7/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 814ebf1..171a563 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
@@ -548,7 +548,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/f668add7/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/f668add7/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


[3/5] tomee git commit: defines a new umarshal, this time, not using the filter

Posted by jg...@apache.org.
defines a new umarshal, this time, not using the filter


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/0165264d
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/0165264d
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/0165264d

Branch: refs/heads/master
Commit: 0165264d37f9cb6ce6d2585f2f6b0fbd926ad5c4
Parents: f668add
Author: Otavio Santana <ot...@gmail.com>
Authored: Fri Nov 16 19:13:19 2018 -0200
Committer: Otavio Santana <ot...@gmail.com>
Committed: Fri Nov 16 19:13:19 2018 -0200

----------------------------------------------------------------------
 .../apache/openejb/config/ReadDescriptors.java  |  2 +-
 .../java/org/apache/openejb/jee/JaxbJavaee.java | 89 +++++++++++++-------
 2 files changed, 60 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/0165264d/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 171a563..ab482f1 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
@@ -555,7 +555,7 @@ public class ReadDescriptors implements DynamicDeployer {
             if (data instanceof URL) {
                 final URL url = (URL) data;
                 try {
-                    final EntityMappings entitymappings = (EntityMappings) JaxbJavaee.unmarshalJavaee(EntityMappings.class, IO.read(url));
+                    final EntityMappings entitymappings = (EntityMappings) JaxbJavaee.unmarshal(EntityMappings.class, IO.read(url));
                     ejbModule.getAltDDs().put("openejb-cmp-orm.xml", entitymappings);
                 } catch (final SAXException e) {
                     throw new OpenEJBException("Cannot parse the openejb-cmp-orm.xml file: " + url.toExternalForm(), e);

http://git-wip-us.apache.org/repos/asf/tomee/blob/0165264d/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
----------------------------------------------------------------------
diff --git a/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
index 3d79864..a76be06 100644
--- a/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
+++ b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
@@ -5,14 +5,14 @@
  * 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.
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.jee;
 
@@ -91,18 +91,7 @@ public class JaxbJavaee {
         return jaxbContext;
     }
 
-    /**
-     * Convert the namespaceURI in the input to the javaee URI, do not validate the xml, and read in a T.
-     *
-     * @param type Class of object to be read in
-     * @param in   input stream to read
-     * @param <T>  class of object to be returned
-     * @return a T read from the input stream
-     * @throws ParserConfigurationException is the SAX parser can not be configured
-     * @throws SAXException                 if there is an xml problem
-     * @throws JAXBException                if the xml cannot be marshalled into a T.
-     */
-    public static <T> Object unmarshalJavaee(final Class<T> type, final InputStream in) throws ParserConfigurationException, SAXException, JAXBException {
+    private static <T> Object unmarshalJavaee(final Class<T> type, final InputStream in, boolean filter) throws ParserConfigurationException, SAXException, JAXBException {
 
         final SAXParserFactory factory = SAXParserFactory.newInstance();
         factory.setNamespaceAware(true);
@@ -122,11 +111,16 @@ public class JaxbJavaee {
             }
         });
 
-        final JavaeeNamespaceFilter xmlFilter = new JavaeeNamespaceFilter(parser.getXMLReader());
-        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
+        SAXSource source = null;
+        if (filter) {
+            final JavaeeNamespaceFilter xmlFilter = new JavaeeNamespaceFilter(parser.getXMLReader());
+            xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
+            // unmarshall
+            source = new SAXSource(xmlFilter, new InputSource(in));
+        } else {
+            source = new SAXSource(new InputSource(in));
+        }
 
-        // unmarshall
-        final SAXSource source = new SAXSource(xmlFilter, new InputSource(in));
 
         currentPublicId.set(new TreeSet<String>());
         try {
@@ -138,6 +132,37 @@ public class JaxbJavaee {
     }
 
     /**
+     *
+     * It unmarshals, but not using the {@link JavaeeNamespaceFilter}
+     *
+     * @param type Class of object to be read in
+     * @param in   input stream to read
+     * @param <T>  class of object to be returned
+     * @return a T read from the input stream
+     * @throws ParserConfigurationException is the SAX parser can not be configured
+     * @throws SAXException                 if there is an xml problem
+     * @throws JAXBException                if the xml cannot be marshalled into a T.
+     */
+    public static <T> Object unmarshal(final Class<T> type, final InputStream in) throws ParserConfigurationException, SAXException, JAXBException {
+        return unmarshalJavaee(type, in, false);
+    }
+
+    /**
+     * Convert the namespaceURI in the input to the javaee URI, do not validate the xml, and read in a T.
+     *
+     * @param type Class of object to be read in
+     * @param in   input stream to read
+     * @param <T>  class of object to be returned
+     * @return a T read from the input stream
+     * @throws ParserConfigurationException is the SAX parser can not be configured
+     * @throws SAXException                 if there is an xml problem
+     * @throws JAXBException                if the xml cannot be marshalled into a T.
+     */
+    public static <T> Object unmarshalJavaee(final Class<T> type, final InputStream in) throws ParserConfigurationException, SAXException, JAXBException {
+        return unmarshalJavaee(type, in, true);
+    }
+
+    /**
      * Read in a T from the input stream.
      *
      * @param type     Class of object to be read in
@@ -290,7 +315,11 @@ public class JaxbJavaee {
             if (uri != null && (uri.startsWith("http://jboss.org") || uri.startsWith("urn:java:"))) { // ignore it to be able to read beans.xml with weld config for instances
                 ignore = true;
             } else {
-                super.startElement("http://java.sun.com/xml/ns/javaee", localName, qname, atts);
+                if ("entity-mappings".equals(localName) && "entity-mappings".equals(localName)) {
+                    super.startElement("http://java.sun.com/xml/ns/javaee", localName, qname, atts);
+                } else {
+                    super.startElement("http://java.sun.com/xml/ns/persistence/orm", localName, qname, atts);
+                }
             }
         }
 
@@ -327,7 +356,7 @@ public class JaxbJavaee {
 
         protected String eeUri(final String uri) {
             // if ee 7 then switch back on ee 6 to not break compatibility - to rework surely when we'll be fully ee 7
-            return "http://xmlns.jcp.org/xml/ns/javaee".equals(uri) ? "http://java.sun.com/xml/ns/javaee": uri;
+            return "http://xmlns.jcp.org/xml/ns/javaee".equals(uri) ? "http://java.sun.com/xml/ns/javaee" : uri;
         }
 
         @Override
@@ -555,10 +584,10 @@ public class JaxbJavaee {
         schemaFactory.setResourceResolver(resourceResolver);
 
         final Schema schema = schemaFactory.newSchema(
-            new Source[]{
-                new StreamSource(xmlSchemaURL.openStream()),
-                new StreamSource(javaeeSchemaURL.openStream())
-            });
+                new Source[]{
+                        new StreamSource(xmlSchemaURL.openStream()),
+                        new StreamSource(javaeeSchemaURL.openStream())
+                });
 
         // validate
         schema.newValidator().validate(sourceForValidate);


[5/5] tomee git commit: Merge remote-tracking branch 'apache/master'

Posted by jg...@apache.org.
Merge remote-tracking branch 'apache/master'


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/9939dff9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/9939dff9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/9939dff9

Branch: refs/heads/master
Commit: 9939dff9f9439440e241c93e0a16ee3dc14044b7
Parents: 3e75a75 511db23
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Mon Nov 19 15:09:05 2018 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Nov 19 15:09:05 2018 +0000

----------------------------------------------------------------------
 itests/failover-ejb/pom.xml                     | 3 +++
 itests/failover/pom.xml                         | 3 +++
 itests/legacy-client/pom.xml                    | 3 +++
 itests/legacy-server/pom.xml                    | 3 +++
 itests/openejb-itests-app/pom.xml               | 3 +++
 itests/openejb-itests-beans/pom.xml             | 3 +++
 itests/openejb-itests-client/pom.xml            | 3 +++
 itests/openejb-itests-interceptor-beans/pom.xml | 3 +++
 itests/openejb-itests-servlets/pom.xml          | 3 +++
 itests/openejb-itests-web/pom.xml               | 3 +++
 10 files changed, 30 insertions(+)
----------------------------------------------------------------------



Re: [4/5] tomee git commit: keeps the original behavior of the filter

Posted by Jean-Louis Monteiro <jl...@tomitribe.com>.
Hey Otavio,

This is a great contribution. Thanks and congrats for your first commit.

JLouis
--
Jean-Louis Monteiro
http://twitter.com/jlouismonteiro
http://www.tomitribe.com


On Mon, Nov 19, 2018 at 4:09 PM <jg...@apache.org> wrote:

> keeps the original behavior of the filter
>
>
> Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
> Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3e75a75b
> Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3e75a75b
> Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3e75a75b
>
> Branch: refs/heads/master
> Commit: 3e75a75b31ad5c61309b58af9944587f5d0e1258
> Parents: 0165264
> Author: Otavio Santana <ot...@gmail.com>
> Authored: Mon Nov 19 09:34:03 2018 -0200
> Committer: Otavio Santana <ot...@gmail.com>
> Committed: Mon Nov 19 09:34:03 2018 -0200
>
> ----------------------------------------------------------------------
>  .../src/main/java/org/apache/openejb/jee/JaxbJavaee.java       | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/tomee/blob/3e75a75b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
> ----------------------------------------------------------------------
> diff --git
> a/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
> b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
> index a76be06..407e183 100644
> ---
> a/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
> +++
> b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
> @@ -315,11 +315,7 @@ public class JaxbJavaee {
>              if (uri != null && (uri.startsWith("http://jboss.org") ||
> uri.startsWith("urn:java:"))) { // ignore it to be able to read beans.xml
> with weld config for instances
>                  ignore = true;
>              } else {
> -                if ("entity-mappings".equals(localName) &&
> "entity-mappings".equals(localName)) {
> -                    super.startElement("http://java.sun.com/xml/ns/javaee",
> localName, qname, atts);
> -                } else {
> -                    super.startElement("
> http://java.sun.com/xml/ns/persistence/orm", localName, qname, atts);
> -                }
> +                super.startElement("http://java.sun.com/xml/ns/javaee",
> localName, qname, atts);
>              }
>          }
>
>
>

[4/5] tomee git commit: keeps the original behavior of the filter

Posted by jg...@apache.org.
keeps the original behavior of the filter


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3e75a75b
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3e75a75b
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3e75a75b

Branch: refs/heads/master
Commit: 3e75a75b31ad5c61309b58af9944587f5d0e1258
Parents: 0165264
Author: Otavio Santana <ot...@gmail.com>
Authored: Mon Nov 19 09:34:03 2018 -0200
Committer: Otavio Santana <ot...@gmail.com>
Committed: Mon Nov 19 09:34:03 2018 -0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/openejb/jee/JaxbJavaee.java       | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3e75a75b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
----------------------------------------------------------------------
diff --git a/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
index a76be06..407e183 100644
--- a/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
+++ b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
@@ -315,11 +315,7 @@ public class JaxbJavaee {
             if (uri != null && (uri.startsWith("http://jboss.org") || uri.startsWith("urn:java:"))) { // ignore it to be able to read beans.xml with weld config for instances
                 ignore = true;
             } else {
-                if ("entity-mappings".equals(localName) && "entity-mappings".equals(localName)) {
-                    super.startElement("http://java.sun.com/xml/ns/javaee", localName, qname, atts);
-                } else {
-                    super.startElement("http://java.sun.com/xml/ns/persistence/orm", localName, qname, atts);
-                }
+                super.startElement("http://java.sun.com/xml/ns/javaee", localName, qname, atts);
             }
         }