[webbeans-commits] Webbeans SVN: r3287 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event: fires and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Jul 27 15:29:58 EDT 2009


Author: dan.j.allen
Date: 2009-07-27 15:29:57 -0400 (Mon, 27 Jul 2009)
New Revision: 3287

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DoggiePoints.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Praise.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TamingCommand.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/DogWhisperer.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/DoggiePoints.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Praise.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Role.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Tame.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/TamingCommand.java
Modified:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DogWhisperer.java
   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/LargeDog.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MagicString.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MultiBindingEvent.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ShowDog.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SmallDog.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Spitz.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SweeWaxbill.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TransactionalObservers.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Housekeeping.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/MiniBar.java
Log:
migrate fire-related event tests from EventTest to FireEventTest

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DogWhisperer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DogWhisperer.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DogWhisperer.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -5,10 +5,17 @@
 
 class DogWhisperer
 {
-   private @Any Event<MultiBindingEvent> event;
+   @Any @Tame @Role("Admin") Event<TamingCommand> tamingEvent;
    
+   @Any Event<Praise> praiseEvent;
+   
    public void issueTamingCommand()
    {
-      event.select(new TameAnnotationLiteral(), new RoleBinding("Admin")).fire(new MultiBindingEvent());
+      tamingEvent.fire(new TamingCommand());
    }
+   
+   public void givePraise()
+   {
+      praiseEvent.fire(new Praise());
+   }
 }

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DoggiePoints.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DoggiePoints.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DoggiePoints.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,38 @@
+package org.jboss.jsr299.tck.tests.event;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+ at RequestScoped class DoggiePoints
+{
+   private int numPraiseReceived;
+   
+   private int numTamed;
+   
+   public void praiseReceived(@Observes @Any Praise praise)
+   {
+      numPraiseReceived++;
+   }
+   
+   public void tamed(@Observes @Tame @Role("Admin") TamingCommand tamed)
+   {
+      numTamed++;
+   }
+   
+   public int getNumPraiseReceived()
+   {
+      return numPraiseReceived;
+   }
+   
+   public int getNumTamed()
+   {
+      return numTamed;
+   }
+   
+   public void reset()
+   {
+      numPraiseReceived = 0;
+      numTamed = 0;
+   }
+}

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-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -6,16 +6,14 @@
 
 import javax.enterprise.event.Notify;
 import javax.enterprise.event.TransactionPhase;
-import javax.enterprise.inject.AnnotationLiteral;
-import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.ObserverMethod;
 
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
-import org.jboss.test.audit.annotations.SpecVersion;
 import org.jboss.jsr299.tck.AbstractJSR299Test;
 import org.jboss.jsr299.tck.literals.AnyLiteral;
 import org.jboss.jsr299.tck.literals.CurrentLiteral;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.test.audit.annotations.SpecVersion;
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
 import org.testng.annotations.Test;
