[webbeans-commits] Webbeans SVN: r3206 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event: bindingTypes and 8 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Fri Jul 24 20:44:39 EDT 2009
Author: dan.j.allen
Date: 2009-07-24 20:44:37 -0400 (Fri, 24 Jul 2009)
New Revision: 3206
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Animal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/AnimalAssessment.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/DiscerningObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/EventBindingTypesTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/EventEmitter.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/NonBindingType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/NonRuntimeBindingType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Tame.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/TameAnnotationLiteral.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Wild.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/WildAnnotationLiteral.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/AbstractBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/ConcreteBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/AbstractEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Artist.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Broadcast.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/ComplexEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypeFamilyObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypesTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/GeneralEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Listener.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Solo.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Song.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/TuneSelect.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnEventType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherEventType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherObserver.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/resolve/typeFamily/
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/Egg.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/EventInjectionWithUndefinedTypeVariableTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/JavaSparrow_Broken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withWildcardType/EventInjectionWithWildcardTypeTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withoutType/EventInjectionWithoutTypeTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/NonManagedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/ObserverMethodOnIncorrectBeanTest.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/observer/ObserverTest.java
Log:
wrote additional event tests and updated assertions for 20090625 (event section not yet complete)
repackaged many of the existing tests (no tests were removed unless duplicates)
corrected tests regarding type variables, but may need to be reviewed
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Animal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Animal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Animal.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+class Animal
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/AnimalAssessment.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/AnimalAssessment.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/AnimalAssessment.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+
+class AnimalAssessment
+{
+ @Any Event<Animal> animalEvent;
+
+ @Tame Event<Animal> tameAnimalEvent;
+
+ @Any @Wild Event<Animal> wildAnimalEvent;
+
+ public void classifyAsTame(Animal animal)
+ {
+ tameAnimalEvent.fire(animal);
+ }
+
+ public void classifyAsWild(Animal animal)
+ {
+ wildAnimalEvent.fire(animal);
+ }
+
+ public void assess(Animal animal)
+ {
+ animalEvent.fire(animal);
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/DiscerningObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/DiscerningObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/DiscerningObserver.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,37 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+ at RequestScoped class DiscerningObserver
+{
+ private int numTimesAnyBindingTypeEventObserved = 0;
+ private int numTimesNonRuntimeBindingTypeObserved = 0;
+
+ public void observeAny(@Observes @Any String event)
+ {
+ numTimesAnyBindingTypeEventObserved++;
+ }
+
+ public void observeNonRuntime(@Observes @Any @NonRuntimeBindingType String event)
+ {
+ numTimesNonRuntimeBindingTypeObserved++;
+ }
+
+ public int getNumTimesAnyBindingTypeEventObserved()
+ {
+ return numTimesAnyBindingTypeEventObserved;
+ }
+
+ public int getNumTimesNonRuntimeBindingTypeObserved()
+ {
+ return numTimesNonRuntimeBindingTypeObserved;
+ }
+
+ public void reset()
+ {
+ numTimesAnyBindingTypeEventObserved = 0;
+ numTimesNonRuntimeBindingTypeObserved = 0;
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/EventBindingTypesTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/EventBindingTypesTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/EventBindingTypesTest.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,86 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.enterprise.inject.TypeLiteral;
+import javax.enterprise.inject.spi.Bean;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+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;
+
+/**
+ * Spec version: 20090625
+ *
+ * @author Dan Allen
+ */
+ at Artifact
+public class EventBindingTypesTest extends AbstractJSR299Test
+{
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.1", id = "d")
+ public void testEventBindingTypeTargetsMethodFieldParameterElementTypes()
+ {
+ Animal animal = new Animal();
+ getCurrentManager().fireEvent(animal, new TameAnnotationLiteral());
+ getInstanceByType(AnimalAssessment.class).classifyAsTame(animal);
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.1", id = "e")
+ public void testEventBindingTypeTargetsFieldParameterElementTypes()
+ {
+ Animal animal = new Animal();
+ getCurrentManager().fireEvent(animal, new WildAnnotationLiteral());
+ getInstanceByType(AnimalAssessment.class).classifyAsWild(animal);
+ }
+
+ /**
+ * This test ensures that an event binding type without runtime retention is effectively invisible
+ */
+ @Test(groups = "events")
+ @SpecAssertion(section = "10.1", id = "f")
+ public void testNonRuntimeBindingTypeIsNotAnEventBindingType()
+ {
+ DiscerningObserver observer = getInstanceByType(DiscerningObserver.class);
+ observer.reset();
+ EventEmitter emitter = getInstanceByType(EventEmitter.class);
+ assert emitter.isEventWithOnlyNonRuntimeBindingTypeNotInjected();
+ emitter.fireEvent();
+ assert observer.getNumTimesAnyBindingTypeEventObserved() == 1;
+ assert observer.getNumTimesNonRuntimeBindingTypeObserved() == 1;
+ emitter.fireEventWithNonRuntimeBindingType();
+ assert observer.getNumTimesAnyBindingTypeEventObserved() == 2;
+ assert observer.getNumTimesNonRuntimeBindingTypeObserved() == 2;
+ }
+
+ @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class } )
+ @SpecAssertion(section = "10.1", id = "f")
+ public void testFireEventWithNonRuntimeBindingTypeFails()
+ {
+ getCurrentManager().fireEvent(new Animal(), new AnnotationLiteral<NonRuntimeBindingType>(){});
+ }
+
+ @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class } )
+ @SpecAssertion(section = "10.1", id = "g")
+ public void testFireEventWithNonBindingAnnotationsFails()
+ {
+ getCurrentManager().fireEvent(new Animal(), new AnnotationLiteral<NonBindingType>(){});
+ }
+
+ @Test(groups = "events")
+ @SpecAssertion(section = "10.1", id = "i")
+ public void testEventAlwaysHasAnyBinding()
+ {
+ Bean<Event<Animal>> animalEventBean = getUniqueBean(new TypeLiteral<Event<Animal>>() {}, new WildAnnotationLiteral());
+ assert animalEventBean.getBindings().contains(new AnyLiteral());
+
+ Bean<Event<Animal>> tameAnimalEventBean = getUniqueBean(new TypeLiteral<Event<Animal>>() {}, new TameAnnotationLiteral());
+ assert tameAnimalEventBean.getBindings().contains(new AnyLiteral());
+
+ Bean<Event<Animal>> wildAnimalEventBean = getUniqueBean(new TypeLiteral<Event<Animal>>() {}, new WildAnnotationLiteral());
+ assert wildAnimalEventBean.getBindings().contains(new AnyLiteral());
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/EventEmitter.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/EventEmitter.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/EventEmitter.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+
+class EventEmitter
+{
+ @Any Event<String> stringEvent;
+
+ @Any @NonRuntimeBindingType Event<String> stringEventWithAnyAndNonRuntimeBindingType;
+
+ @NonRuntimeBindingType Event<String> stringEventWithOnlyNonRuntimeBindingType;
+
+ public void fireEvent()
+ {
+ stringEvent.fire("event");
+ }
+
+ public void fireEventWithNonRuntimeBindingType()
+ {
+ stringEventWithAnyAndNonRuntimeBindingType.fire("event");
+ }
+
+ public boolean isEventWithOnlyNonRuntimeBindingTypeNotInjected()
+ {
+ return stringEventWithOnlyNonRuntimeBindingType == null;
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/NonBindingType.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/NonBindingType.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/NonBindingType.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+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;
+
+ at Target( { FIELD, PARAMETER })
+ at Retention(RUNTIME)
+ at interface NonBindingType
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/NonRuntimeBindingType.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/NonRuntimeBindingType.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/NonRuntimeBindingType.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.BindingType;
+
+ at Target( { FIELD, PARAMETER })
+ at BindingType
+ at interface NonRuntimeBindingType
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Tame.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Tame.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Tame.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+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/bindingTypes/TameAnnotationLiteral.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/TameAnnotationLiteral.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/TameAnnotationLiteral.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+import javax.enterprise.inject.AnnotationLiteral;
+
+class TameAnnotationLiteral extends AnnotationLiteral<Tame> implements Tame
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Wild.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Wild.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/Wild.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+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.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.BindingType;
+
+ at Target( { PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+ at interface Wild
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/WildAnnotationLiteral.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/WildAnnotationLiteral.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/bindingTypes/WildAnnotationLiteral.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.event.bindingTypes;
+
+import javax.enterprise.inject.AnnotationLiteral;
+
+class WildAnnotationLiteral extends AnnotationLiteral<Wild> implements Wild
+{
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/Egg.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/Egg.java 2009-07-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/Egg.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -2,5 +2,4 @@
class Egg
{
-
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/EventInjectionWithUndefinedTypeVariableTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/EventInjectionWithUndefinedTypeVariableTest.java 2009-07-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/EventInjectionWithUndefinedTypeVariableTest.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -17,7 +17,7 @@
package org.jboss.jsr299.tck.tests.event.broken.inject.withTypeVariable;
-
+import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.jsr299.tck.DefinitionError;
import org.jboss.testharness.impl.packaging.Artifact;
@@ -28,16 +28,17 @@
* Tests an Event templated with an undefined type variable and annotated
* with {@link @Any} fails.
*
+ * Spec version: 20090625
+ *
* @author David Allen
*/
@Artifact
@ExpectedDeploymentException(DefinitionError.class)
public class EventInjectionWithUndefinedTypeVariableTest extends AbstractJSR299Test
{
- @Test(groups = { "events", "ri-broken" })
- // TODO need spec assertion (see 10.3.1)
- // I'm confused whether or not this should fail
- public void testAnyAnnotationOnEventInjectionPointWithUndefinedTypeVariableFails()
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.1", id = "cb", note = "Failure case")
+ public void testEventInjectionPointWithUndefinedTypeVariableIsDefinitionError()
{
assert false;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/JavaSparrow_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/JavaSparrow_Broken.java 2009-07-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withTypeVariable/JavaSparrow_Broken.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -2,12 +2,14 @@
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Produces;
class JavaSparrow_Broken
{
- public <T> Egg produce(@Any Event<T> event)
+ public @Produces <T> Egg produce(@Any Event<T> event)
{
- // event might be fired here in real code
+ // event might be fired here to react to the producer method firing
+ // just return canned data for test
return new Egg();
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withWildcardType/EventInjectionWithWildcardTypeTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withWildcardType/EventInjectionWithWildcardTypeTest.java 2009-07-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withWildcardType/EventInjectionWithWildcardTypeTest.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -14,10 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.jboss.jsr299.tck.tests.event.broken.inject.withWildcardType;
-
+import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.jsr299.tck.DefinitionError;
import org.jboss.testharness.impl.packaging.Artifact;
@@ -28,6 +27,8 @@
* Tests that an injection point for an Event object with a wildcard
* type parameter is treated as a definition error.
*
+ * Spec version: 20090625
+ *
* @author David Allen
*/
@Artifact
@@ -35,8 +36,8 @@
public class EventInjectionWithWildcardTypeTest extends AbstractJSR299Test
{
@Test(groups = { "events" })
- // FIXME need spec assertion (see 10.3.1)
- public void testAnyAnnotationOnEventInjectionPointWithWildcardTypeParameterFails()
+ @SpecAssertion(section = "10.1", id = "cb", note = "Failure case")
+ public void testEventInjectionPointWithWildcardTypeParameterIsDefinitionError()
{
assert false;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withoutType/EventInjectionWithoutTypeTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withoutType/EventInjectionWithoutTypeTest.java 2009-07-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/inject/withoutType/EventInjectionWithoutTypeTest.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -34,7 +34,7 @@
public class EventInjectionWithoutTypeTest extends AbstractJSR299Test
{
@Test(groups = { "events" })
- // FIXME need spec assertion (see 10.4.1)
+ // FIXME need spec assertion, probably in the section that defines the Event interface
public void testAnyAnnotationOnEventInjectionPointWithoutTypeParameterFails()
{
assert false;
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/AbstractBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/AbstractBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/AbstractBean.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.event.broken.observer.beanNotManaged;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+abstract class AbstractBean
+{
+ public abstract void observer(@Observes @Any String event);
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/ConcreteBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/ConcreteBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/ConcreteBean.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.event.broken.observer.beanNotManaged;
+
+class ConcreteBean extends AbstractBean
+{
+ @Override
+ public void observer(String event)
+ {
+ }
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/NonManagedBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/NonManagedBean.java 2009-07-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/NonManagedBean.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -17,6 +17,7 @@
package org.jboss.jsr299.tck.tests.event.broken.observer.beanNotManaged;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
/**
* This class is not a bean since it does not have a default constructor
@@ -31,7 +32,7 @@
{
}
- public void observe(@Observes String event)
+ public void observe(@Observes @Any String event)
{
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/ObserverMethodOnIncorrectBeanTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/ObserverMethodOnIncorrectBeanTest.java 2009-07-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer/beanNotManaged/ObserverMethodOnIncorrectBeanTest.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -25,7 +25,7 @@
* Tests an observer method on something that is not a managed bean
* or a session bean.
*
- * Spec version: 20090519
+ * Spec version: 20090625
*
* @author David Allen
*/
@@ -33,9 +33,9 @@
public class ObserverMethodOnIncorrectBeanTest extends AbstractJSR299Test
{
@Test(groups = { "events" })
- @SpecAssertion(section = "10.5", id = "b")
- public void testObserverMethodNotOnSimpleOrSessionBeanFails()
+ @SpecAssertion(section = "10.4", id = "aa")
+ public void testObserverMethodNotOnManagedOrSessionBeanFails()
{
- assert getCurrentManager().resolveObserverMethods("event").isEmpty();
+ assert getCurrentManager().resolveObserverMethods(new String()).isEmpty();
}
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/AbstractEvent.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/AbstractEvent.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/AbstractEvent.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.event.eventTypes;
+
+/**
+ * Abstract level of event hierarchy used to test firing a concrete type and
+ * observing each of the event types associated with that concrete type.
+ *
+ * @author David Allen
+ */
+abstract class AbstractEvent implements GeneralEvent
+{
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Artist.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Artist.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Artist.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.eventTypes;
+
+public class Artist<T>
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Broadcast.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Broadcast.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Broadcast.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.eventTypes;
+
+abstract class Broadcast
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/ComplexEvent.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/ComplexEvent.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/ComplexEvent.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.event.eventTypes;
+
+/**
+ * An event type with a class/interface hierarchy complex enough to test
+ * observing all event types.
+ *
+ * @author David Allen
+ */
+public class ComplexEvent extends AbstractEvent implements GeneralEvent
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypeFamilyObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypeFamilyObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypeFamilyObserver.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.event.eventTypes;
+
+import javax.enterprise.event.Observes;
+
+/**
+ * This class declares observer methods for every superclass and interface
+ * contained in the hierarchy for the {@link ComplexEvent} event type.
+ *
+ * @author David Allen
+ */
+class EventTypeFamilyObserver
+{
+ private static int objectEventQuantity = 0;
+ private static int generalEventQuantity = 0;
+ private static int abstractEventQuantity = 0;
+ private static int complexEventQuantity = 0;
+
+ public void observeObject(@Observes Object event)
+ {
+ // Avoid counting implicit container events
+ if (event instanceof ComplexEvent)
+ {
+ objectEventQuantity++;
+ }
+ }
+
+ public void observeGeneralEvent(@Observes GeneralEvent event)
+ {
+ generalEventQuantity++;
+ }
+
+ public void observeAbstractEvent(@Observes AbstractEvent event)
+ {
+ abstractEventQuantity++;
+ }
+
+ public void observeComplexEvent(@Observes ComplexEvent event)
+ {
+ complexEventQuantity++;
+ }
+
+ public int getGeneralEventQuantity()
+ {
+ return generalEventQuantity;
+ }
+
+ public int getAbstractEventQuantity()
+ {
+ return abstractEventQuantity;
+ }
+
+ public int getComplexEventQuantity()
+ {
+ return complexEventQuantity;
+ }
+
+ public int getObjectEventQuantity()
+ {
+ return objectEventQuantity;
+ }
+
+ public int getTotalEventsObserved()
+ {
+ return objectEventQuantity + generalEventQuantity + abstractEventQuantity + complexEventQuantity;
+ }
+
+ public void reset()
+ {
+ objectEventQuantity = 0;
+ generalEventQuantity = 0;
+ abstractEventQuantity = 0;
+ complexEventQuantity = 0;
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypesTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypesTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypesTest.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,73 @@
+package org.jboss.jsr299.tck.tests.event.eventTypes;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+/**
+ * Spec version: 20090625
+ *
+ * @author Dan Allen
+ */
+ at Artifact
+public class EventTypesTest extends AbstractJSR299Test
+{
+ @Test(groups = "event")
+ @SpecAssertions({
+ @SpecAssertion(section = "10.1", id = "aa"),
+ @SpecAssertion(section = "10.1", id = "j")
+ })
+ public void testEventTypeIsConcreteTypeWithNoTypeVariables()
+ {
+ Listener listener = getInstanceByType(Listener.class);
+ listener.reset();
+ // typical concrete type
+ Song s = new Song();
+ getInstanceByType(TuneSelect.class).songPlaying(s);
+ assert listener.getObjectsFired().size() == 1;
+ assert listener.getObjectsFired().get(0) == s;
+ getCurrentManager().fireEvent(s);
+ assert listener.getObjectsFired().size() == 2;
+ assert listener.getObjectsFired().get(1) == s;
+ // anonymous instance
+ Broadcast b = new Broadcast() {};
+ getInstanceByType(TuneSelect.class).broadcastPlaying(b);
+ assert listener.getObjectsFired().size() == 3;
+ assert listener.getObjectsFired().get(2) == b;
+ // boxed primitive
+ getCurrentManager().fireEvent(1);
+ assert listener.getObjectsFired().size() == 4;
+ assert listener.getObjectsFired().get(3).equals(1);
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.1", id = "c")
+ public void testEventTypeIncludesAllSuperclassesAndInterfacesOfEventObject()
+ {
+ // we have to use a dependent-scoped observer here because we it is observing the Object event type
+ // and a request-scoped object would get called outside of when the request scope is active in this situation
+ EventTypeFamilyObserver observer = getInstanceByType(EventTypeFamilyObserver.class);
+ getCurrentManager().fireEvent(new ComplexEvent());
+ assert observer.getGeneralEventQuantity() == 1;
+ assert observer.getAbstractEventQuantity() == 1;
+ assert observer.getComplexEventQuantity() == 1;
+ assert observer.getObjectEventQuantity() == 1;
+ assert observer.getTotalEventsObserved() == 4;
+ }
+
+ @Test(groups = { "event", "review" }, expectedExceptions = IllegalArgumentException.class)
+ @SpecAssertion(section = "10.1", id = "cb")
+ public void testEventTypeFiredByEventInterfaceMayNotContainTypeVariable()
+ {
+ getInstanceByType(TuneSelect.class).soloArtistPlaying(new Artist<Solo>());
+ }
+
+ @Test(groups = { "event", "review" }, expectedExceptions = IllegalArgumentException.class)
+ @SpecAssertion(section = "10.1", id = "cb")
+ public void testEventTypeFiredByBeanManagerMayNotContainTypeVariable()
+ {
+ getCurrentManager().fireEvent(new Artist<Solo>());
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/GeneralEvent.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/GeneralEvent.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/GeneralEvent.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.event.eventTypes;
+
+/**
+ * Arbitrary interface to test firing events and observing all event types.
+ *
+ * @author David Allen
+ */
+interface GeneralEvent
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Listener.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Listener.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Listener.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,39 @@
+package org.jboss.jsr299.tck.tests.event.eventTypes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+ at RequestScoped class Listener
+{
+ List<Object> objectsFired = new ArrayList<Object>();
+
+ public void registerNumberFired(@Observes @Any Integer i)
+ {
+ objectsFired.add(i);
+ }
+
+ public void registerSongFired(@Observes @Any Song s)
+ {
+ objectsFired.add(s);
+ }
+
+ public void registerBroadcastFired(@Observes @Any Broadcast b)
+ {
+ objectsFired.add(b);
+ }
+
+ public List<Object> getObjectsFired()
+ {
+ return objectsFired;
+ }
+
+ public void reset()
+ {
+ objectsFired.clear();
+ }
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Solo.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Solo.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Solo.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.eventTypes;
+
+class Solo
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Song.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Song.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/Song.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.eventTypes;
+
+class Song
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/TuneSelect.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/TuneSelect.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/TuneSelect.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.tests.event.eventTypes;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+
+class TuneSelect
+{
+ @Any Event<Artist<Solo>> soloArtistEvent;
+
+ @Any Event<Song> songEvent;
+
+ @Any Event<Broadcast> broadcastEvent;
+
+ public void songPlaying(Song s)
+ {
+ songEvent.fire(s);
+ }
+
+ public void broadcastPlaying(Broadcast b)
+ {
+ broadcastEvent.fire(b);
+ }
+
+ public void soloArtistPlaying(Artist<Solo> soloArtist)
+ {
+ soloArtistEvent.fire(soloArtist);
+ }
+}
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-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -13,6 +13,7 @@
import javax.enterprise.inject.spi.InjectionPoint;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.jsr299.tck.literals.AnyLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
@@ -67,9 +68,12 @@
/**
* This test verifies that the fire() method of the injected {@link Event}
* object accepts an event object and that the event object's type is the
- * same as the the paraterized type on the event field.
+ * same as the the parameterized type on the event field.
**/
- @SpecAssertion(section = "10.3", id = "b")
+ @SpecAssertions({
+ @SpecAssertion(section = "10.3", id = "b"),
+ @SpecAssertion(section = "10.3.1", id = "cb")
+ })
@Test(groups = "events")
public void testInjectedEventAcceptsEventObject() throws SecurityException, NoSuchFieldException, NoSuchMethodException
{
@@ -124,7 +128,10 @@
* verified by checking that the cooresponding observer gets invoked.
*/
@Test(groups = "events")
- @SpecAssertion(section = "10.3", id = "c")
+ @SpecAssertions({
+ @SpecAssertion(section = "10.3", id = "c"),
+ @SpecAssertion(section = "10.3.1", id = "cb")
+ })
public void testInjectedEventCanHaveBindings()
{
Billing billing = getInstanceByType(Billing.class);
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnEventType.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnEventType.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnEventType.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.observer;
+
+class AnEventType
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnObserver.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.event.observer;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+class AnObserver
+{
+ static boolean wasNotified = false;
+
+ public void observer(@Observes @Any AnEventType event)
+ {
+ wasNotified = true;
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherEventType.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherEventType.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherEventType.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.observer;
+
+class AnotherEventType<T>
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherObserver.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.event.observer;
+
+import javax.enterprise.event.Observes;
+
+class AnotherObserver
+{
+ static boolean wasNotified = false;
+
+ void observer(@Observes @Role("Admin") AnEventType event)
+ {
+ wasNotified = true;
+ }
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/ObserverTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/ObserverTest.java 2009-07-24 20:17:55 UTC (rev 3205)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/ObserverTest.java 2009-07-25 00:44:37 UTC (rev 3206)
@@ -2,8 +2,6 @@
import java.lang.annotation.Annotation;
-import javax.enterprise.event.Observes;
-
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
@@ -16,31 +14,7 @@
@Artifact
public class ObserverTest extends AbstractJSR299Test
{
- public static class AnEventType
- {
- }
-
- public static class AnObserver
- {
- public static boolean wasNotified = false;
-
- public void observer(@Observes AnEventType event)
- {
- wasNotified = true;
- }
- }
-
- public static class AnotherObserver
- {
- public static boolean wasNotified = false;
-
- public void observer(@Observes @Role("Admin") AnEventType event)
- {
- wasNotified = true;
- }
- }
-
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events" })
@SpecAssertions( {
@SpecAssertion(section = "10.2", id = "h"),
@SpecAssertion(section = "10.5", id = "aa")
@@ -52,7 +26,7 @@
// Fire an event that will be delivered to the two above observers
AnEventType anEvent = new AnEventType();
getCurrentManager().fireEvent(anEvent, roleBinding);
-
+
assert AnObserver.wasNotified;
assert AnotherObserver.wasNotified;
AnObserver.wasNotified = false;
More information about the weld-commits
mailing list