This is an automated email from the ASF dual-hosted git repository.

arne pushed a commit to branch OWB-1393
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git

commit 0cf994045bb2d055d2146b01e92d4fbb9a164c87
Author: arne <[email protected]>
AuthorDate: Sun Oct 10 12:23:52 2021 +0200

    OWB-1393: Add test case
---
 .../portable/events/ProcessObserverMethodTest.java | 60 ++++++++++++++++++++++
 .../extensions/ProcessObserverMethodExtension.java | 42 +++++++++++++++
 2 files changed, 102 insertions(+)

diff --git 
a/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/ProcessObserverMethodTest.java
 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/ProcessObserverMethodTest.java
new file mode 100644
index 0000000..e12e09a
--- /dev/null
+++ 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/ProcessObserverMethodTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.portable.events;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.event.Observes;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import 
org.apache.webbeans.test.portable.events.extensions.ProcessObserverMethodExtension;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class ProcessObserverMethodTest extends AbstractUnitTest
+{
+
+    @Test
+    @Ignore
+    public void testProcessObserverMethodIsInvoked()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(MyObserver.class);
+
+        addExtension(new ProcessObserverMethodExtension.BrokenExtension());  
+        addExtension(new ProcessObserverMethodExtension());
+        
+        startContainer(beanClasses, beanXmls);
+        
+        
Assert.assertTrue(ProcessObserverMethodExtension.processObserverMethodInvoked);
+        
+        shutDownContainer();
+    }
+
+    public static class MyObserver {
+        public void observe(@Observes Context context) {
+            // just any observer
+        }
+    }
+}
diff --git 
a/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/ProcessObserverMethodExtension.java
 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/ProcessObserverMethodExtension.java
new file mode 100644
index 0000000..c0c7eb3
--- /dev/null
+++ 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/ProcessObserverMethodExtension.java
@@ -0,0 +1,42 @@
+/*
+ * 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.portable.events.extensions;
+
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+
+public class ProcessObserverMethodExtension implements Extension
+{
+    public static boolean processObserverMethodInvoked = false;
+    
+    public void processObserverMethod(@Observes ProcessObserverMethod<?, ?> 
event)
+    {
+        processObserverMethodInvoked = true;
+    }
+
+    public static class BrokenExtension implements Extension
+    {
+        public void listenToNonLifecycleEvent(@Observes Context context)
+        {
+            // do nothing
+        }
+    }
+}

Reply via email to