@@ -31,123 +29,12 @@
 @SpecVersion("20090625")
 public class EventTest extends AbstractJSR299Test
 {
-   private static final String FIRE_EVENT_METHOD_NAME = "fireEvent";
    private static final String RESOLVE_OBSERVERS_METHOD_NAME = "resolveObserverMethods";
-   
-   public static class AnEventType
-   {
-   }
 
-   public static class ATemplatedEventType<T>
-   {
-   }
+   // --------- Below this line are tests that need to be evaluated to determine if they need to be moved
 
-   /**
-    * An event binding type is a Java annotation defined as @Target({FIELD,
-    * PARAMETER}) ~or @Target({METHOD, FIELD, PARAMETER, TYPE}) and
-    * @Retention(RUNTIME)~. All event binding types must specify the
-    * @BindingType meta-annotation.
-    */
    @Test(groups = { "events" })
-   @SpecAssertion(section = "10.1", id = "d")
-   public void testEventBindingTypeTargetMostAndRuntime()
-   {
-      getCurrentManager().fireEvent("string event", new TameAnnotationLiteral());
-   }
-
-   /**
-    * An event binding type is a Java annotation defined as ~@Target({FIELD,
-    * PARAMETER}) or~ @Target({METHOD, FIELD, PARAMETER, TYPE}) ~and
-    * @Retention(RUNTIME)~. All event binding types must specify the
-    * @BindingType meta-annotation.
-    */
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "10.1", id = "e")
-   public void testEventBindingTypeTargetsFieldParameterAndRuntime()
-   {
-      getCurrentManager().fireEvent("string event", new RoleBinding("Admin"));
-   }
-
-   /**
-    * An event binding type is a Java annotation defined as ~@Target({FIELD,
-    * PARAMETER}) or @Target({METHOD, FIELD, PARAMETER, TYPE}) and
-    * ~@Retention(RUNTIME)
-    */
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class } )
-   @SpecAssertion(section = "10.1", id = "f")
-   public void testEventBindingTypeNotRuntime()
-   {
-      getCurrentManager().fireEvent("string event", new AnnotationLiteral<BindingTypeNotRuntime>(){});
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class } )
    @SpecAssertions({
-      @SpecAssertion(section = "10.1", id = "g"),
-      @SpecAssertion(section = "11.3.10", id = "e")
-   })
-   public void testManagerFireEventWithNonBindingAnnotationsFails()
-   {
-      getCurrentManager().fireEvent("string event", new AnnotationLiteral<NotABindingType>(){});
-   }
-
-   @Test(groups = { "events", "broken" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertions({
-      @SpecAssertion(section = "10.1", id = "aa"),
-      @SpecAssertion(section = "11.3.10", id = "c")
-   })
-   //TODO This test does not have a template variable nor is there a way to write that in Java
-   public void testManagerFireEventWithEventTypeParametersFails()
-   {
-      ATemplatedEventType<String> anEvent = new ATemplatedEventType<String>();
-      getCurrentManager().fireEvent(anEvent);
-   }
-
-//   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-//   @SpecAssertions({
-//      @SpecAssertion(section = "10.1", id = "aa"),
-//      @SpecAssertion(section = "11.3.10", id = "c")
-//   })
-   // The spec no longer prohibits wildcards
-   public void testBeanManagerFireEventWithEventTypeWildcardsFails()
-   {
-      ATemplatedEventType<?> anEventOnAnyType = new ATemplatedEventType<String>();
-      getCurrentManager().fireEvent(anEventOnAnyType);
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = "11.3.10", id = "d")
-   public void testDuplicateBindingsToFireEventFails() throws Exception
-   {
-      getCurrentManager().fireEvent("string event", new TameAnnotationLiteral(), new TameAnnotationLiteral());
-   }
-   
-   @Test(groups = { "events" })
-   @SpecAssertions({
-      @SpecAssertion(section = "11.3.10", id = "a"),
-      @SpecAssertion(section = "11.3.10", id = "b")
-   })
-   public void testBeanManagerInterfaceForFireEventMethod() throws Exception
-   {
-      assert BeanManager.class.getDeclaredMethod(FIRE_EVENT_METHOD_NAME, Object.class, Annotation[].class) != null;
-   }
-
-   /**
-    * The BeanManager interface provides a method for firing events:
-    */
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "11.3.10", id = "a")
-   public void testBeanManagerFireEvent()
-   {
-      // First a simple event with no bindings is fired
-      AnEventType anEvent = new AnEventType();
-      getCurrentManager().fireEvent(anEvent);
-
-      // Next an event with some event bindings is fired
-      getCurrentManager().fireEvent(anEvent, new RoleBinding("Admin"));
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertions({
       @SpecAssertion(section = "11.3.11", id = "a"),
       @SpecAssertion(section = "11.3.11", id = "b")
    })
@@ -336,25 +223,7 @@
       //TODO How can we assert that the exception was logged?
    }
 
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = "11.3.10", id = "d")
-   public void testDuplicateBindingsToFireFails()
-   {
-      SweeWaxbill bean = getInstanceByType(SweeWaxbill.class);
-      bean.methodThatFiresEvent();
-   }
 
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "10.3.1", id = "eda")
-   public void testEventFireFiresEvent()
-   {
-      BullTerrier.reset();
-      getInstanceByType(DogWhisperer.class).issueTamingCommand();
-      assert BullTerrier.isMultiBindingEventObserved();
-      assert BullTerrier.isSingleBindingEventObserved();
-      BullTerrier.reset();
-   }
-
    @Test(groups = { "events", "underInvestigation" })
    @SpecAssertion(section = "11.2.7", id = "review") // removed from spec?
    public void testObserverMethodCallsManagerAddObserverWithObserverObject()

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/LargeDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/LargeDog.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/LargeDog.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -1,6 +1,6 @@
 package org.jboss.jsr299.tck.tests.event;
 
