[webbeans-commits] Webbeans SVN: r2369 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests: event/register/fires1 and 2 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Apr 9 14:57:50 EDT 2009


Author: dallen6
Date: 2009-04-09 14:57:50 -0400 (Thu, 09 Apr 2009)
New Revision: 2369

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyed.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyedLiteral.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluse.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluseProducer.java
Modified:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/BlueFacedParrotFinch.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/observer1/ConsumerNotifiedForEventTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/ProducerFieldLifecycleTest.java
Log:
Fixes for implicit event beans and related tests.

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java	2009-04-09 18:57:34 UTC (rev 2368)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -252,13 +252,6 @@
       assert getCurrentManager().getClass().getDeclaredMethod("resolveObservers", Object.class, Annotation[].class) != null;
    }
 
-   @Test(groups = { "events", "stub" })
-   @SpecAssertions( { @SpecAssertion(section = "7.4", id = "a") })
-   public void testObserverNotificationCallsResolveObservers()
-   {
-      assert false;
-   }
-
    @Test(groups = { "events" })
    @SpecAssertions( { @SpecAssertion(section = "7.5", id = "a"), @SpecAssertion(section = "7.5.2", id = "a")} )
    public void testObserverMethodAutomaticallyRegistered()
@@ -345,15 +338,20 @@
     * Manager.getInstanceToInject() to each of the other parameters.
     */
    @Test(groups = { "events" })
-   @SpecAssertions( { @SpecAssertion(section = "7.5.4", id = "a"), @SpecAssertion(section = "7.5.8", id = "j") })
+   @SpecAssertions( { 
+      @SpecAssertion(section = "7.5.4", id = "a"), 
+      @SpecAssertion(section = "7.5.8", id = "j") 
+   })
    public void testObserverMethodReceivesInjectionsOnNonObservesParameters()
    {
-      Set<Bean<Object>> beans = getCurrentManager().resolveByType(Object.class);
-      assert beans != null;
+      getCurrentManager().fireEvent("string event");
    }
 
    @Test(groups = { "events" })
