openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject svn commit: r1843927 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events: PortableEventTest.java beans/Cherry.java extensions/AppleExtension1.java
Date Mon, 15 Oct 2018 17:00:20 GMT
Author: tandraschko
Date: Mon Oct 15 17:00:20 2018
New Revision: 1843927

URL: http://svn.apache.org/viewvc?rev=1843927&view=rev
Log:
some unittests for lifecycle event observers

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/Cherry.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension1.java
      - copied, changed from r1843880, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java?rev=1843927&r1=1843926&r2=1843927&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java
Mon Oct 15 17:00:20 2018
@@ -25,7 +25,9 @@ import org.junit.Assert;
 
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.portable.events.beans.Apple;
+import org.apache.webbeans.test.portable.events.beans.Cherry;
 import org.apache.webbeans.test.portable.events.extensions.AppleExtension;
+import org.apache.webbeans.test.portable.events.extensions.AppleExtension1;
 import org.apache.webbeans.test.portable.events.extensions.MessageReceiverExtension;
 import org.apache.webbeans.test.portable.events.extensions.MessageSenderExtension;
 import org.apache.webbeans.test.portable.events.extensions.NotAppleExtnsion;
@@ -166,4 +168,67 @@ public class PortableEventTest extends A
         startContainer();
     }
 
+    
+    @Test
+    public void testNumberCallsNegative()
+    {
+        AppleExtension1.reset();
+        
+        Collection<String> beanXmls = new ArrayList<String>();
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        
+        addExtension(new AppleExtension1());        
+        startContainer(beanClasses, beanXmls);
+        
+        Assert.assertSame(AppleExtension1.CALLED, 0);
+        Assert.assertSame(AppleExtension1.TYPED_CALLED, 0);
+        Assert.assertSame(AppleExtension1.MANAGED_CALLED, 0);
+        Assert.assertSame(AppleExtension1.MANAGED_TYPED_CALLED, 0);
+        
+        shutDownContainer();
+    }
+    
+    @Test
+    public void testNumberCallsPositive()
+    {
+        AppleExtension1.reset();
+        
+        Collection<String> beanXmls = new ArrayList<String>();
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(Apple.class);
+        
+        addExtension(new AppleExtension1());        
+        startContainer(beanClasses, beanXmls);
+        
+        Assert.assertSame(AppleExtension1.CALLED, 1);
+        Assert.assertSame(AppleExtension1.TYPED_CALLED, 1);
+        Assert.assertSame(AppleExtension1.MANAGED_CALLED, 1);
+        Assert.assertSame(AppleExtension1.MANAGED_TYPED_CALLED, 1);
+        
+        shutDownContainer();
+    }
+    
+    @Test
+    public void testNumberCallsPositiveMultipleTypes()
+    {
+        AppleExtension1.reset();
+        
+        Collection<String> beanXmls = new ArrayList<String>();
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(Apple.class);
+        beanClasses.add(Cherry.class);
+        
+        addExtension(new AppleExtension1());        
+        startContainer(beanClasses, beanXmls);
+        
+        Assert.assertSame(AppleExtension1.CALLED, 2);
+        Assert.assertSame(AppleExtension1.TYPED_CALLED, 1);
+        Assert.assertSame(AppleExtension1.MANAGED_CALLED, 2);
+        Assert.assertSame(AppleExtension1.MANAGED_TYPED_CALLED, 1);
+        
+        shutDownContainer();
+    }
 }

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/Cherry.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/Cherry.java?rev=1843927&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/Cherry.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/Cherry.java
Mon Oct 15 17:00:20 2018
@@ -0,0 +1,24 @@
+/*
+ * 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.beans;
+
+public class Cherry
+{
+    
+}

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension1.java
(from r1843880, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension1.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension1.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension.java&r1=1843880&r2=1843927&rev=1843927&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/AppleExtension1.java
Mon Oct 15 17:00:20 2018
@@ -22,17 +22,44 @@ import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ProcessBean;
+import javax.enterprise.inject.spi.ProcessManagedBean;
 
 import org.apache.webbeans.test.portable.events.beans.Apple;
 
-
-public class AppleExtension implements Extension
+public class AppleExtension1 implements Extension
 {
-    public static String NAME = "";
+    public static int TYPED_CALLED = 0;
+    public static int CALLED = 0;
+    
+    public static int MANAGED_TYPED_CALLED = 0;
+    public static int MANAGED_CALLED = 0;
+    
+    public static void reset()
+    {
+        TYPED_CALLED = 0;
+        CALLED = 0;
+        MANAGED_TYPED_CALLED = 0;
+        MANAGED_CALLED = 0;
+    }
+    
+    public void typedProcessBean(@Observes ProcessBean<Apple> event)
+    {
+        TYPED_CALLED++;
+    }
+    
+    public void processBean(@Observes ProcessBean event)
+    {
+        CALLED++;
+    } 
+    
+    
+    public void typedProcessManagedBean(@Observes ProcessManagedBean<Apple> event)
+    {
+        MANAGED_TYPED_CALLED++;
+    }
     
-    public void observeProcessBean(@Observes ProcessBean<Apple> event)
+    public void processManagedBean(@Observes ProcessManagedBean event)
     {
-        Bean<Apple> bean = event.getBean();
-        NAME = bean.getName();
+        MANAGED_CALLED++;
     } 
 }



Mime
View raw message