openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelap...@apache.org
Subject svn commit: r1296549 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test: component/event/normal/ComponentWithObserves1.java component/event/normal/ComponentWithObserves7.java unittests/event/component/ObserversComponentTest.java
Date Sat, 03 Mar 2012 01:36:35 GMT
Author: kelapure
Date: Sat Mar  3 01:36:34 2012
New Revision: 1296549

URL: http://svn.apache.org/viewvc?rev=1296549&view=rev
Log:
OWB-628 Event injection does nott work in observer methods. Cleaning up tests.

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves7.java
      - copied, changed from r1296509, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java?rev=1296549&r1=1296548&r2=1296549&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
Sat Mar  3 01:36:34 2012
@@ -19,7 +19,6 @@
 package org.apache.webbeans.test.component.event.normal;
 
 import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Any;
 
@@ -38,10 +37,9 @@ public class ComponentWithObserves1
         this.userName = event.getUserName();
     }
 
-    private void afterLoggedInWithMember(@Observes @Check(type = "CHECK") LoggedInEvent event,
Event<String> myEvent)
+    private void afterLoggedInWithMember(@Observes @Check(type = "CHECK") LoggedInEvent event)
     {
         this.userNameWithMember = event.getUserName();
-        myEvent.fire("Rohit Kelapure");
     }
 
     public String getUserName()

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves7.java
(from r1296509, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves7.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves7.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java&r1=1296509&r2=1296549&rev=1296549&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves7.java
Sat Mar  3 01:36:34 2012
@@ -23,25 +23,24 @@ import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Any;
 
-import org.apache.webbeans.test.annotation.binding.Check;
 import org.apache.webbeans.test.event.LoggedInEvent;
 
 @RequestScoped
-public class ComponentWithObserves1
+public class ComponentWithObserves7
 {
     private String userName;
 
-    private String userNameWithMember;
+    private String eventString;
 
-    public void afterLoggedIn(@Observes @Any LoggedInEvent event)
+    public void afterLoggedIn(@Observes @Any LoggedInEvent event, Event<String> myEvent)
     {
         this.userName = event.getUserName();
+        myEvent.fire("Rohit_Kelapure");
     }
-
-    private void afterLoggedInWithMember(@Observes @Check(type = "CHECK") LoggedInEvent event,
Event<String> myEvent)
+   
+    public void watchEvent(@Observes String myEventString)
     {
-        this.userNameWithMember = event.getUserName();
-        myEvent.fire("Rohit Kelapure");
+        this.eventString = myEventString;
     }
 
     public String getUserName()
@@ -49,12 +48,9 @@ public class ComponentWithObserves1
         return this.userName;
     }
 
-    /**
-     * @return the userNameWithMember
-     */
-    public String getUserNameWithMember()
+    public String getEventString()
     {
-        return userNameWithMember;
+        return eventString;
     }
 
-}
+}
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java?rev=1296549&r1=1296548&r2=1296549&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
Sat Mar  3 01:36:34 2012
@@ -41,6 +41,7 @@ import org.apache.webbeans.test.componen
 import org.apache.webbeans.test.component.event.normal.ComponentWithObserves4;
 import org.apache.webbeans.test.component.event.normal.ComponentWithObserves5;
 import org.apache.webbeans.test.component.event.normal.ComponentWithObserves6;
+import org.apache.webbeans.test.component.event.normal.ComponentWithObserves7;
 import org.apache.webbeans.test.component.event.normal.TransactionalInterceptor;
 import org.apache.webbeans.test.event.LoggedInEvent;
 import org.junit.Before;
@@ -258,5 +259,26 @@ public class ObserversComponentTest exte
         Assert.assertEquals("ADMIN", instance.getUser());
 
     }
+    
+    @Test
+    public void testObservesWithEventInjection()
+    {
+        clear();
+
+        getManager().addBean(WebBeansContext.getInstance().getWebBeansUtil().getEventBean());
+
+        AbstractOwbBean<ComponentWithObserves7> component = defineManagedBean(ComponentWithObserves7.class);
+        AbstractOwbBean<ComponentWithObservable1> componentObservable = defineManagedBean(ComponentWithObservable1.class);
 
+        WebBeansContext.getInstance().getContextFactory().initRequestContext(null);
+
+        ComponentWithObserves7 instance = getManager().getInstance(component);
+        ComponentWithObservable1 observable = getManager().getInstance(componentObservable);
+
+        observable.afterLoggedIn();
+
+        Assert.assertEquals("Gurkan", instance.getUserName());
+        Assert.assertEquals("Rohit_Kelapure", instance.getEventString());
+    }    
+    
 }



Mime
View raw message