Repository: tomee
Updated Branches:
  refs/heads/develop ebaf1b0f0 -> 55d733209


ensuring all container event are not propagated upper the when sent for a 
webapp of an ear


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

Branch: refs/heads/develop
Commit: 55d7332097e9ce9e0bd984744c44955247c9dfd0
Parents: ebaf1b0
Author: Romain Manni-Bucau <[email protected]>
Authored: Wed Feb 11 15:23:11 2015 +0100
Committer: Romain Manni-Bucau <[email protected]>
Committed: Wed Feb 11 15:23:11 2015 +0100

----------------------------------------------------------------------
 .../openejb/cdi/WebappBeanManagerTest.java      | 90 ++++++++++++++++++++
 1 file changed, 90 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/55d73320/container/openejb-core/src/test/java/org/apache/openejb/cdi/WebappBeanManagerTest.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/test/java/org/apache/openejb/cdi/WebappBeanManagerTest.java
 
b/container/openejb-core/src/test/java/org/apache/openejb/cdi/WebappBeanManagerTest.java
new file mode 100644
index 0000000..3c51da6
--- /dev/null
+++ 
b/container/openejb-core/src/test/java/org/apache/openejb/cdi/WebappBeanManagerTest.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.cdi;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl;
+import 
org.apache.webbeans.portable.events.discovery.AfterDeploymentValidationImpl;
+import org.apache.webbeans.portable.events.discovery.BeforeBeanDiscoveryImpl;
+import org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl;
+import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
+import org.apache.webbeans.portable.events.generics.GProcessBean;
+import org.apache.webbeans.portable.events.generics.GProcessInjectionTarget;
+import org.apache.webbeans.portable.events.generics.GProcessProducer;
+import org.apache.webbeans.portable.events.generics.GProcessProducerField;
+import org.apache.webbeans.portable.events.generics.GProcessProducerMethod;
+import org.apache.webbeans.portable.events.generics.GProcessSessionBean;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.Properties;
+
+import static org.junit.Assert.fail;
+
+public class WebappBeanManagerTest {
+    @Test
+    public void containerEventsShouldntGoUp() {
+        final WebappWebBeansContext ctx = new 
WebappWebBeansContext(Collections.<Class<?>, Object>emptyMap(), new 
Properties(), new WebBeansContext());
+        final WebappBeanManager wbm = new WebappBeanManager(ctx) {
+            @Override
+            public BeanManagerImpl getParentBm() {
+                throw new IllegalStateException("shouldn't be called");
+            }
+        };
+        wbm.fireEvent(new GProcessProducer(null, null), true);
+        wbm.fireEvent(new GProcessProducerField(null, null, null), true);
+        wbm.fireEvent(new GProcessProducerMethod(null, null, null), true);
+        wbm.fireEvent(new GProcessInjectionTarget(null, null), true);
+        wbm.fireEvent(new GProcessBean(null, null), true);
+        wbm.fireEvent(new GProcessAnnotatedType(null), true);
+        wbm.fireEvent(new GProcessSessionBean(null, null, null, null), true);
+        wbm.fireEvent(new AfterBeanDiscoveryImpl(ctx), true);
+        wbm.fireEvent(new AfterDeploymentValidationImpl(wbm), true);
+        wbm.fireEvent(new BeforeBeanDiscoveryImpl(ctx), true);
+        wbm.fireEvent(new BeforeShutdownImpl(), true);
+    }
+
+    @Test
+    public void otherEventsShouldGoUp() {
+        final WebappWebBeansContext ctx = new 
WebappWebBeansContext(Collections.<Class<?>, Object>emptyMap(), new 
Properties(), new WebBeansContext());
+        final WebappBeanManager wbm = new WebappBeanManager(ctx) {
+            @Override
+            public BeanManagerImpl getParentBm() {
+                throw new IllegalStateException("shouldn't be called");
+            }
+        };
+        try {
+            wbm.fireEvent(new Object());
+            fail();
+        } catch (final IllegalStateException ise) {
+            // ok
+        }
+        try {
+            wbm.fireEvent("yeah");
+            fail();
+        } catch (final IllegalStateException ise) {
+            // ok
+        }
+        try {
+            wbm.fireEvent(this);
+            fail();
+        } catch (final IllegalStateException ise) {
+            // ok
+        }
+    }
+}

Reply via email to