You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2017/06/22 08:08:26 UTC

tomee git commit: TOMEE-2073 another patch from Svetlin to ensure EJB#beanName is used in any case

Repository: tomee
Updated Branches:
  refs/heads/master dd1884407 -> ce3b5359b


TOMEE-2073 another patch from Svetlin to ensure EJB#beanName is used in any case


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

Branch: refs/heads/master
Commit: ce3b5359b27bf95bcf438a10b540ec2ca182dbff
Parents: dd18844
Author: rmannibucau <rm...@apache.org>
Authored: Thu Jun 22 10:08:08 2017 +0200
Committer: rmannibucau <rm...@apache.org>
Committed: Thu Jun 22 10:08:15 2017 +0200

----------------------------------------------------------------------
 .../arquillian/tests/core/ejb/ejbjar/Bean.java  |  22 ++++
 .../DescriptorComplementsAnnotationsTest.java   | 113 +++++++++++++++++++
 .../tests/core/ejb/ejbjar/FirstBean.java        |  28 +++++
 .../tests/core/ejb/ejbjar/SecondBean.java       |  28 +++++
 .../ejb/descriptor_complements_annotations.xml  |  67 +++++++++++
 .../openejb/config/AnnotationDeployer.java      |   3 +
 6 files changed, 261 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ce3b5359/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/Bean.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/Bean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/Bean.java
