Repository: tomee
Updated Branches:
  refs/heads/master 5359f312b -> ba30d45dc


more validation for ejb specialization + remote interfaces are not part of the 
ejb api (for cdi) + better cdi tck state clean up using arquillian API


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

Branch: refs/heads/master
Commit: ba30d45dcca686ba2c3a28a8d9314ffacfb3300b
Parents: 5359f31
Author: Romain Manni-Bucau <[email protected]>
Authored: Fri Mar 13 18:59:58 2015 +0100
Committer: Romain Manni-Bucau <[email protected]>
Committed: Fri Mar 13 18:59:58 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/openejb/cdi/CdiEjbBean.java |  3 +-
 .../java/org/apache/openejb/cdi/CdiPlugin.java  | 15 +++++++--
 tck/cdi-embedded/pom.xml                        |  1 -
 .../ArquillianTestCleanUpExtension.java         | 35 ++++++++++++++++++++
 .../tck/cdi/embedded/CleanUpAssembler.java      | 34 -------------------
 ....jboss.arquillian.core.spi.LoadableExtension |  1 +
 tck/cdi-embedded/src/test/resources/failing.xml |  2 +-
 7 files changed, 52 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ba30d45d/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java 
b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
index b3a1702..0480090 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
@@ -36,7 +36,6 @@ import 
org.apache.webbeans.intercept.InterceptorResolutionService;
 import org.apache.webbeans.portable.InjectionTargetImpl;
 import org.apache.webbeans.util.GenericsUtil;
 
-import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
@@ -363,12 +362,14 @@ public class CdiEjbBean<T> extends BaseEjbBean<T> 
implements InterceptedMarker,
                 }
             }
 
+            /* not in EJB types - 3.2.2 of cdi 1.2
             final List<Class> clRemote = 
beanContext.getBusinessRemoteInterfaces();
             if (clRemote != null && !clRemote.isEmpty()) {
                 for (final Class<?> c : clRemote) {
                     ejbTypes.add(c); // parentInterfaces(c), but is it useful 
in practise?
                 }
             }
+            */
 
             ejbTypes.add(Object.class);
         }

