[webbeans-commits] Webbeans SVN: r1710 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event: firesall and 1 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Feb 25 16:03:05 EST 2009


Author: dallen6
Date: 2009-02-25 16:03:05 -0500 (Wed, 25 Feb 2009)
New Revision: 1710

Modified:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Role.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/firesall/AllEventTypesTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/register/observer1/ConsumerNotifiedForEventTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/register/observer1/ManagerAddObserverTest.java
Log:
Added some more test coverage for events

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java	2009-02-25 15:54:46 UTC (rev 1709)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java	2009-02-25 21:03:05 UTC (rev 1710)
@@ -1,5 +1,6 @@
 package org.jboss.jsr299.tck.unit.event;
 
+import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Set;
 
@@ -9,6 +10,7 @@
 import javax.inject.DuplicateBindingTypeException;
 import javax.inject.Standard;
 import javax.inject.manager.Bean;
+import javax.inject.manager.Manager;
 
 import org.hibernate.tck.annotations.SpecAssertion;
 import org.hibernate.tck.annotations.SpecAssertions;
@@ -80,9 +82,54 @@
       }
    }
 
+   /**
+    * 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", "stub" })
+   @SpecAssertions( { @SpecAssertion(section = "7.1", id = "d") })
+   public void testEventBindingTypeTargetMostAndRuntime()
+   {
+
+   }
+
+   /**
+    * 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", "stub" })
+   @SpecAssertions( { @SpecAssertion(section = "7.1", id = "e") })
+   public void testEventBindingTypeTargetsFieldParameterAndRuntime()
+   {
+
+   }
+
+   /**
+    * An event binding type is a Java annotation defined as ~@Target({FIELD,
+    * PARAMETER}) or @Target({METHOD, FIELD, PARAMETER, TYPE}) and
+    * ~@Retention(RUNTIME)
+    * TODO If the binding does not have RUNTIME retention, it cannot be tested
+    */
+   @Test(groups = { "events", "broken" })
+   @SpecAssertions( { @SpecAssertion(section = "7.1", id = "f") })
+   public void testEventBindingTypeNotRuntime()
+   {
+
+   }
+
+   // TODO How to test all annotations w/o BindingType are not event bindings
+   @Test(groups = { "events", "broken" })
+   @SpecAssertions( { @SpecAssertion(section = "7.1", id = "g") })
+   public void testEventBindingTypesSpecifyBinding()
+   {
+
+   }
+
    @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertions( { @SpecAssertion(section = "7.1", id = "a"), 
-      @SpecAssertion(section = "7.2", id = "b") })
+   @SpecAssertions( { @SpecAssertion(section = "7.1", id = "a"), @SpecAssertion(section = "7.2", id = "b") })
    public void testManagerFireEventWithEventTypeParametersFails()
    {
       ATemplatedEventType<String> anEvent = new ATemplatedEventType<String>();
@@ -99,6 +146,13 @@
       getCurrentManager().fireEvent(anEventOnAnyType);
    }
 
+   @Test(groups = { "events" })
+   @SpecAssertions( { @SpecAssertion(section = "7.2", id = "a") })
+   public void testManagerInterfaceForFireEventMethod() throws Exception
+   {
+      assert Manager.class.getDeclaredMethod("fireEvent", Object.class, Annotation[].class) != null;
+   }
+
    @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
    @SpecAssertions( { @SpecAssertion(section = "7.2", id = "d") })
    public void testManagerFireEventWithNonBindingAnnotationsFails()
@@ -115,7 +169,7 @@
     * The Manager interface provides a method for firing events:
     */
    @Test(groups = { "events" })
-   @SpecAssertion(section = "7.2", id = "unknown")
+   @SpecAssertion(section = "7.2", id = "a")
    public void testManagerFireEvent()
    {
       // First a simple event with no bindings is fired
@@ -126,7 +180,22 @@
       getCurrentManager().fireEvent(anEvent, new RoleBinding("Admin"));
    }
 
+   //TODO This is not an assertion but a definition which is circular and non-testable
    @Test(groups = { "events" })
+   @SpecAssertion(section = "7.3", id = "a")
+   public void testObserversImplementObserverInterface()
+   {
+      Observer<String> observer = new Observer<String>()
+      {
+         @Override
+         public void notify(String event)
+         {
+         }
+      };
+      assert observer != null;
+   }
+
+   @Test(groups = { "events" })
    @SpecAssertion(section = "7.5", id = "e")
    public void testMultipleObserverMethodsOK()
    {
@@ -201,7 +270,8 @@
       assert beans != null;
    }
 
-   //TODO This test was working well in January 2009 but no longer creates the observer
+   // TODO This test was working well in January 2009 but no longer creates the
+   // observer
    @Test(groups = { "events", "broken" })
    @SpecAssertion(section = "7.5.5", id = "a")
    public void testConditionalObserver() throws Exception
@@ -224,7 +294,7 @@
             getCurrentManager().fireEvent(new ConditionalEvent());
             assert RecluseSpider.notified;
          }
-         
+
       }.run();
    }
 
@@ -347,7 +417,7 @@
             SweeWaxbill bean = getCurrentManager().getInstanceByType(SweeWaxbill.class);
             bean.methodThatFiresEvent();
          }
-         
+
       }.run();
    }
 
@@ -364,7 +434,7 @@
             SweeWaxbill bean = getCurrentManager().getInstanceByType(SweeWaxbill.class);
             bean.methodThatRegistersObserver();
          }
-         
+
       }.run();
    }
 
@@ -381,7 +451,7 @@
             OwlFinch_Broken bean = getCurrentManager().getInstanceByType(OwlFinch_Broken.class);
             bean.methodThatFiresEvent();
          }
-         
+
       }.run();
    }
 