new file mode 100644
index 0000000..1ff561c
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/Bean.java
@@ -0,0 +1,22 @@
+/*
+ * 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.core.ejb.ejbjar;
+
+public interface Bean {
+    String getName();
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/ce3b5359/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/DescriptorComplementsAnnotationsTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/DescriptorComplementsAnnotationsTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/DescriptorComplementsAnnotationsTest.java
new file mode 100644
index 0000000..b10a727
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/DescriptorComplementsAnnotationsTest.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openejb.arquillian.tests.core.ejb.ejbjar;
+
+import org.apache.openejb.arquillian.tests.Runner;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+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.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
+import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppVersionType;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class DescriptorComplementsAnnotationsTest {
+    private static final String TEST_NAME = DescriptorComplementsAnnotationsTest.class.getSimpleName();
+    private static final String SERVLET_NAME = "TestServlet";
+    private static final java.lang.String RESOURCE_EJB_JAR_XML = "ejb-jar.xml";
+    private static final java.lang.String CONTENT_LOCATION_EJB_JAR_XML = "org/apache/openejb/arquillian/tests/core/ejb/descriptor_complements_annotations.xml";
+
+    @ArquillianResource
+    private URL url;
+
+    @Deployment(testable = false)
+    public static WebArchive createDeployment() {
+        WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
+                .version(WebAppVersionType._3_0)
+                .createServlet()
+                .servletName(SERVLET_NAME)
+                .servletClass(DescriptorComplementsAnnotationsServlet.class.getName()).up()
+                .createServletMapping()
+                .servletName(SERVLET_NAME)
+                .urlPattern("/" + TEST_NAME).up();
+
+        WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
+                .addClass(DescriptorComplementsAnnotationsTest.class)
+                .addClass(DescriptorComplementsAnnotationsServlet.class)
+                .addClass(Bean.class)
+                .addClass(FirstBean.class)
+                .addClass(SecondBean.class)
+                .addClass(Runner.class)
+                .addAsLibraries(JarLocation.jarLocation(Test.class))
+                .addAsWebInfResource(new ClassLoaderAsset(CONTENT_LOCATION_EJB_JAR_XML), RESOURCE_EJB_JAR_XML)
+                .setWebXML(new StringAsset(descriptor.exportAsString()));
+
+        return archive;
+    }
+
+    private void validateTest(String testName) throws IOException {
+        final String expectedOutput = testName + "=true";
+
+        try (InputStream is = new URL(url.toExternalForm() + TEST_NAME + "?test=" + testName).openStream()) {
+            final ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+            int bytesRead;
+            byte[] buffer = new byte[8192];
+            while ((bytesRead = is.read(buffer)) > -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+
+            final String output = new String(os.toByteArray(), "UTF-8");
+            assertNotNull("Response shouldn't be null", output);
+            assertTrue("Output should contain: " + expectedOutput
+                    + "\nActual output:\n" + output, output.contains(expectedOutput));
+        }
+    }
+
+    @Test
+    public void verifyFirstBeanInjection() throws IOException {
+        validateTest("verifyFirstBeanInjection");
+    }
+
+    @Test
+    public void verifySecondBeanInjection() throws IOException {
+        validateTest("verifySecondBeanInjection");
+    }
+
+    @Test
+    public void verifyOverridenBeanInjection() throws IOException {
+        validateTest("verifyOverridenBeanInjection");
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/ce3b5359/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/FirstBean.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/FirstBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/FirstBean.java
new file mode 100644
index 0000000..b1c1d94
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/FirstBean.java
@@ -0,0 +1,28 @@
+/*
+ * 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.core.ejb.ejbjar;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class FirstBean implements Bean {
+    @Override
+    public String getName() {
+        return FirstBean.class.getName();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/ce3b5359/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/SecondBean.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/SecondBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/SecondBean.java
new file mode 100644
index 0000000..955cef6
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/core/ejb/ejbjar/SecondBean.java
@@ -0,0 +1,28 @@
+/*
+ * 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.core.ejb.ejbjar;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class SecondBean implements Bean {
+    @Override
+    public String getName() {
+        return SecondBean.class.getName();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/ce3b5359/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/core/ejb/descriptor_complements_annotations.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/core/ejb/descriptor_complements_annotations.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/core/ejb/descriptor_complements_annotations.xml
new file mode 100644
index 0000000..fb84f98
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/core/ejb/descriptor_complements_annotations.xml
@@ -0,0 +1,67 @@
+<?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>
+        <session>
+            <ejb-name>FirstBean</ejb-name>
+            <ejb-local-ref>
+                <ejb-ref-name>ejb/first</ejb-ref-name>
+                <ejb-ref-type>Session</ejb-ref-type>
+                <local>org.apache.openejb.arquillian.tests.core.ejb.ejbjar.Bean</local>
+                <injection-target>
+                    <injection-target-class>
+                        org.apache.openejb.arquillian.tests.core.ejb.ejbjar.DescriptorComplementsAnnotationsServlet
+                    </injection-target-class>
+                    <injection-target-name>first</injection-target-name>
+                </injection-target>
+            </ejb-local-ref>
+        </session>
+
+        <session>
+            <ejb-name>SecondBean</ejb-name>
+            <ejb-local-ref>
+                <ejb-ref-name>ejb/second</ejb-ref-name>
+                <ejb-ref-type>Session</ejb-ref-type>
+                <local>org.apache.openejb.arquillian.tests.core.ejb.ejbjar.Bean</local>
+                <injection-target>
+                    <injection-target-class>
+                        org.apache.openejb.arquillian.tests.core.ejb.ejbjar.DescriptorComplementsAnnotationsServlet
+                    </injection-target-class>
+                    <injection-target-name>second</injection-target-name>
+                </injection-target>
+            </ejb-local-ref>
+            <ejb-local-ref>
+                <ejb-ref-name>ejb/override</ejb-ref-name>
+                <ejb-ref-type>Session</ejb-ref-type>
+                <ejb-link>SecondBean</ejb-link>
+                <injection-target>
+                    <injection-target-class>
+                        org.apache.openejb.arquillian.tests.core.ejb.ejbjar.DescriptorComplementsAnnotationsServlet
+                    </injection-target-class>
+                    <injection-target-name>override</injection-target-name>
+                </injection-target>
+            </ejb-local-ref>
+        </session>
+    </enterprise-beans>
+</ejb-jar>

http://git-wip-us.apache.org/repos/asf/tomee/blob/ce3b5359/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
index d6b7d24..9df12fe 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
@@ -4255,6 +4255,9 @@ public class AnnotationDeployer implements DynamicDeployer {
                 if (ref.getMappedName() == null) {
                     ref.setMappedName(ejbLocalRef.getMappedName());
                 }
+                if(ref.getEjbLink() == null){
+                    ref.setEjbLink(ejbLocalRef.getEjbLink());
+                }
                 ref.getInjectionTarget().addAll(ejbLocalRef.getInjectionTarget());
                 return;
             }