Author: dan.j.allen
Date: 2009-07-27 19:51:48 -0400 (Mon, 27 Jul 2009)
New Revision: 3296
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/ConditionalEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/EventPayload.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/StockPrice.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/StockWatcher.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/ConditionalEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/ConditionalObserverTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/RecluseSpider.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/Spun.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/Web.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/AirConditioner.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/BatteryEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/BullTerrier.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/DisabledObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/DiskSpaceEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Ghost.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Heater.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/MultiBindingEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/NotEnabled.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Pomeranian.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/PriviledgedObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/ResolveEventObserversTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Role.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/RoleBinding.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Secret.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/SimpleEventType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/SystemMonitor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Tame.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/TameAnnotationLiteral.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Temperature.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Thermostat.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/EJBEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/PomeranianInterface.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/ResolveEnterpriseEventObserverTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/Spitz.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/TransactionalObserversTest.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnimalStereotype.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnimalStereotypeAnnotationLiteral.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/BananaSpider.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/BindingTypeNotRuntime.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ConditionalEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DisabledStringObserver.java
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/DoggiePoints.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EJBEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/LazyFarmer.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/NotABindingType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ObservedType1.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ObservedType2.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Pomeranian.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/PomeranianInterface.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/RecluseSpider.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SimpleEventType.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/Spun.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/TamingCommand.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TeaCupPomeranian.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Web.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/
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/fires/FireEventTest.java
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/ObserverTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Agent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DisobedientDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DogAgent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DogTrainer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/LargeDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Pomeranian.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/PomeranianInterface.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/ShowDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/SmallDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Tame.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Trainer.java
Log:
continue to reorganize event tests
move many tests from EventTest into more function-specific packages
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnimalStereotype.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnimalStereotype.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnimalStereotype.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,21 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.stereotype.Stereotype;
-
-@Stereotype()
-@Target( { TYPE, METHOD, FIELD })
-@Retention(RUNTIME)
-@RequestScoped
-@interface AnimalStereotype
-{
-
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnimalStereotypeAnnotationLiteral.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnimalStereotypeAnnotationLiteral.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnimalStereotypeAnnotationLiteral.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,8 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.inject.AnnotationLiteral;
-
-class AnimalStereotypeAnnotationLiteral extends AnnotationLiteral<AnimalStereotype>
implements AnimalStereotype
-{
-
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/BananaSpider.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/BananaSpider.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/BananaSpider.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,21 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.BeanManager;
-
-/**
- * Simple bean with observer method and another injectable parameter.
- */
-class BananaSpider
-{
- public void observeStringEvent(@Observes String event, BeanManager beanManager, @Spun
Web web)
- {
- assert event != null;
- assert !beanManager.resolveObserverMethods(event).isEmpty();
- if ("validate injected parameters".equals(event))
- {
- assert beanManager != null;
- assert web != null;
- }
- }
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/BindingTypeNotRuntime.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/BindingTypeNotRuntime.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/BindingTypeNotRuntime.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,18 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.SOURCE;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.inject.BindingType;
-
-@Target( { FIELD, PARAMETER })
-@Retention(SOURCE)
-@BindingType
-@interface BindingTypeNotRuntime
-{
-
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ConditionalEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ConditionalEvent.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ConditionalEvent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-class ConditionalEvent
-{
-
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DisabledStringObserver.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DisabledStringObserver.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DisabledStringObserver.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,14 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.event.Observes;
-
-class DisabledStringObserver
-{
- public void disabledObserver(@Observes String event)
- {
- if ("fail if disable observer invoked".equals(event))
- {
- assert false : "This observer should not be invoked since it resides on a
bean which is disabled";
- }
- }
-}
Deleted: 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
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DogWhisperer.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,21 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-
-class DogWhisperer
-{
- @Any @Tame @Role("Admin") Event<TamingCommand> tamingEvent;
-
- @Any Event<Praise> praiseEvent;
-
- public void issueTamingCommand()
- {
- tamingEvent.fire(new TamingCommand());
- }
-
- public void givePraise()
- {
- praiseEvent.fire(new Praise());
- }
-}
Deleted: 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 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/DoggiePoints.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,38 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-
-@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;
- }
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EJBEvent.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EJBEvent.java 2009-07-27
23:12:35 UTC (rev 3295)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EJBEvent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-class EJBEvent
-{
-
-}
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
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,15 +1,12 @@
package org.jboss.jsr299.tck.tests.event;
-import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Set;
-import javax.enterprise.event.Notify;
import javax.enterprise.event.TransactionPhase;
import javax.enterprise.inject.spi.ObserverMethod;
import org.jboss.jsr299.tck.AbstractJSR299Test;
-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;
@@ -28,90 +25,8 @@
@SpecVersion("20090625")
public class EventTest extends AbstractJSR299Test
{
- private static final String RESOLVE_OBSERVERS_METHOD_NAME =
"resolveObserverMethods";
-
- // --------- Below this line are tests that need to be evaluated to determine if they
need to be moved
-
@Test(groups = { "events" })
- @SpecAssertions({
- @SpecAssertion(section = "11.3.11", id = "a"),
- @SpecAssertion(section = "11.3.11", id = "b")
- })
- public void testBeanManagerResolveObserversSignature() throws Exception
- {
- assert
getCurrentManager().getClass().getDeclaredMethod(RESOLVE_OBSERVERS_METHOD_NAME,
Object.class, Annotation[].class) != null;
- }
-
- @Test(groups = { "events" })
- @SpecAssertions({
- @SpecAssertion(section = "10.5", id = "aa"),
- @SpecAssertion(section = "10.4.2", id = "a"),
- @SpecAssertion(section = "12.3", id = "oa")
- })
- public void testObserverMethodAutomaticallyRegistered()
- {
- assert !getCurrentManager().resolveObserverMethods(new String()).isEmpty();
- }
-
- @Test(groups = { "events", "broken" })
- @SpecAssertion(section = "12.3", id = "oa")
- public void testObserverMethodNotAutomaticallyRegisteredForDisabledBeans()
- {
- Set<ObserverMethod<?, String>> observers =
getCurrentManager().resolveObserverMethods(new String());
- assert observers.size() == 2;
- for (ObserverMethod<?, String> observer : observers)
- {
- // an assertion error will be raised if an inappropriate observer is called
- observer.notify("fail if disable observer invoked");
- }
- }
-
- @Test(groups = { "events" })
- @SpecAssertion(section = "10.4", id = "e")
- public void testMultipleObserverMethodsForSameEventPermissible()
- {
- assert getCurrentManager().resolveObserverMethods(new String()).size() > 1;
- }
-
- @Test(groups = { "events" })
- @SpecAssertion(section = "10.4", id = "f")
- public void testMultipleObserverMethodsOnBeanPermissible()
- {
- // Resolve the observers for types 1 and 2
- assert getCurrentManager().resolveObserverMethods(new ObservedType1()).size() ==
1;
-
- assert getCurrentManager().resolveObserverMethods(new ObservedType2()).size() ==
1;
- }
-
- @Test(groups = { "events", "ejb" })
- @SpecAssertion(section = "10.4", id = "d")
- public void testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic()
- {
- assert getCurrentManager().resolveObserverMethods(new EJBEvent()).size() == 2;
- }
-
- @Test(groups = { "events" })
- @SpecAssertion(section = "10.4.1", id = "b")
- public void testObserverMethodWithoutBindingTypesObservesEventsWithoutBindingTypes()
- {
- // Resolve registered observers with an event containing no binding types
- assert getCurrentManager().resolveObserverMethods(new SimpleEventType()).size() ==
2;
- }
-
- @Test(groups = { "events" })
@SpecAssertions( {
- @SpecAssertion(section = "10.4.2", id = "c"),
- @SpecAssertion(section = "10.2.2", id = "a"),
- @SpecAssertion(section = "10.2.3", id = "a")
- })
- public void testObserverMethodMayHaveMultipleBindingTypes()
- {
- // If we can resolve the observer with the two binding types, then it worked
- assert getCurrentManager().resolveObserverMethods(new MultiBindingEvent(), new
RoleBinding("Admin"), new TameAnnotationLiteral()).size() == 2;
- }
-
- @Test(groups = { "events" })
- @SpecAssertions( {
@SpecAssertion(section = "10.4.3", id = "a"),
@SpecAssertion(section = "5.6.8", id = "c"),
@SpecAssertion(section = "2.3.5", id = "ca"),
@@ -123,37 +38,6 @@
}
@Test(groups = { "events" })
- @SpecAssertions( {
- @SpecAssertion(section = "10.4.4", id = "a"),
- @SpecAssertion(section = "5.6.8", id = "ba")
- } )
- public void testConditionalObserver()
- {
- RecluseSpider.reset();
- getCurrentManager().fireEvent(new ConditionalEvent());
- // Should not be notified since bean is not instantiated yet
- assert !RecluseSpider.isNotified();
-
- // Now instantiate the bean and fire another event
- RecluseSpider bean = getInstanceByType(RecluseSpider.class);
- assert bean != null;
- // Must invoke a method to really create the instance
- assert !bean.isInstanceNotified();
- getCurrentManager().fireEvent(new ConditionalEvent());
- assert RecluseSpider.isNotified() && bean.isInstanceNotified();
-
- RecluseSpider.reset();
- }
-
- @Test(groups = { "events" })
- @SpecAssertion(section = "10.5", id = "aa")
- public void testObserverMethodRegistration()
- {
- // Resolve registered observers with an event containing no binding types
- assert getCurrentManager().resolveObserverMethods(new SimpleEventType()).size() ==
2;
- }
-
- @Test(groups = { "events" })
@SpecAssertions({
@SpecAssertion(section = "10.5", id = "review"), // was b
@SpecAssertion(section = "10.5", id = "review") // was h
@@ -204,17 +88,6 @@
assert Shop.deliveryObservedBy.equals(FarmShop.class.getName());
}
- @Test(groups = { "events" })
- @SpecAssertion(section = "5.6.8", id = "ba")
- public void testObserverMethodInvokedOnReturnedInstanceFromContext()
- {
- RecluseSpider spider = getInstanceByType(RecluseSpider.class);
- spider.setWeb(new Web());
- getCurrentManager().fireEvent(new ConditionalEvent());
- assert spider.isInstanceNotified();
- assert spider.getWeb().getRings() == 1;
- }
-
@Test(groups = { "events", "broken" })
@SpecAssertion(section = "10.5", id = "ca")
public void testAsynchronousObserverThrowsExceptionIsLogged() throws
InterruptedException
@@ -305,50 +178,6 @@
}
@Test(groups = { "events" })
- @SpecAssertion(section = "11.1.3", id = "b")
- public void testGetBeanOnObserverMethod()
- {
- Set<ObserverMethod<?, StockPrice>> observers =
getCurrentManager().resolveObserverMethods(new StockPrice());
- assert observers.size() == 1;
- ObserverMethod<?, StockPrice> observerMethod = observers.iterator().next();
- assert observerMethod.getBean().getBeanClass().equals(StockWatcher.class);
- }
-
- @Test(groups = { "events" })
- @SpecAssertion(section = "11.1.3", id = "c")
- public void testGetObservedTypeOnObserverMethod()
- {
- Set<ObserverMethod<?, StockPrice>> observers =
getCurrentManager().resolveObserverMethods(new StockPrice());
- assert observers.size() == 1;
- ObserverMethod<?, ?> observerMethod = observers.iterator().next();
- assert observerMethod.getObservedType().equals(StockPrice.class);
- }
-
- @Test(groups = { "events" })
- @SpecAssertion(section = "11.1.3", id = "c")
- public void testGetObservedBindingsOnObserverMethod()
- {
- Set<ObserverMethod<?, StockPrice>> observers =
getCurrentManager().resolveObserverMethods(new StockPrice());
- assert observers.size() == 1;
- ObserverMethod<?, ?> observerMethod = observers.iterator().next();
- assert observerMethod.getObservedBindings().size() == 1;
- assert observerMethod.getObservedBindings().contains(new CurrentLiteral());
- }
-
- @Test(groups = { "events" })
- @SpecAssertion(section = "11.1.3", id = "d")
- public void testGetNotifyOnObserverMethod()
- {
- Set<ObserverMethod<?, StockPrice>> observers =
getCurrentManager().resolveObserverMethods(new StockPrice());
- assert observers.size() == 1;
- assert observers.iterator().next().getNotify().equals(Notify.ALWAYS);
-
- Set<ObserverMethod<?, ConditionalEvent>> conditionalObservers =
getCurrentManager().resolveObserverMethods(new ConditionalEvent());
- assert !conditionalObservers.isEmpty();
- assert
conditionalObservers.iterator().next().getNotify().equals(Notify.IF_EXISTS);
- }
-
- @Test(groups = { "events" })
@SpecAssertion(section = "11.1.3", id = "e")
public void testGetTransactionPhaseOnObserverMethod()
{
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/LazyFarmer.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/LazyFarmer.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/LazyFarmer.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,7 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-
-class LazyFarmer extends Farmer
-{
-
-}
Deleted: 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
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/MagicString.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,54 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-class MagicString
-{
- private static boolean equalsUsed = false;
- private final String value;
-
- public MagicString(String value)
- {
- this.value = value;
- }
-
- public int compareTo(String anotherString)
- {
- return value.compareTo(anotherString);
- }
-
- public int compareToIgnoreCase(String str)
- {
- return value.compareToIgnoreCase(str);
- }
-
- @Override
- public boolean equals(Object anObject)
- {
- return value.equals(anObject);
- }
-
- @Override
- public int hashCode()
- {
- return value.hashCode();
- }
-
- public boolean isEmpty()
- {
- return value == null || value.length() == 0;
- }
-
- public int length()
- {
- return value.length();
- }
-
- public boolean matches(String regex)
- {
- return value.matches(regex);
- }
-
- public static boolean isEqualsUsed()
- {
- return equalsUsed;
- }
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/NotABindingType.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/NotABindingType.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/NotABindingType.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,15 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-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;
-
-@Target( { FIELD, PARAMETER })
-@Retention(RUNTIME)
-@interface NotABindingType
-{
-
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ObservedType1.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ObservedType1.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ObservedType1.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-class ObservedType1
-{
-
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ObservedType2.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ObservedType2.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/ObservedType2.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-class ObservedType2
-{
-
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Pomeranian.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Pomeranian.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Pomeranian.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,23 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Named;
-
-@Named("Teddy")
-class Pomeranian
-{
- public static Thread notificationThread;
-
- public void observeSimpleEvent(@Observes SimpleEventType someEvent)
- {
- notificationThread = Thread.currentThread();
- }
-
- public void observerTameSimpleEvent(@Observes @Tame SimpleEventType someEvent)
- {
- }
-
- public static void staticallyObserveEvent(@Observes SimpleEventType someEvent)
- {
- }
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/PomeranianInterface.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/PomeranianInterface.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/PomeranianInterface.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,10 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.ejb.Local;
-import javax.enterprise.event.Observes;
-
-@Local
-public interface PomeranianInterface
-{
- public void observeSimpleEvent(@Observes EJBEvent someEvent);
-}
Deleted: 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 2009-07-27
23:12:35 UTC (rev 3295)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Praise.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,5 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-class Praise
-{
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/RecluseSpider.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/RecluseSpider.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/RecluseSpider.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,52 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Notify;
-import javax.enterprise.event.Observes;
-
-/**
- * Simple web bean that conditionally listens to events.
- *
- */
-@RequestScoped
-class RecluseSpider
-{
- private static boolean notified = false;
- private boolean instanceNotified = false;
- private Web web;
-
- public void observe(@Observes(notifyObserver = Notify.IF_EXISTS) ConditionalEvent
someEvent)
- {
- notified = true;
- instanceNotified = true;
- if (web != null)
- {
- web.addRing();
- }
- }
-
- public boolean isInstanceNotified()
- {
- return instanceNotified;
- }
-
- public static boolean isNotified()
- {
- return notified;
- }
-
- public static void reset()
- {
- notified = false;
- }
-
- public void setWeb(Web web)
- {
- this.web = web;
- }
-
- public Web getWeb()
- {
- return this.web;
- }
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SimpleEventType.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SimpleEventType.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SimpleEventType.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-class SimpleEventType
-{
-
-}
Deleted: 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
23:12:35 UTC (rev 3295)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Spitz.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,20 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.ejb.Stateful;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Named;
-
-public
-@Stateful
-@Tame
-@Named("Teddy")
-class Spitz implements PomeranianInterface
-{
- public void observeSimpleEvent(@Observes EJBEvent someEvent)
- {
- }
-
- public static void staticallyObserveEvent(@Observes EJBEvent someEvent)
- {
- }
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Spun.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Spun.java 2009-07-27
23:12:35 UTC (rev 3295)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Spun.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,21 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-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 Spun
-{
-}
Deleted: 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
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/SweeWaxbill.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,14 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-
-class SweeWaxbill
-{
- private @Any @Role("Admin") Event<String> simpleEvent;
-
- public void methodThatReselectsAndFiresEvent()
- {
- simpleEvent.select(new RoleBinding("Admin")).fire("string
event");
- }
-}
Deleted: 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 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TamingCommand.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,5 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-class TamingCommand
-{
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TeaCupPomeranian.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TeaCupPomeranian.java 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/TeaCupPomeranian.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,30 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Named;
-
-@Tame
-@Named("Teddy")
-class TeaCupPomeranian
-{
- public static class OversizedException extends RuntimeException
- {
- private static final long serialVersionUID = 1L;
-
- }
-
- public static class TooSmallException extends Exception
- {
- private static final long serialVersionUID = 1L;
- }
-
- public void observeSimpleEvent(@Observes ObservedType1 someEvent)
- {
- throw new OversizedException();
- }
-
- public void observeAnotherSimpleEvent(@Observes ObservedType2 someEvent) throws
TooSmallException
- {
- throw new TooSmallException();
- }
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Web.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Web.java 2009-07-27
23:12:35 UTC (rev 3295)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/Web.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,21 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-@Spun class Web
-{
- private int rings = 0;
-
- public void addRing()
- {
- this.rings++;
- }
-
- public void setRings(int rings)
- {
- this.rings = rings;
- }
-
- public int getRings()
- {
- return this.rings;
- }
-}
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
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -36,7 +36,7 @@
@Test(groups = { "events" })
@SpecAssertions({
- // These two assertions combine to create a testable assertion
+ // these two assertions combine to create a logical, testable assertion
@SpecAssertion(section = "11.3.10", id = "a"),
@SpecAssertion(section = "11.3.10", id = "b")
})
Modified:
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 2009-07-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/AnotherObserver.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,5 +1,6 @@
package org.jboss.jsr299.tck.tests.event.observer;
+import javax.enterprise.event.Notify;
import javax.enterprise.event.Observes;
class AnotherObserver
@@ -10,4 +11,8 @@
{
wasNotified = true;
}
+
+ void conditionalObserve(@Observes(notifyObserver = Notify.IF_EXISTS) ConditionalEvent
e)
+ {
+ }
}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/ConditionalEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/ConditionalEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/ConditionalEvent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.observer;
+
+class ConditionalEvent
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/EventPayload.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/EventPayload.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/EventPayload.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.event.observer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class EventPayload
+{
+ private List<Class<?>> classesVisited = new
ArrayList<Class<?>>();
+
+ public List<Class<?>> getClassesVisited()
+ {
+ return classesVisited;
+ }
+
+ public void recordVisit(Object o)
+ {
+ classesVisited.add(o.getClass());
+ }
+}
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-27
23:12:35 UTC (rev 3295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/ObserverTest.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,11 +1,16 @@
package org.jboss.jsr299.tck.tests.event.observer;
import java.lang.annotation.Annotation;
+import java.util.Set;
+import javax.enterprise.event.Notify;
+import javax.enterprise.inject.spi.ObserverMethod;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+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.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -43,5 +48,48 @@
assert AnObserver.wasNotified;
assert !AnotherObserver.wasNotified;
}
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "11.1.3", id = "b")
+ public void testGetBeanOnObserverMethod()
+ {
+ Set<ObserverMethod<?, StockPrice>> observers =
getCurrentManager().resolveObserverMethods(new StockPrice());
+ assert observers.size() == 1;
+ ObserverMethod<?, StockPrice> observerMethod = observers.iterator().next();
+ assert observerMethod.getBean().getBeanClass().equals(StockWatcher.class);
+ }
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "11.1.3", id = "c")
+ public void testGetObservedTypeOnObserverMethod()
+ {
+ Set<ObserverMethod<?, StockPrice>> observers =
getCurrentManager().resolveObserverMethods(new StockPrice());
+ assert observers.size() == 1;
+ ObserverMethod<?, ?> observerMethod = observers.iterator().next();
+ assert observerMethod.getObservedType().equals(StockPrice.class);
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "11.1.3", id = "c")
+ public void testGetObservedBindingsOnObserverMethod()
+ {
+ Set<ObserverMethod<?, StockPrice>> observers =
getCurrentManager().resolveObserverMethods(new StockPrice());
+ assert observers.size() == 1;
+ ObserverMethod<?, ?> observerMethod = observers.iterator().next();
+ assert observerMethod.getObservedBindings().size() == 1;
+ assert observerMethod.getObservedBindings().contains(new CurrentLiteral());
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "11.1.3", id = "d")
+ public void testGetNotifyOnObserverMethod()
+ {
+ Set<ObserverMethod<?, StockPrice>> observers =
getCurrentManager().resolveObserverMethods(new StockPrice());
+ assert observers.size() == 1;
+ assert observers.iterator().next().getNotify().equals(Notify.ALWAYS);
+
+ Set<ObserverMethod<?, ConditionalEvent>> conditionalObservers =
getCurrentManager().resolveObserverMethods(new ConditionalEvent());
+ assert !conditionalObservers.isEmpty();
+ assert
conditionalObservers.iterator().next().getNotify().equals(Notify.IF_EXISTS);
+ }
+
}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/StockPrice.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/StockPrice.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/StockPrice.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.observer;
+
+class StockPrice extends EventPayload
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/StockWatcher.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/StockWatcher.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/StockWatcher.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.event.observer;
+
+import javax.enterprise.event.Observes;
+
+class StockWatcher
+{
+ private static Class<?> observerClazz;
+
+ public void observeStockPrice(@Observes StockPrice price)
+ {
+ observerClazz = this.getClass();
+ price.recordVisit(this);
+ }
+
+ public static Class<?> getObserverClazz()
+ {
+ return observerClazz;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/ConditionalEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/ConditionalEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/ConditionalEvent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.observer.conditional;
+
+class ConditionalEvent
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/ConditionalObserverTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/ConditionalObserverTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/ConditionalObserverTest.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,67 @@
+package org.jboss.jsr299.tck.tests.event.observer.conditional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.event.Notify;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+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.testng.annotations.Test;
+
+@Artifact
+@SpecVersion("20090625")
+public class ConditionalObserverTest extends AbstractJSR299Test
+{
+ @Test(groups = { "events", "broken" })
+ @SpecAssertions( {
+ @SpecAssertion(section = "5.6.8", id = "ba"),
+ @SpecAssertion(section = "10.4.4", id = "a")
+ } )
+ public void testConditionalObserver()
+ {
+ RecluseSpider.reset();
+ getCurrentManager().fireEvent(new ConditionalEvent());
+ // Should not be notified since bean is not instantiated yet
+ assert !RecluseSpider.isNotified();
+
+ // Now instantiate the bean and fire another event
+ RecluseSpider bean = getInstanceByType(RecluseSpider.class);
+ assert bean != null;
+ // Must invoke a method to really create the instance
+ assert !bean.isInstanceNotified();
+ getCurrentManager().fireEvent(new ConditionalEvent());
+ assert RecluseSpider.isNotified() && bean.isInstanceNotified();
+
+ RecluseSpider.reset();
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "5.6.8", id = "ba")
+ public void testObserverMethodInvokedOnReturnedInstanceFromContext()
+ {
+ RecluseSpider spider = getInstanceByType(RecluseSpider.class);
+ spider.setWeb(new Web());
+ getCurrentManager().fireEvent(new ConditionalEvent());
+ assert spider.isInstanceNotified();
+ assert spider.getWeb().getRings() == 1;
+ }
+
+ @Test
+ @SpecAssertion(section = "10.4.4", id = "c")
+ public void testNotifyEnumerationContainsNotifyValues()
+ {
+ assert Notify.values().length == 2;
+ List<String> notifyValueNames = new ArrayList<String>();
+ for (Notify value : Notify.values())
+ {
+ notifyValueNames.add(value.name());
+ }
+
+ assert notifyValueNames.contains("IF_EXISTS");
+ assert notifyValueNames.contains("ALWAYS");
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/RecluseSpider.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/RecluseSpider.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/RecluseSpider.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,52 @@
+package org.jboss.jsr299.tck.tests.event.observer.conditional;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Notify;
+import javax.enterprise.event.Observes;
+
+/**
+ * Simple web bean that conditionally listens to events.
+ *
+ */
+@RequestScoped
+class RecluseSpider
+{
+ private static boolean notified = false;
+ private boolean instanceNotified = false;
+ private Web web;
+
+ public void observe(@Observes(notifyObserver = Notify.IF_EXISTS) ConditionalEvent
someEvent)
+ {
+ notified = true;
+ instanceNotified = true;
+ if (web != null)
+ {
+ web.addRing();
+ }
+ }
+
+ public boolean isInstanceNotified()
+ {
+ return instanceNotified;
+ }
+
+ public static boolean isNotified()
+ {
+ return notified;
+ }
+
+ public static void reset()
+ {
+ notified = false;
+ }
+
+ public void setWeb(Web web)
+ {
+ this.web = web;
+ }
+
+ public Web getWeb()
+ {
+ return this.web;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/Spun.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/Spun.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/Spun.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.event.observer.conditional;
+
+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 Spun
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/Web.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/Web.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/conditional/Web.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.event.observer.conditional;
+
+@Spun class Web
+{
+ private int rings = 0;
+
+ public void addRing()
+ {
+ this.rings++;
+ }
+
+ public void setRings(int rings)
+ {
+ this.rings = rings;
+ }
+
+ public int getRings()
+ {
+ return this.rings;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/AirConditioner.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/AirConditioner.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/AirConditioner.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,32 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import javax.enterprise.event.Observes;
+
+public class AirConditioner
+{
+ private Temperature target;
+
+ private boolean on = false;
+
+ public void setTargetTemperature(Temperature target)
+ {
+ this.target = target;
+ }
+
+ public void temperatureChanged(@Observes Temperature temperature)
+ {
+ if (on && temperature.getDegrees() <= target.getDegrees())
+ {
+ on = false;
+ }
+ else if (!on && temperature.getDegrees() > target.getDegrees())
+ {
+ on = true;
+ }
+ }
+
+ public boolean isOn()
+ {
+ return on;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/BatteryEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/BatteryEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/BatteryEvent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+class BatteryEvent
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/BullTerrier.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/BullTerrier.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/BullTerrier.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,35 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import javax.enterprise.event.Observes;
+
+class BullTerrier
+{
+ private static boolean multiBindingEventObserved = false;
+ private static boolean singleBindingEventObserved = false;
+
+ public void observesMultiBindingEvent(@Observes @Role("Admin") @Tame
MultiBindingEvent someEvent)
+ {
+ multiBindingEventObserved = true;
+ }
+
+ public void observesSingleBindingEvent(@Observes @Tame MultiBindingEvent someEvent)
+ {
+ singleBindingEventObserved = true;
+ }
+
+ public static boolean isMultiBindingEventObserved()
+ {
+ return multiBindingEventObserved;
+ }
+
+ public static boolean isSingleBindingEventObserved()
+ {
+ return singleBindingEventObserved;
+ }
+
+ public static void reset()
+ {
+ multiBindingEventObserved = false;
+ singleBindingEventObserved = false;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/DisabledObserver.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/DisabledObserver.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/DisabledObserver.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import javax.enterprise.event.Observes;
+
+@NotEnabled class DisabledObserver
+{
+ public void observeSecret(@Observes @Secret String secretString)
+ {
+ if ("fail if disabled observer invoked".equals(secretString))
+ {
+ assert false : "This observer should not be invoked since it resides on a
bean with a policy that is not enabled.";
+ }
+ }
+
+ public void observeGhost(@Observes Ghost ghost)
+ {
+ assert false : "This observer should not be invoked since it resides on a bean
with a policy that is not enabled.";
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/DiskSpaceEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/DiskSpaceEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/DiskSpaceEvent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+class DiskSpaceEvent
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Ghost.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Ghost.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Ghost.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+class Ghost
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Heater.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Heater.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Heater.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,32 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import javax.enterprise.event.Observes;
+
+public class Heater
+{
+ private Temperature target;
+
+ private boolean on = false;
+
+ public void setTargetTemperature(Temperature target)
+ {
+ this.target = target;
+ }
+
+ public void temperatureChanged(@Observes Temperature temperature)
+ {
+ if (on && temperature.getDegrees() > target.getDegrees())
+ {
+ on = false;
+ }
+ else if (!on && temperature.getDegrees() <= target.getDegrees())
+ {
+ on = true;
+ }
+ }
+
+ public boolean isOn()
+ {
+ return on;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/MultiBindingEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/MultiBindingEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/MultiBindingEvent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+class MultiBindingEvent
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/NotEnabled.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/NotEnabled.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/NotEnabled.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,35 @@
+/*
+ * 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.observer.resolve;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Policy;
+import javax.enterprise.inject.stereotype.Stereotype;
+
+@Stereotype
+@Policy
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@interface NotEnabled
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Pomeranian.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Pomeranian.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Pomeranian.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,23 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Named;
+
+@Named("Teddy")
+class Pomeranian
+{
+ public static Thread notificationThread;
+
+ public void observeSimpleEvent(@Observes SimpleEventType someEvent)
+ {
+ notificationThread = Thread.currentThread();
+ }
+
+ public void observerTameSimpleEvent(@Observes @Tame SimpleEventType someEvent)
+ {
+ }
+
+ public static void staticallyObserveEvent(@Observes SimpleEventType someEvent)
+ {
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/PriviledgedObserver.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/PriviledgedObserver.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/PriviledgedObserver.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import javax.enterprise.event.Observes;
+
+class PriviledgedObserver
+{
+ public void observeSecret(@Observes @Secret String secretString)
+ {
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/ResolveEventObserversTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/ResolveEventObserversTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/ResolveEventObserversTest.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,121 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.enterprise.inject.spi.ObserverMethod;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+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.testng.annotations.Test;
+
+@Artifact
+@SpecVersion("20090625")
+public class ResolveEventObserversTest extends AbstractJSR299Test
+{
+ private static final String BEAN_MANAGER_RESOLVE_OBSERVERS_METHOD_NAME =
"resolveObserverMethods";
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.4", id = "e")
+ public void testMultipleObserverMethodsForSameEventPermissible()
+ {
+ assert getCurrentManager().resolveObserverMethods(new Temperature(0)).size() == 2;
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.4", id = "f")
+ public void testMultipleObserverMethodsOnBeanPermissible()
+ {
+ assert getCurrentManager().resolveObserverMethods(new BatteryEvent()).size() == 1;
+ assert getCurrentManager().resolveObserverMethods(new DiskSpaceEvent()).size() ==
1;
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.4.2", id = "a")
+ public void testMethodWithParameterAnnotatedWithObservesRegistersObserverMethod()
throws SecurityException, NoSuchMethodException
+ {
+ Set<ObserverMethod<?, Temperature>> temperatureObservers =
getCurrentManager().resolveObserverMethods(new Temperature(0d));
+ assert temperatureObservers.size() > 1;
+ ObserverMethod<?, Temperature> temperatureObserver =
temperatureObservers.iterator().next();
+ assert temperatureObserver.getBean() == getUniqueBean(AirConditioner.class);
+ assert temperatureObserver.getObservedType().equals(Temperature.class);
+
+ Method method = AirConditioner.class.getMethod("temperatureChanged",
Temperature.class);
+ assert method != null;
+ assert method.getParameterTypes().length == 1;
+ assert method.getParameterTypes()[0].equals(Temperature.class);
+ assert
method.getParameterAnnotations()[0][0].annotationType().equals(Observes.class);
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.4.1", id = "b")
+ public void testObserverMethodWithoutBindingTypesObservesEventsWithoutBindingTypes()
+ {
+ // Resolve registered observers with an event containing no binding types
+ assert getCurrentManager().resolveObserverMethods(new SimpleEventType()).size() ==
2;
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertions( {
+ @SpecAssertion(section = "10.4.2", id = "c"),
+ @SpecAssertion(section = "10.2.2", id = "a"),
+ @SpecAssertion(section = "10.2.3", id = "a")
+ })
+ public void testObserverMethodMayHaveMultipleBindingTypes()
+ {
+ // If we can resolve the observer with the two binding types, then it worked
+ assert getCurrentManager().resolveObserverMethods(new MultiBindingEvent(), new
RoleBinding("Admin"), new TameAnnotationLiteral()).size() == 2;
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "10.5", id = "aa")
+ public void testObserverMethodRegistration()
+ {
+ // Resolve registered observers with an event containing no binding types
+ assert getCurrentManager().resolveObserverMethods(new SimpleEventType()).size() ==
2;
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertions({
+ // these two assertions combine to create a logical, testable assertion
+ @SpecAssertion(section = "11.3.11", id = "a"),
+ @SpecAssertion(section = "11.3.11", id = "b")
+ })
+ public void testBeanManagerResolveObserversSignature() throws Exception
+ {
+ assert
getCurrentManager().getClass().getDeclaredMethod(BEAN_MANAGER_RESOLVE_OBSERVERS_METHOD_NAME,
Object.class, Annotation[].class) != null;
+ }
+
+ @Test(groups = { "events" })
+ @SpecAssertion(section = "12.3", id = "oa")
+ public void testObserverMethodAutomaticallyRegistered()
+ {
+ assert !getCurrentManager().resolveObserverMethods(new Ghost()).isEmpty();
+ assert !getCurrentManager().resolveObserverMethods(new String(), new
AnnotationLiteral<Secret>() {}).isEmpty();
+ }
+
+ // WBRI-317
+ // when this bug is fixed, also add a test that verifies that if a policy is enabled,
the obserer methods on the bean also get registered
+ @Test(groups = { "events", "ri-broken" })
+ @SpecAssertion(section = "12.3", id = "oa")
+ public void testObserverMethodNotAutomaticallyRegisteredForDisabledBeans()
+ {
+ Set<ObserverMethod<?, Ghost>> ghostObservers =
getCurrentManager().resolveObserverMethods(new Ghost());
+ assert ghostObservers.size() == 0;
+
+ Set<ObserverMethod<?, String>> stringObservers =
getCurrentManager().resolveObserverMethods(new String(), new
AnnotationLiteral<Secret>() {});
+ assert stringObservers.size() == 1;
+ for (ObserverMethod<?, String> observer : stringObservers)
+ {
+ // an assertion error will be raised if an inappropriate observer is called
+ observer.notify("fail if disabled observer invoked");
+ }
+ }
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Role.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Role.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Role.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+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;
+
+@Target( { FIELD, PARAMETER })
+@Retention(RUNTIME)
+@BindingType
+@interface Role
+{
+ String value();
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/RoleBinding.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/RoleBinding.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/RoleBinding.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import javax.enterprise.inject.AnnotationLiteral;
+
+
+class RoleBinding extends AnnotationLiteral<Role> implements Role
+{
+ private String value = null;
+
+ public RoleBinding(String value)
+ {
+ this.value = value;
+ }
+
+ public String value()
+ {
+ return value;
+ }
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Secret.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Secret.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Secret.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+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 Secret
+{
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/SimpleEventType.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/SimpleEventType.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/SimpleEventType.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+class SimpleEventType
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/SystemMonitor.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/SystemMonitor.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/SystemMonitor.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+import javax.enterprise.event.Observes;
+
+class SystemMonitor
+{
+ public void lowBattery(@Observes BatteryEvent e)
+ {
+ }
+
+ public void lowDiskSpace(@Observes DiskSpaceEvent e)
+ {
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Tame.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Tame.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Tame.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+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 Tame
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/TameAnnotationLiteral.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/TameAnnotationLiteral.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/TameAnnotationLiteral.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+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/observer/resolve/Temperature.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Temperature.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Temperature.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,17 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+class Temperature
+{
+ private double degrees;
+
+ public Temperature(double degrees)
+ {
+ this.degrees = degrees;
+ }
+
+ public double getDegrees()
+ {
+ return degrees;
+ }
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Thermostat.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Thermostat.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/Thermostat.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve;
+
+class Thermostat
+{
+ public void notifyTemperatureChanged(Temperature temperature)
+ {
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/EJBEvent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/EJBEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/EJBEvent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve.enterprise;
+
+class EJBEvent
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/PomeranianInterface.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/PomeranianInterface.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/PomeranianInterface.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve.enterprise;
+
+import javax.ejb.Local;
+import javax.enterprise.event.Observes;
+
+@Local
+public interface PomeranianInterface
+{
+ public void observeSimpleEvent(@Observes EJBEvent someEvent);
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/ResolveEnterpriseEventObserverTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/ResolveEnterpriseEventObserverTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/ResolveEnterpriseEventObserverTest.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve.enterprise;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+@SpecVersion("20090625")
+public class ResolveEnterpriseEventObserverTest extends AbstractJSR299Test
+{
+ @Test(groups = { "events", "ejb" })
+ @SpecAssertion(section = "10.4", id = "d")
+ public void testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic()
+ {
+ assert getCurrentManager().resolveObserverMethods(new EJBEvent()).size() == 2;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/Spitz.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/Spitz.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/resolve/enterprise/Spitz.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,17 @@
+package org.jboss.jsr299.tck.tests.event.observer.resolve.enterprise;
+
+import javax.ejb.Stateful;
+import javax.enterprise.event.Observes;
+
+public
+@Stateful
+class Spitz implements PomeranianInterface
+{
+ public void observeSimpleEvent(@Observes EJBEvent someEvent)
+ {
+ }
+
+ public static void staticallyObserveEvent(@Observes EJBEvent someEvent)
+ {
+ }
+}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional (from
rev 3271,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers)
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Agent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Agent.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Agent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
import javax.ejb.Local;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DisobedientDog.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DisobedientDog.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
class DisobedientDog
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DogAgent.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogAgent.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DogAgent.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
import static javax.ejb.TransactionManagementType.BEAN;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DogTrainer.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/DogTrainer.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
import static javax.ejb.TransactionManagementType.BEAN;
import static javax.enterprise.event.TransactionPhase.BEFORE_COMPLETION;
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/EventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/EventTest.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,188 +0,0 @@
-/*
- * 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.transactionalObservers;
-
-import java.lang.annotation.Annotation;
-import java.math.BigInteger;
-
-import javax.ejb.EJBException;
-import javax.enterprise.inject.AnnotationLiteral;
-
-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.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Packaging;
-import org.jboss.testharness.impl.packaging.PackagingType;
-import org.testng.annotations.Test;
-
-/**
- * Integration tests for Web Bean events.
- *
- * @author David Allen
- *
- */
-@Artifact
-(a)Packaging(PackagingType.EAR)
-@IntegrationTest
-@SpecVersion("20090625")
-public class EventTest extends AbstractJSR299Test
-{
-
- private static final Annotation TAME_LITERAL = new AnnotationLiteral<Tame>()
- {
- };
- private PomeranianInterface dog = null;
-
- @Override
- public void beforeMethod()
- {
- super.beforeMethod();
- dog = (PomeranianInterface) getInstanceByName("Teddy");
- }
-
-// @AfterMethod(alwaysRun = true)
-// public void teardownTest()
-// {
-// try
-// {
-// dog.removeSessionBean();
-// }
-// catch (Exception e)
-// {
-// // Not important since the bean is now gone one way or the other
-// }
-// }
-
- @Test(groups = { "events", "integration" })
- @SpecAssertion(section = "10.4.5", id = "a")
- public void testTransactionalObserverNotifiedImmediatelyWhenNoTransactionInProgress()
- {
- dog.setCorrectContext(false);
- dog.setCorrectTransactionState(false);
- Agent dogAgent = getInstanceByType(Agent.class);
- assert dogAgent != null;
- dogAgent.sendOutsideTransaction(BigInteger.TEN);
- assert dog.isCorrectTransactionState();
- // TODO Fix the security contexts
- // assert dog.isCorrectContext();
- }
-
- @Test(groups = { "events", "integration", "broken" })
- @SpecAssertion(section = "10.4.5", id = "c")
- public void testAfterTransactionCompletionObserver() throws InterruptedException
- {
- dog.setCorrectContext(false);
- dog.setCorrectTransactionState(false);
- assert !getCurrentManager().resolveObserverMethods("event").isEmpty();
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction("event");
- Thread.sleep(100);
- assert dog.isCorrectTransactionState();
- }
-
- @Test(groups = { "events", "integration", "broken" })
- @SpecAssertion(section = "10.4.5", id = "d")
- public void testAfterTransactionSuccessObserver() throws InterruptedException
- {
- dog.setCorrectContext(false);
- dog.setCorrectTransactionState(false);
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction(new Integer(4));
- Thread.sleep(100);
- assert dog.isCorrectTransactionState();
- }
-
- @Test(groups = { "events", "integration", "ri-broken"
})
- @SpecAssertion(section = "10.4.5", id = "e")
- // WBRI-303
- public void testAfterTransactionFailureObserver() throws InterruptedException
- {
- dog.setCorrectContext(false);
- dog.setCorrectTransactionState(false);
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction(new Float(4.0));
- Thread.sleep(100);
- assert dog.isCorrectTransactionState();
- }
-
- @Test(groups = { "events", "integration", "broken" })
- @SpecAssertions( {
- @SpecAssertion(section = "10.4.5", id = "b"),
- @SpecAssertion(section = "10.4.5", id = "e") })
- public void testBeforeTransactionCompletionObserver()
- {
- dog.setCorrectContext(false);
- dog.setCorrectTransactionState(false);
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction(new RuntimeException("test event"));
- assert dog.isCorrectTransactionState();
- // TODO Fix the security contexts
- // assert dog.isCorrectContext();
- }
-
- @Test(groups = { "events", "ri-broken" })
- @SpecAssertion(section = "review", id = "review") // the spec now
only mentions asynchronous observer methods in passing
- // WBRI-303
- public void testAsynchronousObserverAlsoTransactional() throws InterruptedException
- {
- dog.setCorrectContext(false);
- dog.setCorrectTransactionState(false);
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction('a');
- Thread.sleep(200);
- assert dog.isCorrectTransactionState();
- }
-
- @Test(groups = { "events", "integration" })
- @SpecAssertion(section = "10.5", id = "bd")
- public void testObserverCanSetRollbackOnlyOnTransaction()
- {
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction(new DisobedientDog());
- }
-
- @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
- @SpecAssertion(section = "10.5", id = "bd")
- // WBRI-303
- public void testObserverCannotInitiateJtaTransaction()
- {
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction(new ShowDog());
- }
-
- @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
- @SpecAssertion(section = "10.5", id = "bd")
- // WBRI-303
- public void testObserverCannotCommitJtaTransaction()
- {
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction(new LargeDog());
- }
-
- @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
- @SpecAssertion(section = "10.5", id = "bd")
- // WBRI-303
- public void testObserverCannotRollbackJtaTransaction()
- {
- Agent dogAgent = getInstanceByType(Agent.class);
- dogAgent.sendInTransaction(new SmallDog());
- }
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/LargeDog.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/LargeDog.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
public class LargeDog
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Pomeranian.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Pomeranian.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Pomeranian.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
import static javax.ejb.TransactionManagementType.BEAN;
import static javax.enterprise.event.TransactionPhase.AFTER_COMPLETION;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/PomeranianInterface.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/PomeranianInterface.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/PomeranianInterface.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
import java.math.BigInteger;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/ShowDog.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/ShowDog.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
public class ShowDog
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/SmallDog.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/SmallDog.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
public class SmallDog
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Tame.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Tame.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Tame.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Trainer.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java 2009-07-27
16:13:31 UTC (rev 3271)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/Trainer.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -1,4 +1,4 @@
-package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+package org.jboss.jsr299.tck.tests.event.observer.transactional;
import javax.ejb.Local;
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/TransactionalObserversTest.java
(from rev 3271,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/TransactionalObserversTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/transactional/TransactionalObserversTest.java 2009-07-27
23:51:48 UTC (rev 3296)
@@ -0,0 +1,188 @@
+/*
+ * 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.observer.transactional;
+
+import java.lang.annotation.Annotation;
+import java.math.BigInteger;
+
+import javax.ejb.EJBException;
+import javax.enterprise.inject.AnnotationLiteral;
+
+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.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+/**
+ * Integration tests for Web Bean events.
+ *
+ * @author David Allen
+ *
+ */
+@Artifact
+(a)Packaging(PackagingType.EAR)
+@IntegrationTest
+@SpecVersion("20090625")
+public class TransactionalObserversTest extends AbstractJSR299Test
+{
+
+ private static final Annotation TAME_LITERAL = new AnnotationLiteral<Tame>()
+ {
+ };
+ private PomeranianInterface dog = null;
+
+ @Override
+ public void beforeMethod()
+ {
+ super.beforeMethod();
+ dog = (PomeranianInterface) getInstanceByName("Teddy");
+ }
+
+// @AfterMethod(alwaysRun = true)
+// public void teardownTest()
+// {
+// try
+// {
+// dog.removeSessionBean();
+// }
+// catch (Exception e)
+// {
+// // Not important since the bean is now gone one way or the other
+// }
+// }
+
+ @Test(groups = { "events", "integration" })
+ @SpecAssertion(section = "10.4.5", id = "a")
+ public void testTransactionalObserverNotifiedImmediatelyWhenNoTransactionInProgress()
+ {
+ dog.setCorrectContext(false);
+ dog.setCorrectTransactionState(false);
+ Agent dogAgent = getInstanceByType(Agent.class);
+ assert dogAgent != null;
+ dogAgent.sendOutsideTransaction(BigInteger.TEN);
+ assert dog.isCorrectTransactionState();
+ // TODO Fix the security contexts
+ // assert dog.isCorrectContext();
+ }
+
+ @Test(groups = { "events", "integration", "broken" })
+ @SpecAssertion(section = "10.4.5", id = "c")
+ public void testAfterTransactionCompletionObserver() throws InterruptedException
+ {
+ dog.setCorrectContext(false);
+ dog.setCorrectTransactionState(false);
+ assert !getCurrentManager().resolveObserverMethods("event").isEmpty();
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction("event");
+ Thread.sleep(100);
+ assert dog.isCorrectTransactionState();
+ }
+
+ @Test(groups = { "events", "integration", "broken" })
+ @SpecAssertion(section = "10.4.5", id = "d")
+ public void testAfterTransactionSuccessObserver() throws InterruptedException
+ {
+ dog.setCorrectContext(false);
+ dog.setCorrectTransactionState(false);
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new Integer(4));
+ Thread.sleep(100);
+ assert dog.isCorrectTransactionState();
+ }
+
+ @Test(groups = { "events", "integration", "ri-broken"
})
+ @SpecAssertion(section = "10.4.5", id = "e")
+ // WBRI-303
+ public void testAfterTransactionFailureObserver() throws InterruptedException
+ {
+ dog.setCorrectContext(false);
+ dog.setCorrectTransactionState(false);
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new Float(4.0));
+ Thread.sleep(100);
+ assert dog.isCorrectTransactionState();
+ }
+
+ @Test(groups = { "events", "integration", "broken" })
+ @SpecAssertions( {
+ @SpecAssertion(section = "10.4.5", id = "b"),
+ @SpecAssertion(section = "10.4.5", id = "e") })
+ public void testBeforeTransactionCompletionObserver()
+ {
+ dog.setCorrectContext(false);
+ dog.setCorrectTransactionState(false);
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new RuntimeException("test event"));
+ assert dog.isCorrectTransactionState();
+ // TODO Fix the security contexts
+ // assert dog.isCorrectContext();
+ }
+
+ @Test(groups = { "events", "ri-broken" })
+ @SpecAssertion(section = "review", id = "review") // the spec now
only mentions asynchronous observer methods in passing
+ // WBRI-303
+ public void testAsynchronousObserverAlsoTransactional() throws InterruptedException
+ {
+ dog.setCorrectContext(false);
+ dog.setCorrectTransactionState(false);
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction('a');
+ Thread.sleep(200);
+ assert dog.isCorrectTransactionState();
+ }
+
+ @Test(groups = { "events", "integration" })
+ @SpecAssertion(section = "10.5", id = "bd")
+ public void testObserverCanSetRollbackOnlyOnTransaction()
+ {
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new DisobedientDog());
+ }
+
+ @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
+ @SpecAssertion(section = "10.5", id = "bd")
+ // WBRI-303
+ public void testObserverCannotInitiateJtaTransaction()
+ {
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new ShowDog());
+ }
+
+ @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
+ @SpecAssertion(section = "10.5", id = "bd")
+ // WBRI-303
+ public void testObserverCannotCommitJtaTransaction()
+ {
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new LargeDog());
+ }
+
+ @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
+ @SpecAssertion(section = "10.5", id = "bd")
+ // WBRI-303
+ public void testObserverCannotRollbackJtaTransaction()
+ {
+ Agent dogAgent = getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new SmallDog());
+ }
+}