http://git-wip-us.apache.org/repos/asf/tomee/blob/ba30d45d/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java 
b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
index a06ea9b..8dab787 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
@@ -49,6 +49,7 @@ import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansJavaEEPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansWebPlugin;
+import org.apache.webbeans.util.GenericsUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 import javax.enterprise.context.ApplicationScoped;
@@ -300,8 +301,18 @@ public class CdiPlugin extends AbstractOwbPlugin 
implements OpenWebBeansJavaEEPl
     public <T> Bean<T> defineSessionBean(final Class<T> clazz, final 
BeanAttributes<T> attributes, final AnnotatedType<T> annotatedType) {
         final BeanContext bc = findBeanContext(webBeansContext, clazz);
         final Class<?> superClass = bc.getManagedClass().getSuperclass();
-        if (superClass != Object.class && !isSessionBean(superClass) && 
annotatedType.isAnnotationPresent(Specializes.class)) {
-            throw new DefinitionException("You can only specialize another 
EJB: " + clazz);
+        if (annotatedType.isAnnotationPresent(Specializes.class)) {
+            if (superClass != Object.class && !isSessionBean(superClass)) {
+                throw new DefinitionException("You can only specialize another 
EJB: " + clazz);
+            }
+            final BeanContext parentBc = findBeanContext(webBeansContext, 
superClass);
+            final List<Class> businessLocalInterfaces = new 
ArrayList<>(parentBc.getBusinessLocalInterfaces());
+            for (final Class<?> api : bc.getBusinessLocalInterfaces()) {
+                
businessLocalInterfaces.removeAll(GenericsUtil.getTypeClosure(api));
+            }
+            if (!businessLocalInterfaces.isEmpty()) {
+                throw new DefinitionException("You can only specialize another 
EJB with at least the same API: " + clazz);
+            }
         }
         final CdiEjbBean<T> bean = new OpenEJBBeanBuilder<T>(bc, 
webBeansContext, annotatedType, attributes).createBean(clazz, 
!annotatedType.isAnnotationPresent(Vetoed.class));
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/ba30d45d/tck/cdi-embedded/pom.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/pom.xml b/tck/cdi-embedded/pom.xml
index 8ee76d9..e2c9e08 100644
--- a/tck/cdi-embedded/pom.xml
+++ b/tck/cdi-embedded/pom.xml
@@ -203,7 +203,6 @@
             
<openejb.cdi.producer.interception>false</openejb.cdi.producer.interception>
             
<openejb.cdi.filter.classloader>false</openejb.cdi.filter.classloader>
 
-            
<openejb.assembler>org.apache.openejb.tck.cdi.embedded.CleanUpAssembler</openejb.assembler>
             <openejb.jul.forceReload>true</openejb.jul.forceReload>
             
<openejb.strict.interface.declaration>true</openejb.strict.interface.declaration>
             <openejb.http.mock-request>true</openejb.http.mock-request>

http://git-wip-us.apache.org/repos/asf/tomee/blob/ba30d45d/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ArquillianTestCleanUpExtension.java
----------------------------------------------------------------------
diff --git 
a/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ArquillianTestCleanUpExtension.java
 
b/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ArquillianTestCleanUpExtension.java
new file mode 100644
index 0000000..b0fda02
--- /dev/null
+++ 
b/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ArquillianTestCleanUpExtension.java
@@ -0,0 +1,35 @@
+/*
+ * 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.tck.cdi.embedded;
+
+import org.jboss.arquillian.core.api.annotation.Observes;
+import org.jboss.arquillian.core.spi.LoadableExtension;
+import org.jboss.arquillian.test.spi.event.suite.AfterClass;
+import org.jboss.cdi.tck.util.ActionSequence;
+
+public class ArquillianTestCleanUpExtension implements LoadableExtension {
+    @Override
+    public void register(final ExtensionBuilder extensionBuilder) {
+        extensionBuilder.observer(CleanUpObserver.class);
+    }
+
+    public static class CleanUpObserver {
+        public void cleanup(@Observes final AfterClass ignored) {
+            ActionSequence.reset(); // avoids to leak between tests, works in 
war cause of classloading but not in embedded mode
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/ba30d45d/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
----------------------------------------------------------------------
diff --git 
a/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
 
b/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
deleted file mode 100644
index c31bd36..0000000
--- 
a/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.tck.cdi.embedded;
-
-import org.apache.openejb.UndeployException;
-import org.apache.openejb.assembler.classic.AppInfo;
-import org.apache.openejb.assembler.classic.Assembler;
-import org.apache.openejb.loader.SystemInstance;
-import org.apache.openejb.spi.ContainerSystem;
-import org.jboss.cdi.tck.util.ActionSequence;
-
-public class CleanUpAssembler extends Assembler {
-    @Override
-    public void destroyApplication(final AppInfo appInfo) throws 
UndeployException {
-        super.destroyApplication(appInfo);
-        if 
(SystemInstance.get().getComponent(ContainerSystem.class).getAppContexts().isEmpty())
 {
-            ActionSequence.reset();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/tomee/blob/ba30d45d/tck/cdi-embedded/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
----------------------------------------------------------------------
diff --git 
a/tck/cdi-embedded/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
 
b/tck/cdi-embedded/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
new file mode 100644
index 0000000..e7e35c9
--- /dev/null
+++ 
b/tck/cdi-embedded/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
@@ -0,0 +1 @@
+org.apache.openejb.tck.cdi.embedded.ArquillianTestCleanUpExtension

http://git-wip-us.apache.org/repos/asf/tomee/blob/ba30d45d/tck/cdi-embedded/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/failing.xml 
b/tck/cdi-embedded/src/test/resources/failing.xml
index b0a5663..9cad804 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -31,7 +31,7 @@
     -Dopenejb.embedded.try-jsp=true
     -->
     <classes>
-      <class 
name="org.jboss.cdi.tck.tests.lookup.modules.SpecializedBeanInjectionNotAvailable02Test"
 />
+      <class 
name="org.jboss.cdi.tck.tests.inheritance.specialization.enterprise.EnterpriseBeanSpecializationTest"
 />
     </classes>
   </test>
 </suite>

Reply via email to