Author: dan.j.allen
Date: 2009-07-23 22:26:26 -0400 (Thu, 23 Jul 2009)
New Revision: 3184
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Item_Illegal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/StudentDirectory.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/AlarmSystem.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/BreakInEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/NotABindingType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecurityEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecurityEvent_Illegal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecuritySensor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SelectEventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SystemTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/Violent.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.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/implicit/ImplicitEventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/Registration.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/Student.java
Log:
tests for the Event interface
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java 2009-07-24
02:24:33 UTC (rev 3183)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -134,6 +134,12 @@
return resolveUniqueBean(type, beans);
}
+ public <T> Bean<T> getUniqueBean(TypeLiteral<T> type, Annotation...
bindings)
+ {
+ Set<Bean<T>> beans = getBeans(type, bindings);
+ return resolveUniqueBean(type.getType(), beans);
+ }
+
public <T> Set<Bean<T>> getBeans(Class<T> type, Annotation...
bindings)
{
return (Set) getCurrentManager().getBeans(type, bindings);
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
02:24:33 UTC (rev 3183)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -22,6 +22,8 @@
* Tests that verify the event firing behavior of the Event
* interface.
*
+ * Spec version: 20090625
+ *
* @author Dan Allen
*/
@Artifact
@@ -189,5 +191,13 @@
assert housekeeping.getItemsTainted().size() == 1;
assert housekeeping.getItemsTainted().contains(water);
}
+
+ @Test(groups = "events", expectedExceptions =
IllegalArgumentException.class)
+ @SpecAssertion(section = "10.3.1", id = "f")
+ public void testEventFireThrowsExceptionIfEventObjectContainsTypeVariable()
+ {
+ MiniBar miniBar = getInstanceByType(MiniBar.class);
+ miniBar.itemEvent.fire(new Item_Illegal<Integer>("12 oz Beer",
5.50));
+ }
}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Item_Illegal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Item_Illegal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/Item_Illegal.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.event.fires;
+
+class Item_Illegal<T> extends Item
+{
+
+ public Item_Illegal(String name, double price)
+ {
+ super(name, price);
+ }
+
+}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/ImplicitEventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/ImplicitEventTest.java 2009-07-24
02:24:33 UTC (rev 3183)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/ImplicitEventTest.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -1,12 +1,11 @@
package org.jboss.jsr299.tck.tests.event.implicit;
+import java.io.IOException;
import java.io.Serializable;
import javax.enterprise.context.Dependent;
import javax.enterprise.event.Event;
import javax.enterprise.inject.TypeLiteral;
-import javax.enterprise.inject.deployment.Standard;
-import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
@@ -17,60 +16,95 @@
/**
* Test that there is an implicit event bean for every legal event type
+ * and verify its composition.
*
- * Spec version: 20090519
+ * Spec version: 20090625
*
* @author Dan Allen
*/
@Artifact
public class ImplicitEventTest extends AbstractJSR299Test
{
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "10.4.2", id = "a"),
- @SpecAssertion(section = "10.4.2", id = "b"),
- @SpecAssertion(section = "10.1", id = "i")
- })
+ private static final TypeLiteral<Event<StudentRegisteredEvent>>
STUDENT_REGISTERED_EVENT_LITERAL = new
TypeLiteral<Event<StudentRegisteredEvent>>() {};
+ private static final TypeLiteral<Event<CourseFullEvent>>
COURSE_FULL_EVENT_LITERAL = new TypeLiteral<Event<CourseFullEvent>>() {};
+ private static final TypeLiteral<Event<AwardEvent>> AWARD_EVENT_LITERAL =
new TypeLiteral<Event<AwardEvent>>() {};
+
+ @Test(groups = "events")
+ @SpecAssertion(section = "10.3.2", id = "a")
public void testImplicitEventExistsForEachEventType()
{
- assert getBeans(new TypeLiteral<Event<StudentRegisteredEvent>>() {},
new AnyLiteral()).size() == 1;
- assert getBeans(new TypeLiteral<Event<CourseFullEvent>>() {}, new
AnyLiteral()).size() == 1;
- assert getBeans(new TypeLiteral<Event<AwardEvent>>() {}, new
AnyLiteral()).size() == 1;
- assert getBeans(new TypeLiteral<Event<AwardEvent>>() {}, new
AnyLiteral(), new HonorsLiteral()).size() == 1;
+ assert getBeans(STUDENT_REGISTERED_EVENT_LITERAL).size() == 1;
+ assert getBeans(COURSE_FULL_EVENT_LITERAL).size() == 1;
+ assert getBeans(AWARD_EVENT_LITERAL).size() == 1;
}
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "10.4.2", id = "c"),
- @SpecAssertion(section = "10.4.2", id = "d"),
- @SpecAssertion(section = "10.4.2", id = "e"),
- @SpecAssertion(section = "10.4.2", id = "g"),
- @SpecAssertion(section = "6.6.2", id = "e")
- })
- public void testImplicitEventHasCorrectAttributes()
+ @Test(groups = "events")
+ @SpecAssertion(section = "10.3.2", id = "b")
+ public void testImplicitEventHasAllExplicitBindingTypes()
{
- Bean<Event<StudentRegisteredEvent>> event = getBeans(new
TypeLiteral<Event<StudentRegisteredEvent>>() {}, new
AnyLiteral()).iterator().next();
- assert event != null;
- assert event.getDeploymentType().equals(Standard.class);
- assert event.getScopeType().equals(Dependent.class);
- assert event.getName() == null;
- assert event.getBindings().size() == 1;
- assert event.getBindings().iterator().next().equals(new AnyLiteral());
- Registration registration = this.getInstanceByType(Registration.class);
- assert isSerializable(registration.getCourseFullEvent().getClass());
+ assert getBeans(AWARD_EVENT_LITERAL, new AnyLiteral(), new HonorsLiteral()).size()
== 1;
}
- @Test
- @SpecAssertion(section = "10.4.2", id = "f")
- public void testImplicitEventImplementationProvidedByContainer()
+ @SpecAssertion(section = "10.1", id = "i")
+ public void testImplicitEventHasAnyBinding()
{
- assert getInstanceByType(Registration.class).getCourseFullEvent() != null;
-
+ assert getUniqueBean(STUDENT_REGISTERED_EVENT_LITERAL).getBindings().contains(new
AnyLiteral());
+ assert getUniqueBean(COURSE_FULL_EVENT_LITERAL).getBindings().contains(new
AnyLiteral());
+ assert getUniqueBean(AWARD_EVENT_LITERAL).getBindings().contains(new
AnyLiteral());
+ assert getUniqueBean(AWARD_EVENT_LITERAL, new
HonorsLiteral()).getBindings().contains(new AnyLiteral());
+ assert getUniqueBean(AWARD_EVENT_LITERAL, new AnyLiteral(), new HonorsLiteral()) ==
getUniqueBean(AWARD_EVENT_LITERAL, new HonorsLiteral());
}
- public static boolean isSerializable(Class<?> clazz)
+ @Test(groups = "events")
+ @SpecAssertion(section = "10.3.2", id = "d")
+ public void testImplicitEventHasDependentScope()
{
- return clazz.isPrimitive() || Serializable.class.isAssignableFrom(clazz);
+ assert
getUniqueBean(STUDENT_REGISTERED_EVENT_LITERAL).getScopeType().equals(Dependent.class);
}
-
+
+ @Test(groups = "events")
+ @SpecAssertion(section = "10.3.2", id = "e")
+ public void testImplicitEventHasNoName()
+ {
+ assert getUniqueBean(STUDENT_REGISTERED_EVENT_LITERAL).getName() == null;
+ }
+
+ @Test(groups = "events")
+ @SpecAssertion(section = "10.3.2", id = "f")
+ public void testImplicitEventHasImplementation()
+ {
+ StudentDirectory directory = getInstanceByType(StudentDirectory.class);
+ directory.reset();
+ Registration registration = getInstanceByType(Registration.class);
+ assert registration.getInjectedCourseFullEvent() != null;
+ assert registration.getInjectedStudentRegisteredEvent() != null;
+ Event<StudentRegisteredEvent> event =
registration.getInjectedStudentRegisteredEvent();
+ Student student = new Student("Dan");
+ event.fire(new StudentRegisteredEvent(student));
+ assert directory.getStudents().size() == 1;
+ assert directory.getStudents().contains(student);
+ }
+
+ @Test(groups = { "ri-broken", "events" })
+ @SpecAssertions({
+ @SpecAssertion(section = "10.3.2", id = "g"),
+ @SpecAssertion(section = "6.6.2", id = "e") // break up this
assertion into smaller bits
+ })
+ public void testImplicitEventIsPassivationCapable() throws IOException,
ClassNotFoundException
+ {
+ StudentDirectory directory = getInstanceByType(StudentDirectory.class);
+ directory.reset();
+ Registration registration = getInstanceByType(Registration.class);
+ Event<StudentRegisteredEvent> event =
registration.getInjectedStudentRegisteredEvent();
+ assert Serializable.class.isAssignableFrom(event.getClass());
+ byte[] serializedEvent = serialize(event);
+ @SuppressWarnings("unchecked")
+ Event<StudentRegisteredEvent> eventCopy =
(Event<StudentRegisteredEvent>) deserialize(serializedEvent);
+ // make sure we can still use it
+ Student student = new Student("Dan");
+ eventCopy.fire(new StudentRegisteredEvent(student));
+ assert directory.getStudents().size() == 1;
+ assert directory.getStudents().contains(student);
+ }
+
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/Registration.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/Registration.java 2009-07-24
02:24:33 UTC (rev 3183)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/Registration.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -10,13 +10,12 @@
private Event<CourseFullEvent> courseFullEvent;
- // FIXME @Any should not be required here
- public @Initializer Registration(@Any Event<CourseFullEvent> courseFullEvent)
+ public @Initializer Registration(Event<CourseFullEvent> courseFullEvent)
{
this.courseFullEvent = courseFullEvent;
}
- public void registerUser(Student student)
+ public void registerStudent(Student student)
{
studentRegisteredEvent.fire(new StudentRegisteredEvent(student));
}
@@ -26,8 +25,13 @@
courseFullEvent.fire(new CourseFullEvent(course));
}
- Event<CourseFullEvent> getCourseFullEvent()
+ Event<StudentRegisteredEvent> getInjectedStudentRegisteredEvent()
{
+ return studentRegisteredEvent;
+ }
+
+ Event<CourseFullEvent> getInjectedCourseFullEvent()
+ {
return courseFullEvent;
}
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/Student.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/Student.java 2009-07-24
02:24:33 UTC (rev 3183)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/Student.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -2,4 +2,15 @@
class Student
{
+ private String name;
+
+ public Student(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/StudentDirectory.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/StudentDirectory.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/implicit/StudentDirectory.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.tests.event.implicit;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+@RequestScoped class StudentDirectory
+{
+ private Set<Student> students = new HashSet<Student>();
+
+ public void addStudent(@Observes @Any StudentRegisteredEvent event)
+ {
+ students.add(event.getStudent());
+ }
+
+ public Set<Student> getStudents()
+ {
+ return students;
+ }
+
+ public void reset()
+ {
+ students.clear();
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/AlarmSystem.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/AlarmSystem.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/AlarmSystem.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,64 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+@RequestScoped class AlarmSystem
+{
+ private int numSecurityEvents = 0;
+
+ private int numSystemTests = 0;
+
+ private int numBreakIns = 0;
+
+ private int numViolentBreakIns = 0;
+
+ public void securityEventOccurred(@Observes @Any SecurityEvent event)
+ {
+ numSecurityEvents++;
+ }
+
+ public void selfTest(@Observes @SystemTest SecurityEvent event)
+ {
+ numSystemTests++;
+ }
+
+ public void breakInOccurred(@Observes @Any BreakInEvent event)
+ {
+ numBreakIns++;
+ }
+
+ public void securityBreeched(@Observes @Violent BreakInEvent event)
+ {
+ numViolentBreakIns++;
+ }
+
+ public int getNumSystemTests()
+ {
+ return numSystemTests;
+ }
+
+ public int getNumSecurityEvents()
+ {
+ return numSecurityEvents;
+ }
+
+ public int getNumBreakIns()
+ {
+ return numBreakIns;
+ }
+
+ public int getNumViolentBreakIns()
+ {
+ return numViolentBreakIns;
+ }
+
+ public void reset()
+ {
+ numBreakIns = 0;
+ numViolentBreakIns = 0;
+ numSecurityEvents = 0;
+ numSystemTests = 0;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/BreakInEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/BreakInEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/BreakInEvent.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+class BreakInEvent extends SecurityEvent
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/NotABindingType.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/NotABindingType.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/NotABindingType.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+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;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@interface NotABindingType
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecurityEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecurityEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecurityEvent.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+class SecurityEvent
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecurityEvent_Illegal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecurityEvent_Illegal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecurityEvent_Illegal.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+class SecurityEvent_Illegal<T> extends SecurityEvent
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecuritySensor.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecuritySensor.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SecuritySensor.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+
+class SecuritySensor
+{
+ @Any Event<SecurityEvent> securityEvent;
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SelectEventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SelectEventTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SelectEventTest.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,92 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+import javax.enterprise.inject.AnnotationLiteral;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+/**
+ * These tests verify the behavior of the Event#select() method.
+ *
+ * Spec version: 20090625
+ *
+ * @author Dan Allen
+ */
+@Artifact
+public class SelectEventTest extends AbstractJSR299Test
+{
+ @Test(groups = "events")
+ @SpecAssertion(section = "10.3.1", id = "eaa")
+ public void testEventSelectReturnsEventOfSameType()
+ {
+ AlarmSystem alarm = getInstanceByType(AlarmSystem.class);
+ alarm.reset();
+ SecuritySensor sensor = getInstanceByType(SecuritySensor.class);
+
+ sensor.securityEvent.fire(new SecurityEvent());
+ assert alarm.getNumSecurityEvents() == 1;
+ assert alarm.getNumSystemTests() == 0;
+ assert alarm.getNumBreakIns() == 0;
+ assert alarm.getNumViolentBreakIns() == 0;
+
+ sensor.securityEvent.select(new AnnotationLiteral<SystemTest>() {}).fire(new
SecurityEvent());
+ assert alarm.getNumSecurityEvents() == 2;
+ assert alarm.getNumSystemTests() == 1;
+ assert alarm.getNumBreakIns() == 0;
+ assert alarm.getNumViolentBreakIns() == 0;
+
+ sensor.securityEvent.select(BreakInEvent.class).fire(new BreakInEvent());
+ assert alarm.getNumSecurityEvents() == 3;
+ assert alarm.getNumSystemTests() == 1;
+ assert alarm.getNumBreakIns() == 1;
+ assert alarm.getNumViolentBreakIns() == 0;
+
+ sensor.securityEvent.select(BreakInEvent.class, new
AnnotationLiteral<Violent>() {}).fire(new BreakInEvent());
+ assert alarm.getNumSecurityEvents() == 4;
+ assert alarm.getNumSystemTests() == 1;
+ assert alarm.getNumBreakIns() == 2;
+ assert alarm.getNumViolentBreakIns() == 1;
+ }
+
+ @Test(groups = { "ri-broken", "events" }, expectedExceptions =
IllegalArgumentException.class)
+ @SpecAssertion(section = "10.3.1", id = "eab")
+ public void testEventSelectThrowsExceptionIfEventTypeHasTypeVariable()
+ {
+ SecuritySensor sensor = getInstanceByType(SecuritySensor.class);
+ sensor.securityEvent.select(SecurityEvent_Illegal.class);
+ }
+
+ @Test(groups = "events", expectedExceptions =
IllegalArgumentException.class)
+ @SpecAssertion(section = "10.3.1", id = "eba")
+ public void testEventSelectThrowsExceptionForDuplicateBindingType()
+ {
+ SecuritySensor sensor = getInstanceByType(SecuritySensor.class);
+ sensor.securityEvent.select(new AnnotationLiteral<SystemTest>() {}, new
AnnotationLiteral<SystemTest>() {});
+ }
+
+ @Test(groups = "events", expectedExceptions =
IllegalArgumentException.class)
+ @SpecAssertion(section = "10.3.1", id = "eba")
+ public void testEventSelectWithSubtypeThrowsExceptionForDuplicateBindingType()
+ {
+ SecuritySensor sensor = getInstanceByType(SecuritySensor.class);
+ sensor.securityEvent.select(BreakInEvent.class, new
AnnotationLiteral<Violent>() {}, new AnnotationLiteral<Violent>() {});
+ }
+
+ @Test(groups = "events", expectedExceptions =
IllegalArgumentException.class)
+ @SpecAssertion(section = "10.3.1", id = "ec")
+ public void testEventSelectThrowsExceptionIfAnnotationIsNotBindingType()
+ {
+ SecuritySensor sensor = getInstanceByType(SecuritySensor.class);
+ sensor.securityEvent.select(new AnnotationLiteral<NotABindingType>() {});
+ }
+
+ @Test(groups = "events", expectedExceptions =
IllegalArgumentException.class)
+ @SpecAssertion(section = "10.3.1", id = "ec")
+ public void testEventSelectWithSubtypeThrowsExceptionIfAnnotationIsNotBindingType()
+ {
+ SecuritySensor sensor = getInstanceByType(SecuritySensor.class);
+ sensor.securityEvent.select(BreakInEvent.class, new
AnnotationLiteral<NotABindingType>() {});
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SystemTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SystemTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/SystemTest.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+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;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface SystemTest
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/Violent.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/Violent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/select/Violent.java 2009-07-24
02:26:26 UTC (rev 3184)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.event.select;
+
+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;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface Violent
+{
+}