openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1694733 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents: ./ ExtensionEventTest.java ShouldNotCatchExtensionEventBean.java
Date Fri, 07 Aug 2015 19:29:19 GMT
Author: struberg
Date: Fri Aug  7 19:29:19 2015
New Revision: 1694733

URL: http://svn.apache.org/r1694733
Log:
OWB-935 add unit test 

A standard bean observing CDI Extension event which should not get triggered.
Extension events can only get observed in Extensions


Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ExtensionEventTest.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ShouldNotCatchExtensionEventBean.java
  (with props)

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ExtensionEventTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ExtensionEventTest.java?rev=1694733&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ExtensionEventTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ExtensionEventTest.java
Fri Aug  7 19:29:19 2015
@@ -0,0 +1,37 @@
+/*
+ * 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.webbeans.test.events.extensionevents;
+
+import junit.framework.Assert;
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+/**
+ * Test observing extension events and cases where
+ * standard beans shall _not_ be able to observe them.
+ */
+public class ExtensionEventTest extends AbstractUnitTest
+{
+
+    @Test
+    public void testNormalBeanDoesntGetExtensionEvents() throws Exception
+    {
+        ShouldNotCatchExtensionEventBean.extensionEventInvoked = false;
+        startContainer(ShouldNotCatchExtensionEventBean.class);
+        Assert.assertFalse(ShouldNotCatchExtensionEventBean.extensionEventInvoked);
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ExtensionEventTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ShouldNotCatchExtensionEventBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ShouldNotCatchExtensionEventBean.java?rev=1694733&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ShouldNotCatchExtensionEventBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ShouldNotCatchExtensionEventBean.java
Fri Aug  7 19:29:19 2015
@@ -0,0 +1,44 @@
+/*
+ * 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.webbeans.test.events.extensionevents;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+
+
+/**
+ * This is a standard CDI bean which Observes Object.class.
+ * This should not result in getting any
+ */
+@ApplicationScoped
+public class ShouldNotCatchExtensionEventBean
+{
+
+    public static boolean extensionEventInvoked = false;
+
+    public void catchItAll(@Observes Object all)
+    {
+        if (all instanceof AfterBeanDiscovery || all instanceof AfterDeploymentValidation
+            || all instanceof ProcessObserverMethod)
+        {
+            extensionEventInvoked = true;
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/extensionevents/ShouldNotCatchExtensionEventBean.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message