-public class LargeDog
+class LargeDog
 {
 
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MagicString.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MagicString.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MagicString.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -1,6 +1,6 @@
 package org.jboss.jsr299.tck.tests.event;
 
-public class MagicString
+class MagicString
 {
    private static boolean equalsUsed = false;
    private final String   value;

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MultiBindingEvent.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MultiBindingEvent.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MultiBindingEvent.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -2,5 +2,4 @@
 
 class MultiBindingEvent
 {
-
 }

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Praise.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Praise.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Praise.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event;
+
+class Praise
+{
+}

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ShowDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ShowDog.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ShowDog.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -1,6 +1,6 @@
 package org.jboss.jsr299.tck.tests.event;
 
-public class ShowDog
+class ShowDog
 {
 
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SmallDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SmallDog.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SmallDog.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -1,6 +1,6 @@
 package org.jboss.jsr299.tck.tests.event;
 
-public class SmallDog
+class SmallDog
 {
 
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Spitz.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Spitz.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Spitz.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -4,10 +4,11 @@
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Named;
 
+public
 @Stateful
 @Tame
 @Named("Teddy")
-public class Spitz implements PomeranianInterface
+class Spitz implements PomeranianInterface
 {
    public void observeSimpleEvent(@Observes EJBEvent someEvent)
    {

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SweeWaxbill.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SweeWaxbill.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SweeWaxbill.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -5,10 +5,9 @@
 
 class SweeWaxbill
 {
-   @Any @Role("Admin")
-   private Event<String> simpleEvent;
+   private @Any @Role("Admin") Event<String> simpleEvent;
 
-   public void methodThatFiresEvent()
+   public void methodThatReselectsAndFiresEvent()
    {
       simpleEvent.select(new RoleBinding("Admin")).fire("string event");
    }

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TamingCommand.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TamingCommand.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TamingCommand.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event;
+
+class TamingCommand
+{
+}

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TransactionalObservers.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TransactionalObservers.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TransactionalObservers.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -1,13 +1,13 @@
 package org.jboss.jsr299.tck.tests.event;
 
-import static javax.enterprise.event.TransactionPhase.BEFORE_COMPLETION;
 import static javax.enterprise.event.TransactionPhase.AFTER_COMPLETION;
 import static javax.enterprise.event.TransactionPhase.AFTER_FAILURE;
 import static javax.enterprise.event.TransactionPhase.AFTER_SUCCESS;
+import static javax.enterprise.event.TransactionPhase.BEFORE_COMPLETION;
 
 import javax.enterprise.event.Observes;
 
-public class TransactionalObservers
+class TransactionalObservers
 {
    public void train(@Observes(during=BEFORE_COMPLETION) DisobedientDog dog)
    {

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/DogWhisperer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/DogWhisperer.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/DogWhisperer.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.event.fires;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+
+class DogWhisperer
+{
+   @Any @Tame @Role("Master") Event<TamingCommand> tamingEvent;
+   
+   @Any Event<Praise> praiseEvent;
+   
+   public void issueTamingCommand()
+   {
+      tamingEvent.fire(new TamingCommand());
+   }
+   
+   public void givePraise()
+   {
+      praiseEvent.fire(new Praise());
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/DoggiePoints.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/DoggiePoints.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/DoggiePoints.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,38 @@
+package org.jboss.jsr299.tck.tests.event.fires;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+ at RequestScoped class DoggiePoints
+{
+   private int numPraiseReceived;
+   
+   private int numTamed;
+   
+   public void praiseReceived(@Observes @Any Praise praise)
+   {
+      numPraiseReceived++;
+   }
+   
+   public void tamed(@Observes @Tame @Role("Master") TamingCommand tamed)
+   {
+      numTamed++;
+   }
+   
+   public int getNumPraiseReceived()
+   {
+      return numPraiseReceived;
+   }
+   
+   public int getNumTamed()
+   {
+      return numTamed;
+   }
+   
+   public void reset()
+   {
+      numPraiseReceived = 0;
+      numTamed = 0;
+   }
+}

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -1,5 +1,6 @@
 package org.jboss.jsr299.tck.tests.event.fires;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
@@ -10,13 +11,14 @@
 import javax.enterprise.event.Event;
 import javax.enterprise.inject.AnnotationLiteral;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
 
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.AnyLiteral;
 import org.jboss.test.audit.annotations.SpecAssertion;
 import org.jboss.test.audit.annotations.SpecAssertions;
 import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.AnyLiteral;
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.testng.annotations.Test;
 
@@ -30,6 +32,41 @@
 @SpecVersion("20090625")
 public class FireEventTest extends AbstractJSR299Test
 {
+   private static final String BEAN_MANAGER_FIRE_EVENT_METHOD_NAME = "fireEvent";
+   
+   @Test(groups = { "events" })
+   @SpecAssertions({
+      // These two assertions combine to create a testable assertion
+      @SpecAssertion(section = "11.3.10", id = "a"),
+      @SpecAssertion(section = "11.3.10", id = "b")
+   })
+   public void testBeanManagerInterfaceForFireEventMethod() throws Exception
+   {
+      assert BeanManager.class.getDeclaredMethod(BEAN_MANAGER_FIRE_EVENT_METHOD_NAME, Object.class, Annotation[].class) != null;
+   }
+   
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "11.3.10", id = "a")
+   public void testBeanManagerFireEvent()
+   {
+      Billing billing = getInstanceByType(Billing.class);
+      billing.reset();
+      MiniBar miniBar = new MiniBar();
+      miniBar.stockNoNotify();
+      getCurrentManager().fireEvent(miniBar);
+      assert billing.isActive();
+      Item chocolate = miniBar.getItemByName("Chocolate");
+      getCurrentManager().fireEvent(chocolate, new AnnotationLiteral<Lifted>() {});
+      assert billing.getCharge() == 5.00d;
+   }
+   
+   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
+   @SpecAssertion(section = "11.3.10", id = "d")
+   public void testDuplicateBindingsToFireEventFails() throws Exception
+   {
+      getCurrentManager().fireEvent(new Object(), new AnnotationLiteral<Lifted>() {}, new AnnotationLiteral<Lifted>() {});
+   }
+   
    /**
     * This test verifies that the {@link Event} object capable of firing
     * {@link Item} objects can be injected with the {@link @Any} binding type
@@ -199,6 +236,42 @@
       assert housekeeping.getItemsTainted().contains(water);
    }
    
+   @Test(groups = "events")
+   @SpecAssertion(section = "10.3.1", id = "ca")
+   public void testEventProvidesMethodForFiringEventsWithCombinationOfTypeAndBindings()
+   {
+      DoggiePoints points = getInstanceByType(DoggiePoints.class);
+      points.reset();
+      DogWhisperer master = getInstanceByType(DogWhisperer.class);
+      master.issueTamingCommand();
+      assert points.getNumTamed() == 1;
+      assert points.getNumPraiseReceived() == 0;
+      master.givePraise();
+      assert points.getNumTamed() == 1;
+      assert points.getNumPraiseReceived() == 1;
+   }
+   
+   @Test(groups = "events")
+   @SpecAssertion(section = "10.3.1", id = "eda")
+   public void testEventSelectedFiresAndObserversNotified()
+   {
+      Housekeeping houseKeeping = getInstanceByType(Housekeeping.class);
+      houseKeeping.reset();
+      MiniBar miniBar = getInstanceByType(MiniBar.class);
+      Item chocolate = new Item("Chocolate", 5.00d);
+      Item crackers = new Item("Crackers", 2.50d);
+
+      miniBar.getItemEvent().fire(chocolate);
+      assert houseKeeping.getItemActivity().size() == 1;
+      assert houseKeeping.getItemActivity().get(0) == chocolate;
+      
+      miniBar.getItemEvent().select(new AnnotationLiteral<Lifted>() {}).fire(crackers);
+      assert houseKeeping.getItemActivity().size() == 2;
+      assert houseKeeping.getItemActivity().get(1) == crackers;
+      assert houseKeeping.getItemsMissing().size() == 1;
+      assert houseKeeping.getItemsMissing().iterator().next() == crackers;
+   }
+   
    @Test(groups = {"events", "broken"}, expectedExceptions = IllegalArgumentException.class)
    @SpecAssertion(section = "10.3.1", id = "f")
    //TODO There does not seem to be any way to write code that compiles and tests this assertion

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Housekeeping.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Housekeeping.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Housekeeping.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -1,6 +1,8 @@
 package org.jboss.jsr299.tck.tests.event.fires;
 
+import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import javax.enterprise.context.RequestScoped;
@@ -13,6 +15,8 @@
    
    private Set<Item> itemsMissing = new HashSet<Item>();
    
+   private List<Item> itemActivity = new ArrayList<Item>();
+   
    public void onItemRemoved(@Observes @Lifted Item item)
    {
       itemsMissing.add(item);
@@ -25,6 +29,11 @@
       itemsTainted.add(item);
    }
    
+   public void onItemActivity(@Observes @Any Item item)
+   {
+      itemActivity.add(item);
+   }
+   
    public Set<Item> getItemsTainted()
    {
       return itemsTainted;
@@ -35,8 +44,19 @@
       return itemsMissing;
    }
    
+   public List<Item> getItemActivity()
+   {
+      return itemActivity;
+   }
+   
    public void minibarStocked(@Observes @Any MiniBar minibar)
    {
+      reset();
+   }
+   
+   public void reset()
+   {
+      itemActivity.clear();
       itemsMissing.clear();
       itemsTainted.clear();
    }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/MiniBar.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/MiniBar.java	2009-07-27 18:46:26 UTC (rev 3286)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/MiniBar.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -17,6 +17,11 @@
    
    @Any Event<Item> itemEvent;
    
+   Event<Item> getItemEvent()
+   {
+      return itemEvent;
+   }
+   
    public Set<Item> getItems()
    {
       return items;
@@ -68,9 +73,14 @@
    
    public void stock()
    {
+      stockNoNotify();
+      miniBarEvent.fire(this);
+   }
+   
+   public void stockNoNotify()
+   {
       items.add(new Item("Chocolate", 5.00));
       items.add(new Item("16 oz Water", 1.00));
       items.add(new Item("Disposable Camera", 10.00));
-      miniBarEvent.fire(this);
    }
 }

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Praise.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Praise.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Praise.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.fires;
+
+class Praise
+{
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Role.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Role.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Role.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.event.fires;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.BindingType;
+
+ at Target( { FIELD, PARAMETER })
+ at Retention(RUNTIME)
+ at BindingType
+ at interface Role
+{
+   String value();
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Tame.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Tame.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Tame.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.event.fires;
+
+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.enterprise.inject.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+ at interface Tame
+{
+
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/TamingCommand.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/TamingCommand.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/TamingCommand.java	2009-07-27 19:29:57 UTC (rev 3287)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.fires;
+
+class TamingCommand
+{
+}




More information about the weld-commits mailing list