-   @SpecAssertions( { @SpecAssertion(section = "7.5.5", id = "a"), @SpecAssertion(section = "7.5.5", id = "b")} )
+   @SpecAssertions( { 
+      @SpecAssertion(section = "7.5.5", id = "a"), 
+      @SpecAssertion(section = "7.5.5", id = "b")
+   } )
    public void testConditionalObserver() throws Exception
    {
       RecluseSpider.notified = false;

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/BlueFacedParrotFinch.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/BlueFacedParrotFinch.java	2009-04-09 18:57:34 UTC (rev 2368)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/BlueFacedParrotFinch.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -7,25 +7,41 @@
 class BlueFacedParrotFinch
 {
    @Fires
-   private Event<String> simpleEvent;
+   protected Event<Integer> simpleEvent;
+   
+   @Fires @Tame
+   protected Event<String> simpleStringEvent;
+   
+   public static boolean simpleStringEventObserved = false;
 
    public void methodThatFiresEvent()
    {
-      simpleEvent.fire("An event");
+      simpleEvent.fire(new Integer(42));
    }
 
    public void methodThatRegistersObserver()
    {
-      simpleEvent.observe(new Observer<String>()
+      simpleEvent.observe(new Observer<Integer>()
       {
-         public void notify(String event)
+         public void notify(Integer event)
          {
          }
       });
    }
 
-   public Event<String> getSimpleEvent()
+   public void methodThatFiresAnotherEvent()
    {
-      return simpleEvent;
+      simpleStringEvent.fire("the answer to life", new OneEyedLiteral());
    }
+
+   public void methodThatRegistersAnotherObserver()
+   {
+      simpleStringEvent.observe(new Observer<String>()
+      {
+         public void notify(String event)
+         {
+            BlueFacedParrotFinch.simpleStringEventObserved = true;
+         }
+      });
+   }
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java	2009-04-09 18:57:34 UTC (rev 2368)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -38,7 +38,7 @@
 @BeansXml("beans.xml")
 public class ImplicitEventBeanTest extends AbstractJSR299Test
 {
-   @Test(groups = { "events", "ri-broken" })
+   @Test(groups = { "events" })
    @SpecAssertions( { 
       @SpecAssertion(section = "7.6", id = "b"), 
       @SpecAssertion(section = "7.6", id = "c"), 
@@ -58,7 +58,7 @@
             BlueFacedParrotFinch bean = getCurrentManager().getInstanceByType(BlueFacedParrotFinch.class);
             bean.methodThatRegistersObserver();
 
-            Set<Observer<String>> observers = getCurrentManager().resolveObservers("String type event");
+            Set<Observer<Integer>> observers = getCurrentManager().resolveObservers(new Integer(78));
             assert observers.size() == 1;
          }
 
@@ -69,6 +69,20 @@
          @Override
          protected void execute() throws Exception
          {
+            BlueFacedParrotFinch.simpleStringEventObserved = false;
+            BlueFacedParrotFinch bean = getCurrentManager().getInstanceByType(BlueFacedParrotFinch.class);
+            bean.methodThatRegistersAnotherObserver();
+            bean.methodThatFiresAnotherEvent();
+            assert BlueFacedParrotFinch.simpleStringEventObserved;
+         }
+
+      }.run();
+      new RunInDependentContext()
+      {
+
+         @Override
+         protected void execute() throws Exception
+         {
             StarFinch starFinch = getCurrentManager().getInstanceByType(StarFinch.class);
             FinchKeeper birdKeeper = getCurrentManager().getInstanceByType(FinchKeeper.class);
             BirdCage birdCage = getCurrentManager().getInstanceByType(BirdCage.class);

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyed.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyed.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyed.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.event.register.fires1;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+ at interface OneEyed
+{
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyed.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyedLiteral.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyedLiteral.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyedLiteral.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.event.register.fires1;
+
+import javax.inject.AnnotationLiteral;
+
+public class OneEyedLiteral extends AnnotationLiteral<OneEyed> implements OneEyed
+{
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/OneEyedLiteral.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/observer1/ConsumerNotifiedForEventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/observer1/ConsumerNotifiedForEventTest.java	2009-04-09 18:57:34 UTC (rev 2368)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/observer1/ConsumerNotifiedForEventTest.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -1,5 +1,7 @@
 package org.jboss.jsr299.tck.tests.event.register.observer1;
 
+import java.lang.annotation.Annotation;
+
 import javax.event.Observer;
 
 import org.hibernate.tck.annotations.SpecAssertion;
@@ -26,20 +28,39 @@
    }
 
    @Test(groups = { "events" })
-   @SpecAssertions( { @SpecAssertion(section = "7.1", id = "h"), @SpecAssertion(section = "7.3", id = "d"), @SpecAssertion(section = "7.4", id = "b") })
+   @SpecAssertions( { 
+      @SpecAssertion(section = "7.1", id = "h"), 
+      @SpecAssertion(section = "7.3", id = "d"), 
+      @SpecAssertion(section = "7.4", id = "b")
+   })
    public void testConsumerNotifiedWhenEventTypeAndAllBindingsMatch()
    {
+      Annotation roleBinding = new RoleBinding("Admin");
       AnObserver observer1 = new AnObserver();
       AnObserver observer2 = new AnObserver();
       getCurrentManager().addObserver(observer1, AnEventType.class);
-      getCurrentManager().addObserver(observer2, AnEventType.class);
+      getCurrentManager().addObserver(observer2, AnEventType.class, roleBinding);
 
       // Fire an event that will be delivered to the two above observers
       AnEventType anEvent = new AnEventType();
-      getCurrentManager().fireEvent(anEvent);
+      getCurrentManager().fireEvent(anEvent, roleBinding);
 
       assert observer1.wasNotified;
       assert observer2.wasNotified;
+      observer1.wasNotified = false;
+      observer2.wasNotified = false;
+      
+      // Fire an event that will be delivered to only one
+      getCurrentManager().fireEvent(anEvent);
+      assert observer1.wasNotified;
+      assert !observer2.wasNotified;
+      observer1.wasNotified = false;
+      observer2.wasNotified = false;
+      
+      // Also make sure the binding value is considered
+      getCurrentManager().fireEvent(anEvent, new RoleBinding("user"));
+      assert observer1.wasNotified;
+      assert !observer2.wasNotified;
    }
 
 

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluse.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluse.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluse.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.lifecycle;
+
+class BrownRecluse extends Spider
+{
+   public BrownRecluse(Integer numberOfEyes)
+   {
+      
+   }
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluse.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluseProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluseProducer.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluseProducer.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.lifecycle;
+
+import javax.inject.Produces;
+
+class BrownRecluseProducer
+{
+   @Produces
+   protected BrownRecluse spider = new BrownRecluse(5);
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/BrownRecluseProducer.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/ProducerFieldLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/ProducerFieldLifecycleTest.java	2009-04-09 18:57:34 UTC (rev 2368)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/lifecycle/ProducerFieldLifecycleTest.java	2009-04-09 18:57:50 UTC (rev 2369)
@@ -21,6 +21,23 @@
 
    @Test(groups = { "producerField" })
    @SpecAssertions({
+      @SpecAssertion(section = "6.8", id = "b")
+   })
+   public void testProducerFieldNotAnotherBean()
+   {
+      new RunInDependentContext()
+      {
+
+         @Override
+         protected void execute() throws Exception
+         {
+            assert getCurrentManager().getInstanceByType(BrownRecluse.class) != null;
+         }
+      };
+   }
+
+   @Test(groups = { "producerField" })
+   @SpecAssertions({
       @SpecAssertion(section = "6.8", id = "h"),
       @SpecAssertion(section = "3.5", id = "b")
    })




More information about the weld-commits mailing list