@@ -398,7 +468,7 @@
             OwlFinch_Broken bean = getCurrentManager().getInstanceByType(OwlFinch_Broken.class);
             bean.methodThatRegistersObserver();
          }
-         
+
       }.run();
    }
 
@@ -412,12 +482,12 @@
          @Override
          protected void execute() throws Exception
          {
-            // Retrieve the implicit event bean from the manager only by 
+            // Retrieve the implicit event bean from the manager only by
             // its API type
             Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
             assert !eventBeans.isEmpty();
          }
-         
+
       }.run();
    }
 
@@ -431,12 +501,12 @@
          @Override
          protected void execute() throws Exception
          {
-            // Retrieve the implicit event bean from the manager 
+            // Retrieve the implicit event bean from the manager
             // by its binding types (uses OrangeCheekedWaxbill)
             Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding(), new TameAnnotationLiteral(), new RoleBinding("Admin"));
             assert !eventBeans.isEmpty();
          }
-         
+
       }.run();
    }
 
@@ -457,7 +527,7 @@
             Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
             assert eventBean.getDeploymentType().equals(Standard.class);
          }
-         
+
       }.run();
    }
 
@@ -470,7 +540,7 @@
          @Override
          protected void execute() throws Exception
          {
-            // Retrieve the implicit event bean from the manager only 
+            // Retrieve the implicit event bean from the manager only
             // by its API type (uses BlueFacedParrotFinch)
             Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
             assert eventBeans.size() == 1;
@@ -489,7 +559,7 @@
          @Override
          protected void execute() throws Exception
          {
-            // Retrieve the implicit event bean from the manager only 
+            // Retrieve the implicit event bean from the manager only
             // by its API type (uses BlueFacedParrotFinch)
             Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
             assert eventBeans.size() == 1;
@@ -508,7 +578,7 @@
          @Override
          protected void execute() throws Exception
          {
-            // Retrieve the implicit event bean from the manager only 
+            // Retrieve the implicit event bean from the manager only
             // by its API type (uses BlueFacedParrotFinch)
             Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new FiresBinding());
             assert eventBeans.size() == 1;
@@ -589,7 +659,8 @@
     * By default, Java implementation reuse is assumed. In this case, the
     * producer, disposal and observer methods of the first bean are not
     * inherited by the second bean.
-    * @throws Exception 
+    * 
+    * @throws Exception
     */
    @Test(groups = { "events", "inheritance" })
    @SpecAssertion(section = "4", id = "a")
@@ -603,13 +674,13 @@
          {
             Set<Observer<Egg>> observers = getCurrentManager().resolveObservers(new Egg());
             assert observers.size() == 1;
-            
+
             // Notify the observer so we can confirm that it
             // is a method only on Farmer, and not LazyFarmer
             observers.iterator().next().notify(new Egg());
             assert Farmer.getObserverClazz().equals(Farmer.class);
          }
-         
+
       }.run();
    }
 

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Role.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Role.java	2009-02-25 15:54:46 UTC (rev 1709)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Role.java	2009-02-25 21:03:05 UTC (rev 1710)
@@ -1,13 +1,17 @@
 package org.jboss.jsr299.tck.unit.event;
 
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
 
 import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
 
 import javax.inject.BindingType;
 
+ at Target( { FIELD, PARAMETER })
+ at Retention(RUNTIME)
 @BindingType
- at Retention(RUNTIME)
 @interface Role
 {
    String value();

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/firesall/AllEventTypesTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/firesall/AllEventTypesTest.java	2009-02-25 15:54:46 UTC (rev 1709)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/firesall/AllEventTypesTest.java	2009-02-25 21:03:05 UTC (rev 1710)
@@ -15,7 +15,7 @@
     * @throws Exception
     */
    @Test(groups = { "events" })
-   @SpecAssertion(section = "7.1", id = "b")
+   @SpecAssertion(section = "7.1", id = "c")
    public void testEventTypeIncludesAllSuperclassesAndInterfacesOfEventObject() throws Exception
    {
       // Fire a single complex type of event with many observers

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/register/observer1/ConsumerNotifiedForEventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/register/observer1/ConsumerNotifiedForEventTest.java	2009-02-25 15:54:46 UTC (rev 1709)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/register/observer1/ConsumerNotifiedForEventTest.java	2009-02-25 21:03:05 UTC (rev 1710)
@@ -26,7 +26,7 @@
    }
 
    @Test(groups = { "events" })
-   @SpecAssertions( { @SpecAssertion(section = "7.1", id = "e"), @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()
    {
       AnObserver observer1 = new AnObserver();

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/register/observer1/ManagerAddObserverTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/register/observer1/ManagerAddObserverTest.java	2009-02-25 15:54:46 UTC (rev 1709)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/register/observer1/ManagerAddObserverTest.java	2009-02-25 21:03:05 UTC (rev 1710)
@@ -24,6 +24,7 @@
 import javax.inject.TypeLiteral;
 
 import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
 import org.jboss.jsr299.tck.AbstractDeclarativeTest;
 import org.jboss.jsr299.tck.impl.packaging.Artifact;
 import org.testng.annotations.Test;
@@ -32,7 +33,7 @@
  * Tests for the manager.addObserver() method.
  * 
  * @author David Allen
- *
+ * 
  */
 @Artifact
 public class ManagerAddObserverTest extends AbstractDeclarativeTest
@@ -52,7 +53,7 @@
    }
 
    @Test(groups = { "events" })
-   @SpecAssertion(section = "7.3", id = "b")
+   @SpecAssertions( { @SpecAssertion(section = "7.3", id = "b"), @SpecAssertion(section = "7.3", id = "c") })
    public void testManagerAddObserver()
    {
       Observer<AnEventType> observer1 = new AnObserver();




More information about the weld-commits mailing list