[webbeans-commits] Webbeans SVN: r538 - in ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test: mock and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Dec 17 04:04:29 EST 2008


Author: dallen6
Date: 2008-12-17 04:04:29 -0500 (Wed, 17 Dec 2008)
New Revision: 538

Added:
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java
Removed:
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventManagerTest.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NewEventTest.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java
Modified:
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
Log:
Cleanup of old event bus test code no longer needed.

Copied: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java (from rev 537, ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NewEventTest.java)
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java	2008-12-17 09:04:29 UTC (rev 538)
@@ -0,0 +1,929 @@
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Set;
+
+import javax.webbeans.DefinitionException;
+import javax.webbeans.DuplicateBindingTypeException;
+import javax.webbeans.Event;
+import javax.webbeans.Observable;
+import javax.webbeans.Observer;
+import javax.webbeans.ObserverException;
+import javax.webbeans.TypeLiteral;
+import javax.webbeans.manager.Bean;
+
+import org.jboss.webbeans.bean.BeanFactory;
+import org.jboss.webbeans.bean.EventBean;
+import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bindings.InitializedBinding;
+import org.jboss.webbeans.contexts.DependentContext;
+import org.jboss.webbeans.introspector.AnnotatedField;
+import org.jboss.webbeans.test.beans.BananaSpider;
+import org.jboss.webbeans.test.beans.BirdCage;
+import org.jboss.webbeans.test.beans.BlueFacedParrotFinch;
+import org.jboss.webbeans.test.beans.FinchKeeper;
+import org.jboss.webbeans.test.beans.RecluseSpider;
+import org.jboss.webbeans.test.beans.StarFinch;
+import org.jboss.webbeans.test.beans.TeaCupPomeranian;
+import org.jboss.webbeans.test.beans.broken.BlackRumpedWaxbill;
+import org.jboss.webbeans.test.beans.broken.CommonWaxbill;
+import org.jboss.webbeans.test.beans.broken.GoldbreastWaxbill;
+import org.jboss.webbeans.test.beans.broken.JavaSparrow;
+import org.jboss.webbeans.test.beans.broken.OwlFinch;
+import org.jboss.webbeans.test.beans.broken.SweeWaxbill;
+import org.jboss.webbeans.test.bindings.AnimalStereotypeAnnotationLiteral;
+import org.jboss.webbeans.test.bindings.RoleBinding;
+import org.jboss.webbeans.test.bindings.TameAnnotationLiteral;
+import org.jboss.webbeans.test.ejb.invalid.AustralianTerrier;
+import org.jboss.webbeans.test.ejb.invalid.BorderTerrier;
+import org.jboss.webbeans.test.ejb.invalid.BostonTerrier;
+import org.jboss.webbeans.test.ejb.invalid.CairnsTerrier;
+import org.jboss.webbeans.test.ejb.invalid.FoxTerrier;
+import org.jboss.webbeans.test.ejb.invalid.TibetanTerrier;
+import org.jboss.webbeans.test.ejb.invalid.YorkshireTerrier;
+import org.jboss.webbeans.test.ejb.valid.BullTerrier;
+import org.jboss.webbeans.test.ejb.valid.Pomeranian;
+import org.jboss.webbeans.test.mock.MockManagerImpl;
+import org.jboss.webbeans.test.mock.MockWebBeanDiscovery;
+import org.testng.annotations.Test;
+
+/**
+ * Event bus tests
+ * 
+ * @author Nicklas Karlsson
+ * @author David Allen
+ * 
+ */
+ at SpecVersion("20081206")
+public class EventBusTest extends AbstractTest
+{
+   public static class AnEventType
+   {
+   }
+
+   public static class ATemplatedEventType<T>
+   {
+   }
+
+   public static class AnObserver implements Observer<AnEventType>
+   {
+      public boolean wasNotified = false;
+
+      public void notify(AnEventType event)
+      {
+         wasNotified = true;
+      }
+   }
+
+   public static class AnObserverWithException implements Observer<AnEventType>
+   {
+      public boolean wasNotified = false;
+      public RuntimeException theException = new RuntimeException("RE1");
+
+      public void notify(AnEventType event)
+      {
+         wasNotified = true;
+         throw theException;
+      }
+   }
+
+   @SuppressWarnings("unchecked")
+   @Test(groups = "events")
+   public void testEventBeanCreation()
+   {
+      SimpleBean<MyTest> myTestBean = BeanFactory.createSimpleBean(MyTest.class, manager);
+      boolean found = false;
+      for (AnnotatedField field : myTestBean.getInjectableFields())
+      {
+         if (field.isAnnotationPresent(Observable.class))
+         {
+            EventBean eventBean = BeanFactory.createEventBean(field, manager);
+            Event<Param> event = eventBean.create();
+            assert event != null;
+            found = true;
+         }
+      }
+      assert found;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.1")
+   public void testEventTypeIncludesAllSuperclassesAndInterfacesOfEventObject()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.2")
+   public void testManagerFireEvent()
+   {
+      // First a simple event with no bindings is fired
+      AnEventType anEvent = new AnEventType();
+      manager.fireEvent(anEvent);
+
+      // Next an event with some event bindings is fired
+      manager.fireEvent(anEvent, new RoleBinding("Admin"));
+   }
+
+   /**
+    * If the type of the event object passed to fireEvent() contains type
+    * variables or wildcards, an IllegalArgumentException is thrown
+    */
+   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
+   @SpecAssertion(section = { "8.1", "8.2" })
+   public void testManagerFireEventWithEventTypeParametersFails()
+   {
+      ATemplatedEventType<String> anEvent = new ATemplatedEventType<String>();
+      manager.fireEvent(anEvent);
+   }
+
+   /**
+    * If the type of the event object passed to fireEvent() contains type
+    * variables or wildcards, an IllegalArgumentException is thrown
+    */
+   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
+   @SpecAssertion(section = { "8.1", "8.2" })
+   public void testManagerFireEventWithEventTypeWildcardsFails()
+   {
+      // Although the above test is really the same as with a wildcard, we will
+      // test
+      // it anyhow since the specification calls it out separately.
+      ATemplatedEventType<?> anEventOnAnyType = new ATemplatedEventType<String>();
+      manager.fireEvent(anEventOnAnyType);
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
+   @SpecAssertion(section = { "8.1", "8.2" })
+   public void testManagerFireEventWithNonBindingAnnotationsFails()
+   {
+      // The specs are not exactly clear on what is supposed to happen here,
+      // but borrowing from Section 8.3, we'll expect the same behavior here
+      // for a consistent API.
+      // TODO Verify that fireEvent should fail on non-binding annotations
+      AnEventType anEvent = new AnEventType();
+      manager.fireEvent(anEvent, new AnimalStereotypeAnnotationLiteral());
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.3")
+   public void testManagerAddObserver()
+   {
+      Observer<AnEventType> observer = new AnObserver();
+
+      // First test with the Class<T> of the event type
+      manager.addObserver(observer, AnEventType.class);
+      Set<Observer<AnEventType>> resolvedObservers = manager.resolveObservers(new AnEventType());
+      assert !resolvedObservers.isEmpty();
+      assert resolvedObservers.size() == 1;
+      assert resolvedObservers.iterator().next() == observer;
+
+      // Now test with the TypeLiteral<T> of the event type
+      observer = new AnObserver();
+      manager.addObserver(observer, new TypeLiteral<AnEventType>()
+      {
+      });
+      resolvedObservers = manager.resolveObservers(new AnEventType());
+      assert !resolvedObservers.isEmpty();
+      assert resolvedObservers.size() == 2;
+      boolean foundObserver = false;
+      for (Observer<AnEventType> obs : resolvedObservers)
+      {
+         if (obs == observer)
+         {
+            foundObserver = true;
+            break;
+         }
+      }
+      assert foundObserver;
+
+      // Try adding an observer with some binding types
+      observer = new AnObserver();
+      Annotation[] bindingTypes = new Annotation[] { new RoleBinding("Admin"), new RoleBinding("Manager") };
+      manager.addObserver(observer, AnEventType.class, bindingTypes);
+      resolvedObservers = manager.resolveObservers(new AnEventType(), bindingTypes);
+      assert !resolvedObservers.isEmpty();
+      assert resolvedObservers.size() == 3;
+      foundObserver = false;
+      for (Observer<AnEventType> obs : resolvedObservers)
+      {
+         if (obs == observer)
+         {
+            foundObserver = true;
+            break;
+         }
+      }
+      assert foundObserver;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.3")
+   public void testManagerRemoveObserver()
+   {
+      Observer<AnEventType> observer = new AnObserver();
+
+      // First test with the Class<T> of the event type
+      manager.addObserver(observer, AnEventType.class);
+      manager.removeObserver(observer, AnEventType.class);
+      Set<Observer<AnEventType>> resolvedObservers = manager.resolveObservers(new AnEventType());
+      assert resolvedObservers.isEmpty();
+
+      // Now test with the TypeLiteral<T> of the event type
+      observer = new AnObserver();
+      manager.addObserver(observer, new TypeLiteral<AnEventType>()
+      {
+      });
+      manager.removeObserver(observer, new TypeLiteral<AnEventType>()
+      {
+      });
+      resolvedObservers = manager.resolveObservers(new AnEventType());
+      assert resolvedObservers.isEmpty();
+
+      // Also test with binding types
+      Annotation[] bindings = new Annotation[] { new RoleBinding("Admin") };
+      manager.addObserver(observer, AnEventType.class, bindings);
+      manager.removeObserver(observer, AnEventType.class);
+      resolvedObservers = manager.resolveObservers(new AnEventType(), bindings);
+      assert !resolvedObservers.isEmpty();
+      manager.removeObserver(observer, AnEventType.class, new RoleBinding("Admin"));
+      resolvedObservers = manager.resolveObservers(new AnEventType(), bindings);
+      assert resolvedObservers.isEmpty();
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DuplicateBindingTypeException.class })
+   @SpecAssertion(section = "8.3")
+   public void testMultipleInstancesOfSameBindingTypeWhenAddingObserverFails()
+   {
+      Observer<AnEventType> observer = new AnObserver();
+      manager.addObserver(observer, AnEventType.class, new RoleBinding("Admin"), new TameAnnotationLiteral(), new TameAnnotationLiteral());
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
+   @SpecAssertion(section = "8.3")
+   public void testNonBindingTypePassedToAddObserverFails()
+   {
+      Observer<AnEventType> observer = new AnObserver();
+      manager.addObserver(observer, AnEventType.class, new AnimalStereotypeAnnotationLiteral());
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DuplicateBindingTypeException.class })
+   @SpecAssertion(section = "8.3")
+   public void testMultipleInstancesOfSameBindingTypeWhenRemovingObserverFails()
+   {
+      Observer<AnEventType> observer = new AnObserver();
+      manager.addObserver(observer, AnEventType.class);
+      manager.removeObserver(observer, AnEventType.class, new RoleBinding("Admin"), new TameAnnotationLiteral(), new TameAnnotationLiteral());
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
+   @SpecAssertion(section = "8.3")
+   public void testNonBindingTypePassedToRemoveObserverFails()
+   {
+      Observer<AnEventType> observer = new AnObserver();
+      manager.addObserver(observer, AnEventType.class);
+      manager.removeObserver(observer, AnEventType.class, new AnimalStereotypeAnnotationLiteral());
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = { "8.1", "8.4" })
+   public void testConsumerNotifiedWhenEventTypeAndAllBindingsMatch()
+   {
+      AnObserver observer1 = new AnObserver();
+      AnObserver observer2 = new AnObserver();
+      manager.addObserver(observer1, AnEventType.class);
+      manager.addObserver(observer2, AnEventType.class);
+
+      // Fire an event that will be delivered to the two above observers
+      AnEventType anEvent = new AnEventType();
+      manager.fireEvent(anEvent);
+
+      assert observer1.wasNotified;
+      assert observer2.wasNotified;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.4")
+   public void testObserverThrowsExceptionAbortsNotifications()
+   {
+      AnObserver observer = new AnObserver();
+      AnObserverWithException anotherObserver = new AnObserverWithException();
+      manager.addObserver(anotherObserver, AnEventType.class);
+      manager.addObserver(observer, AnEventType.class);
+
+      // Fire an event that will be delivered to the two above observers
+      AnEventType anEvent = new AnEventType();
+      boolean fireFailed = false;
+      try
+      {
+         manager.fireEvent(anEvent);
+      }
+      catch (Exception e)
+      {
+         if (anotherObserver.theException.equals(e))
+            fireFailed = true;
+      }
+      assert fireFailed;
+
+      assert anotherObserver.wasNotified;
+      // TODO This cannot properly test for event processing abort
+      // assert !observer.wasNotified;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.4")
+   public void testObserverCalledBeforeTransactionCompleteMaySetRollbackOnly()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.4")
+   public void testObserverManipulatingJTATransactionsDirectlyFails()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.5")
+   public void testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(Pomeranian.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
+      Set<Observer<MockManagerImpl>> observers = manager.resolveObservers(manager, new InitializedBinding());
+      assert observers.size() == 2;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.5")
+   public void testObserverMethodOnEnterpriseBeanNotBusinessMethodOrStaticFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(TibetanTerrier.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
+      Set<Observer<MockManagerImpl>> observers = manager.resolveObservers(manager, new InitializedBinding());
+      assert observers.size() == 1;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.5")
+   public void testMultipleObserverMethodsOK()
+   {
+      // Somewhat of a cheat, but this other test already does have 2 observer
+      // methods
+      // for the same event type and event bindings.
+      testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic();
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = { "8.5.1", "8.5.2" })
+   public void testObserverMethodMustHaveOnlyOneEventParameter()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(YorkshireTerrier.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans != null;
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.5.1")
+   public void testObserverMethodCannotObserveParameterizedEvents()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(BostonTerrier.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans != null;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.5.1")
+   public void testObserverMethodWithoutBindingTypesObservesEventsWithoutBindingTypes()
+   {
+      // This observer has no binding types specified
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(Pomeranian.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
+
+      // Resolve registered observers with an event containing no binding types
+      Set<Observer<String>> resolvedObservers = manager.resolveObservers("A new event");
+      assert !resolvedObservers.isEmpty();
+      assert resolvedObservers.size() == 1;
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.5.2")
+   public void testObserverMethodAnnotatedProducesFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(BorderTerrier.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans != null;
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.5.2")
+   public void testObserverMethodAnnotatedInitializerFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(AustralianTerrier.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans != null;
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.5.2")
+   public void testObserverMethodAnnotatedDestructorFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(CairnsTerrier.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans != null;
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.5.2")
+   public void testObserverMethodWithDisposesParamFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(FoxTerrier.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans != null;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.5.2")
+   public void testObserverMethodMayHaveMultipleBindingTypes()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(BullTerrier.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans != null;
+      // If we can resolve the observer with the two binding types,
+      // then it worked
+      Set<Observer<String>> resolvedObservers = manager.resolveObservers("An event object", new RoleBinding("Admin"), new TameAnnotationLiteral());
+      assert !resolvedObservers.isEmpty();
+      assert resolvedObservers.size() == 1;
+
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.5.3")
+   public void testXMLDefinedObserverMethodIgnoresBindingAnnotations()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.5.3")
+   public void testXMLDefinedObserverNotFindingImplementationMethodFails()
+   {
+      assert false;
+   }
+   
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.5.4")
+   public void testObserverMethodReceivesInjectionsOnNonObservesParameters()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(BananaSpider.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans != null;
+   }
+
+   /**
+    * Tests that a conditional observer is not notified of events until after it
+    * is created by some other separate action.
+    * 
+    * This test will not be supported till after Alpha 1 of the RI.
+    */
+   @Test(groups = { "broken", "events" })
+   @SpecAssertion(section = "8.5.5")
+   public void testConditionalObserver()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(RecluseSpider.class));
+
+      manager.fireEvent("New string event");
+      // Should not be notified since bean is not instantiated yet
+      assert !RecluseSpider.notified;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.1")
+   public void testTransactionalObserverCanOnlyObserveSinglePhase()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.5.6")
+   public void testTransactionalObserverNotifiedImmediatelyWhenNoTransactionInProgress()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.5.6")
+   public void testAfterTransactionCompletionObserver()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.5.6")
+   public void testAfterTransactionSuccessObserver()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.5.6")
+   public void testAfterTransactionFailureObserver()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.5.6")
+   public void testBeforeTransactionCompletionObserver()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.5.7")
+   public void testObserverMethodRegistration()
+   {
+      // For now, this test is checking the registration of methods
+      testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic();
+   }
+
+   /**
+    * 
+    */
+   @Test(groups = { "broken", "events" })
+   @SpecAssertion(section = "8.5.7")
+   public void testEnterpriseBeanObserverMethodCalledWithCallerContext()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(Pomeranian.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans.size() == 1;
+      String event = "A new event";
+      Set<Observer<String>> observers = manager.resolveObservers(event);
+      assert observers.size() == 1;
+      
+      manager.fireEvent(event);
+      assert Thread.currentThread().equals(Pomeranian.notificationThread);
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.5.7")
+   public void testTransactionalObserverThrownExceptionIsCaughtAndLogged()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "events" }, expectedExceptions={ TeaCupPomeranian.OversizedException.class })
+   @SpecAssertion(section = "8.5.7")
+   public void testNonTransactionalObserverThrownNonCheckedExceptionIsRethrown()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(TeaCupPomeranian.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
+      manager.fireEvent("Another event");
+   }
+
+   @Test(groups = { "events" }, expectedExceptions={ ObserverException.class })
+   @SpecAssertion(section = "8.5.7")
+   public void testNonTransactionalObserverThrownCheckedExceptionIsWrappedAndRethrown()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(TeaCupPomeranian.class));
+      List<Bean<?>> beans = manager.getBeans();
+      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
+      manager.fireEvent(new Integer(1));
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DuplicateBindingTypeException.class })
+   @SpecAssertion(section = "8.6")
+   public void testDuplicateBindingsToFireFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(SweeWaxbill.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         SweeWaxbill bean = manager.getInstanceByType(SweeWaxbill.class);
+         bean.methodThatFiresEvent();
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "events" }, expectedExceptions={ DuplicateBindingTypeException.class })
+   @SpecAssertion(section = "8.6")
+   public void testDuplicateBindingsToObservesFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(SweeWaxbill.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         SweeWaxbill bean = manager.getInstanceByType(SweeWaxbill.class);
+         bean.methodThatRegistersObserver();
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
+   @SpecAssertion(section = "8.6")
+   public void testNonBindingTypePassedToFireFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(OwlFinch.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         OwlFinch bean = manager.getInstanceByType(OwlFinch.class);
+         bean.methodThatFiresEvent();
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
+   @SpecAssertion(section = "8.6")
+   public void testNonBindingTypePassedToObservesFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(OwlFinch.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         OwlFinch bean = manager.getInstanceByType(OwlFinch.class);
+         bean.methodThatRegistersObserver();
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnField()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(BlueFacedParrotFinch.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         BlueFacedParrotFinch bean = manager.getInstanceByType(BlueFacedParrotFinch.class);
+         bean.methodThatRegistersObserver();
+
+         Set<Observer<String>> observers = manager.resolveObservers("String type event");
+         assert observers.size() == 1;
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "broken", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnParameterOfProducerMethod()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(StarFinch.class, FinchKeeper.class, BirdCage.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         StarFinch starFinch = manager.getInstanceByType(StarFinch.class);
+         FinchKeeper birdKeeper = manager.getInstanceByType(FinchKeeper.class);
+         BirdCage birdCage = manager.getInstanceByType(BirdCage.class);
+         assert starFinch != null;
+         assert birdCage != null;
+         assert birdCage.someMess != null;
+         assert birdKeeper.newMessDetected;
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnParameterOfInitializerMethod()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnParameterOfDisposalMethod()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnParameterOfRemoveMethod()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnParameterOfConstructor()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnNonEventTypeInjectionPointFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(CommonWaxbill.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         CommonWaxbill bean = manager.getInstanceByType(CommonWaxbill.class);
+         assert bean != null;
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnInjectionPointWithoutTypeParameterFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(BlackRumpedWaxbill.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         BlackRumpedWaxbill bean = manager.getInstanceByType(BlackRumpedWaxbill.class);
+         assert bean != null;
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnInjectionPointWithWildcardedTypeParameterFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(GoldbreastWaxbill.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         GoldbreastWaxbill bean = manager.getInstanceByType(GoldbreastWaxbill.class);
+         assert bean != null;
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
+   @SpecAssertion(section = "8.6")
+   public void testObservableAnnotationOnInjectionPointWithTypeVariabledTypeParameterFails()
+   {
+      webBeansBootstrap.boot(new MockWebBeanDiscovery(JavaSparrow.class));
+      try
+      {
+         DependentContext.INSTANCE.setActive(true);
+         JavaSparrow bean = manager.getInstanceByType(JavaSparrow.class);
+         assert bean != null;
+      }
+      finally
+      {
+         DependentContext.INSTANCE.setActive(false);
+      }
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testImplicitObserverBeanMatchesAPITypeOfInectionPoint()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testImplicitObserverBeanMatchesBindingAnnotationsOfInjectionPoint()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testImplicitObserverBeanHasStandardDeploymentType()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testImplicitObserverBeanHasDependentScope()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testFireMethodCallsManagerFireWithEventObject()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testFireMethodCallsManagerFireWithBindingAnnotationsExceptObservable()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testFireMethodCallsManagerFireWithAllBindingAnnotationInstances()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObserveMethodCallsManagerAddObserverWithObserverObject()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObserveMethodCallsManagerAddObserverWithAllBindingAnnotationsExceptObservable()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.6")
+   public void testObserveMethodCallsManagerAddObserverWithAllBindingAnnotationInstance()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.7")
+   public void testEventObjectContainsTypeVariablesWhenResolvingFails()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.7")
+   public void testEventObjectContainsWildcardsWhenResolvingFails()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.7")
+   public void testDuplicateBindingTypesWhenResolvingFails()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.7")
+   public void testNonBindingTypeAnnotationWhenResolvingFails()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.7")
+   public void testResolvingChecksEventType()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.7")
+   public void testResolvingChecksTypeParameters()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.7")
+   public void testResolvingChecksBindingTypes()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "events" })
+   @SpecAssertion(section = "8.7")
+   public void testResolvingChecksBindingTypeMembers()
+   {
+      assert false;
+   }
+
+}

Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventManagerTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventManagerTest.java	2008-12-16 22:25:06 UTC (rev 537)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventManagerTest.java	2008-12-17 09:04:29 UTC (rev 538)
@@ -1,183 +0,0 @@
-package org.jboss.webbeans.test;
-
-import java.util.Set;
-
-import javax.transaction.Synchronization;
-import javax.webbeans.Observer;
-
-import org.jboss.webbeans.MetaDataCache;
-import org.jboss.webbeans.event.DeferredEventNotification;
-import org.jboss.webbeans.event.EventManager;
-import org.jboss.webbeans.test.beans.DangerCall;
-import org.jboss.webbeans.test.bindings.TameAnnotationLiteral;
-import org.testng.annotations.Test;
-
-/**
- * Tests for the EventManager implementation used by the Web Beans RI.
- * 
- * @author David Allen
- * 
- */
- at SpecVersion("PDR")
-public class EventManagerTest extends AbstractTest
-{
-   public class AnObserver<T> implements Observer<T>
-   {
-      public void notify(T event)
-      {
-      }
-   }
-
-   private Synchronization registeredSynch;
-
-   /**
-    * Tests adding an observer to the event bus and verified that it can still
-    * be retrieved for a corresponding event.
-    */
-   @Test(groups = "observerMethod")
-   public void testAddObserver()
-   {
-      EventManager eventManager = new EventManager(manager);
-      Observer<DangerCall> observer = new AnObserver<DangerCall>();
-      eventManager.addObserver(observer, DangerCall.class);
-      DangerCall event = new DangerCall();
-
-      Set<Observer<DangerCall>> observerSet = eventManager.getObservers(event);
-      assert observerSet.size() == 1;
-      assert observerSet.iterator().next().equals(observer);
-
-      // Add another observer for the same event, but with an event binding
-      observer = new AnObserver<DangerCall>();
-      eventManager.addObserver(observer, DangerCall.class, new TameAnnotationLiteral());
-      observerSet = eventManager.getObservers(event);
-      assert observerSet.size() == 1;
-      observerSet = eventManager.getObservers(event, new TameAnnotationLiteral());
-      assert observerSet.size() == 2;
-   }
-
-   /**
-    * Tests the remove operation and verifies that the observer is no longer
-    * registered for events.
-    */
-   @Test(groups = { "observerMethod" })
-   public void testRemoveObserver()
-   {
-      EventManager eventManager = new EventManager(manager);
-      Observer<DangerCall> observer = new AnObserver<DangerCall>();
-      eventManager.addObserver(observer, DangerCall.class);
-      eventManager.removeObserver(observer, DangerCall.class);
-      // FIXME CopyOnWrite broke remove, have to check later
-      assert eventManager.getObservers(new DangerCall()).isEmpty();
-   }
-
-   /**
-    * Tests the deferred event feature associated with transactions.
-    */
-   @Test(groups = { "deferredEvent", "broken" })
-   public void testDeferEvent()
-   {
-      // Setup a transaction manager for this test and inject into the event bus
-      // TransactionManager tm = new TransactionManager() {
-      // public void begin() throws NotSupportedException, SystemException
-      // {
-      // }
-      //
-      // public void commit() throws RollbackException,
-      // HeuristicMixedException, HeuristicRollbackException,
-      // SecurityException, IllegalStateException, SystemException
-      // {
-      // }
-      //
-      // public int getStatus() throws SystemException
-      // {
-      // return 0;
-      // }
-      //
-      // public Transaction getTransaction() throws SystemException
-      // {
-      // return new Transaction() {
-      //               
-      // public void commit() throws RollbackException,
-      // HeuristicMixedException, HeuristicRollbackException,
-      // SecurityException, IllegalStateException, SystemException
-      // {
-      // }
-      //
-      // public boolean delistResource(XAResource arg0, int arg1)
-      // throws IllegalStateException, SystemException
-      // {
-      // return false;
-      // }
-      //
-      // public boolean enlistResource(XAResource arg0)
-      // throws RollbackException, IllegalStateException,
-      // SystemException
-      // {
-      // return false;
-      // }
-      //
-      // public int getStatus() throws SystemException
-      // {
-      // return 0;
-      // }
-      //
-      // public void registerSynchronization(Synchronization synchronization)
-      // throws RollbackException, IllegalStateException,
-      // SystemException
-      // {
-      // registeredSynch = synchronization;
-      // }
-      //
-      // public void rollback() throws IllegalStateException,
-      // SystemException
-      // {
-      // }
-      //
-      // public void setRollbackOnly() throws IllegalStateException,
-      // SystemException
-      // {
-      // }
-      //               
-      // };
-      // }
-      //
-      // public void resume(Transaction arg0)
-      // throws InvalidTransactionException, IllegalStateException,
-      // SystemException
-      // {
-      // }
-      //
-      // public void rollback() throws IllegalStateException,
-      // SecurityException, SystemException
-      // {
-      // }
-      //
-      // public void setRollbackOnly() throws IllegalStateException,
-      // SystemException
-      // {
-      // }
-      //
-      // public void setTransactionTimeout(int arg0) throws SystemException
-      // {
-      // }
-      //
-      // public Transaction suspend() throws SystemException
-      // {
-      // return null;
-      // }
-      //         
-      // };
-//      EventManager eventManager = new EventManager(manager);
-//      Observer<DangerCall> observer = new AnObserver<DangerCall>();
-//      try
-//      {
-//         eventManager.deferEvent(new DangerCall(), observer);
-//      }
-//      catch (Exception e)
-//      {
-//      }
-//
-//      assert this.registeredSynch != null;
-//      assert ((DeferredEventNotification) this.registeredSynch).getObserver().equals(observer);
-   }
-}

Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java	2008-12-16 22:25:06 UTC (rev 537)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java	2008-12-17 09:04:29 UTC (rev 538)
@@ -1,53 +0,0 @@
-package org.jboss.webbeans.test;
-
-import javax.webbeans.Observer;
-
-import org.jboss.webbeans.event.EventObserver;
-import org.jboss.webbeans.test.beans.DangerCall;
-import org.jboss.webbeans.test.bindings.AnimalStereotypeAnnotationLiteral;
-import org.jboss.webbeans.test.bindings.RoleBinding;
-import org.jboss.webbeans.test.bindings.TameAnnotationLiteral;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the wrapper class {@link EventObserverTest} which implements some of
- * the observer resolution behavior specified in 7.7.1 and 7.7.2 of the Web Beans
- * Specification.
- * 
- * @author David Allen
- *
- */
- at SpecVersion("PDR")
-public class EventObserverTest
-{
-   public class AnObserver<T> implements Observer<T>
-   {
-      public void notify(T event)
-      {
-      }
-   }
-
-   
-   /**
-    * Tests different annotation literals as event bindings to make sure the wrapper
-    * properly detects when an observer matches the given event bindings.
-    */
-   @Test(groups = "event")
-   @SpecAssertion(section = "7.7.1")
-   public void testIsObserverInterested()
-   {
-      Observer<DangerCall> observer = new AnObserver<DangerCall>();
-      EventObserver<DangerCall> wrappedObserver = new EventObserver<DangerCall>(observer, DangerCall.class, new TameAnnotationLiteral());
-      assert wrappedObserver.getEventBindings().size() == 1;
-      assert wrappedObserver.isObserverInterested(new TameAnnotationLiteral());
-      assert !wrappedObserver.isObserverInterested(new AnimalStereotypeAnnotationLiteral());
-      assert !wrappedObserver.isObserverInterested();
-      assert wrappedObserver.isObserverInterested(new TameAnnotationLiteral(), new RoleBinding("Admin"));
-      
-      // Perform some tests with binding values (7.7.1)
-      wrappedObserver = new EventObserver<DangerCall>(observer, DangerCall.class, new RoleBinding("Admin"));
-      assert wrappedObserver.getEventBindings().size() == 1;
-      assert wrappedObserver.isObserverInterested(new RoleBinding("Admin"));
-      assert !wrappedObserver.isObserverInterested(new RoleBinding("User"));
-   }
-}

Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java	2008-12-16 22:25:06 UTC (rev 537)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java	2008-12-17 09:04:29 UTC (rev 538)
@@ -1,140 +0,0 @@
-package org.jboss.webbeans.test;
-
-import java.lang.annotation.Annotation;
-
-import javax.webbeans.DuplicateBindingTypeException;
-import javax.webbeans.Event;
-import javax.webbeans.Observer;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.event.EventImpl;
-import org.jboss.webbeans.test.annotations.Synchronous;
-import org.jboss.webbeans.test.annotations.Tame;
-import org.jboss.webbeans.test.beans.DangerCall;
-import org.jboss.webbeans.test.bindings.FishStereotypeAnnotationLiteral;
-import org.jboss.webbeans.test.bindings.RiverFishStereotypeAnnotationLiteral;
-import org.jboss.webbeans.test.bindings.SynchronousAnnotationLiteral;
-import org.jboss.webbeans.test.bindings.TameAnnotationLiteral;
-import org.jboss.webbeans.test.mock.MockManagerImpl;
-import org.jboss.webbeans.util.Reflections;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Tests for the implementation of an Event component.
- * 
- * @author David Allen
- * 
- */
- at SpecVersion("PDR")
-public class EventTest
-{
-   private MockManagerImpl manager = null;
-
-   /**
-    * Test class used as an observer.
-    * 
-    */
-   public class AnObserver<T> implements Observer<T>
-   {
-      protected boolean notified = false;
-
-      public void notify(T event)
-      {
-         this.notified = true;
-      }
-   }
-
-   @SuppressWarnings("unchecked")
-   @BeforeMethod
-   public void before() throws Exception
-   {
-      manager = new MockManagerImpl();
-      CurrentManager.setRootManager(manager);
-   }
-
-   /**
-    * Tests the {@link Event#fire(Object, Annotation...)} method with a locally
-    * instantiated implementation.
-    */
-   @SuppressWarnings("unchecked")
-   @Test(groups = "event")
-   @SpecAssertion(section = "7.6")
-   public void testFireEvent()
-   {
-      DangerCall anEvent = new DangerCall();
-      //Create a test annotation for the event and use it to construct the
-      //event object
-      Annotation[] annotations = new Annotation[] { new TameAnnotationLiteral() };
-      EventImpl<DangerCall> eventComponent = new EventImpl<DangerCall>(DangerCall.class, manager, annotations);
-      eventComponent.fire(anEvent, new SynchronousAnnotationLiteral());
-      assert anEvent.equals(manager.getEvent());
-      assert Reflections.annotationSetMatches(manager.getEventBindings(),
-            Tame.class, Synchronous.class);
-
-      //Test duplicate annotations on the fire method call
-      boolean duplicateDetected = false;
-      try
-      {
-         eventComponent.fire(anEvent, new TameAnnotationLiteral(),
-               new TameAnnotationLiteral());
-      } catch (DuplicateBindingTypeException e)
-      {
-         duplicateDetected = true;
-      }
-      assert duplicateDetected;
-
-      //Test annotations that are not binding types
-      boolean nonBindingTypeDetected = false;
-      try
-      {
-         eventComponent.fire(anEvent, new FishStereotypeAnnotationLiteral());
-      } catch (IllegalArgumentException e)
-      {
-         nonBindingTypeDetected = true;
-      }
-      assert nonBindingTypeDetected;
-   }
-
-   /**
-    * Tests the {@link Event#observe(javax.webbeans.Observer, Annotation...)}
-    * method with a locally instantiated implementation.
-    */
-   @Test(groups = {"observerMethod"})
-   @SpecAssertion(section = "7.6")
-   public void testObserve()
-   {
-      //Create a test annotation for the event and use it to construct the
-      //event object
-      Annotation[] annotations = new Annotation[] { new TameAnnotationLiteral() };
-      EventImpl<DangerCall> eventComponent = new EventImpl<DangerCall>(DangerCall.class, manager, annotations);
-      Observer<DangerCall> observer = new AnObserver<DangerCall>();
-      eventComponent.observe(observer, new SynchronousAnnotationLiteral());
-      assert manager.getObservedEventType().equals(DangerCall.class);
-
-       //Try duplicate annotation bindings
-      boolean duplicateDetected = false;
-      try
-      {
-         eventComponent.observe(observer,
-               new TameAnnotationLiteral());
-      } catch (DuplicateBindingTypeException e)
-      {
-         duplicateDetected = true;
-      }
-      assert duplicateDetected;
-
-      //Try an invalid binding type
-      boolean nonBindingTypeDetected = false;
-      try
-      {
-         eventComponent.observe(observer,
-               new RiverFishStereotypeAnnotationLiteral());
-      } catch (IllegalArgumentException e)
-      {
-         nonBindingTypeDetected = true;
-      }
-      assert nonBindingTypeDetected;
-   }
-
-}

Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NewEventTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NewEventTest.java	2008-12-16 22:25:06 UTC (rev 537)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NewEventTest.java	2008-12-17 09:04:29 UTC (rev 538)
@@ -1,929 +0,0 @@
-package org.jboss.webbeans.test;
-
-import java.lang.annotation.Annotation;
-import java.util.List;
-import java.util.Set;
-
-import javax.webbeans.DefinitionException;
-import javax.webbeans.DuplicateBindingTypeException;
-import javax.webbeans.Event;
-import javax.webbeans.Observable;
-import javax.webbeans.Observer;
-import javax.webbeans.ObserverException;
-import javax.webbeans.TypeLiteral;
-import javax.webbeans.manager.Bean;
-
-import org.jboss.webbeans.bean.BeanFactory;
-import org.jboss.webbeans.bean.EventBean;
-import org.jboss.webbeans.bean.SimpleBean;
-import org.jboss.webbeans.bindings.InitializedBinding;
-import org.jboss.webbeans.contexts.DependentContext;
-import org.jboss.webbeans.introspector.AnnotatedField;
-import org.jboss.webbeans.test.beans.BananaSpider;
-import org.jboss.webbeans.test.beans.BirdCage;
-import org.jboss.webbeans.test.beans.BlueFacedParrotFinch;
-import org.jboss.webbeans.test.beans.FinchKeeper;
-import org.jboss.webbeans.test.beans.RecluseSpider;
-import org.jboss.webbeans.test.beans.StarFinch;
-import org.jboss.webbeans.test.beans.TeaCupPomeranian;
-import org.jboss.webbeans.test.beans.broken.BlackRumpedWaxbill;
-import org.jboss.webbeans.test.beans.broken.CommonWaxbill;
-import org.jboss.webbeans.test.beans.broken.GoldbreastWaxbill;
-import org.jboss.webbeans.test.beans.broken.JavaSparrow;
-import org.jboss.webbeans.test.beans.broken.OwlFinch;
-import org.jboss.webbeans.test.beans.broken.SweeWaxbill;
-import org.jboss.webbeans.test.bindings.AnimalStereotypeAnnotationLiteral;
-import org.jboss.webbeans.test.bindings.RoleBinding;
-import org.jboss.webbeans.test.bindings.TameAnnotationLiteral;
-import org.jboss.webbeans.test.ejb.invalid.AustralianTerrier;
-import org.jboss.webbeans.test.ejb.invalid.BorderTerrier;
-import org.jboss.webbeans.test.ejb.invalid.BostonTerrier;
-import org.jboss.webbeans.test.ejb.invalid.CairnsTerrier;
-import org.jboss.webbeans.test.ejb.invalid.FoxTerrier;
-import org.jboss.webbeans.test.ejb.invalid.TibetanTerrier;
-import org.jboss.webbeans.test.ejb.invalid.YorkshireTerrier;
-import org.jboss.webbeans.test.ejb.valid.BullTerrier;
-import org.jboss.webbeans.test.ejb.valid.Pomeranian;
-import org.jboss.webbeans.test.mock.MockManagerImpl;
-import org.jboss.webbeans.test.mock.MockWebBeanDiscovery;
-import org.testng.annotations.Test;
-
-/**
- * Temporary name until synchronized with David Allen
- * 
- * @author Nicklas Karlsson
- * @author David Allen
- * 
- */
- at SpecVersion("20081206")
-public class NewEventTest extends AbstractTest
-{
-   public static class AnEventType
-   {
-   }
-
-   public static class ATemplatedEventType<T>
-   {
-   }
-
-   public static class AnObserver implements Observer<AnEventType>
-   {
-      public boolean wasNotified = false;
-
-      public void notify(AnEventType event)
-      {
-         wasNotified = true;
-      }
-   }
-
-   public static class AnObserverWithException implements Observer<AnEventType>
-   {
-      public boolean wasNotified = false;
-      public RuntimeException theException = new RuntimeException("RE1");
-
-      public void notify(AnEventType event)
-      {
-         wasNotified = true;
-         throw theException;
-      }
-   }
-
-   @SuppressWarnings("unchecked")
-   @Test(groups = "events")
-   public void testEventBeanCreation()
-   {
-      SimpleBean<MyTest> myTestBean = BeanFactory.createSimpleBean(MyTest.class, manager);
-      boolean found = false;
-      for (AnnotatedField field : myTestBean.getInjectableFields())
-      {
-         if (field.isAnnotationPresent(Observable.class))
-         {
-            EventBean eventBean = BeanFactory.createEventBean(field, manager);
-            Event<Param> event = eventBean.create();
-            assert event != null;
-            found = true;
-         }
-      }
-      assert found;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.1")
-   public void testEventTypeIncludesAllSuperclassesAndInterfacesOfEventObject()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.2")
-   public void testManagerFireEvent()
-   {
-      // First a simple event with no bindings is fired
-      AnEventType anEvent = new AnEventType();
-      manager.fireEvent(anEvent);
-
-      // Next an event with some event bindings is fired
-      manager.fireEvent(anEvent, new RoleBinding("Admin"));
-   }
-
-   /**
-    * If the type of the event object passed to fireEvent() contains type
-    * variables or wildcards, an IllegalArgumentException is thrown
-    */
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = { "8.1", "8.2" })
-   public void testManagerFireEventWithEventTypeParametersFails()
-   {
-      ATemplatedEventType<String> anEvent = new ATemplatedEventType<String>();
-      manager.fireEvent(anEvent);
-   }
-
-   /**
-    * If the type of the event object passed to fireEvent() contains type
-    * variables or wildcards, an IllegalArgumentException is thrown
-    */
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = { "8.1", "8.2" })
-   public void testManagerFireEventWithEventTypeWildcardsFails()
-   {
-      // Although the above test is really the same as with a wildcard, we will
-      // test
-      // it anyhow since the specification calls it out separately.
-      ATemplatedEventType<?> anEventOnAnyType = new ATemplatedEventType<String>();
-      manager.fireEvent(anEventOnAnyType);
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = { "8.1", "8.2" })
-   public void testManagerFireEventWithNonBindingAnnotationsFails()
-   {
-      // The specs are not exactly clear on what is supposed to happen here,
-      // but borrowing from Section 8.3, we'll expect the same behavior here
-      // for a consistent API.
-      // TODO Verify that fireEvent should fail on non-binding annotations
-      AnEventType anEvent = new AnEventType();
-      manager.fireEvent(anEvent, new AnimalStereotypeAnnotationLiteral());
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.3")
-   public void testManagerAddObserver()
-   {
-      Observer<AnEventType> observer = new AnObserver();
-
-      // First test with the Class<T> of the event type
-      manager.addObserver(observer, AnEventType.class);
-      Set<Observer<AnEventType>> resolvedObservers = manager.resolveObservers(new AnEventType());
-      assert !resolvedObservers.isEmpty();
-      assert resolvedObservers.size() == 1;
-      assert resolvedObservers.iterator().next() == observer;
-
-      // Now test with the TypeLiteral<T> of the event type
-      observer = new AnObserver();
-      manager.addObserver(observer, new TypeLiteral<AnEventType>()
-      {
-      });
-      resolvedObservers = manager.resolveObservers(new AnEventType());
-      assert !resolvedObservers.isEmpty();
-      assert resolvedObservers.size() == 2;
-      boolean foundObserver = false;
-      for (Observer<AnEventType> obs : resolvedObservers)
-      {
-         if (obs == observer)
-         {
-            foundObserver = true;
-            break;
-         }
-      }
-      assert foundObserver;
-
-      // Try adding an observer with some binding types
-      observer = new AnObserver();
-      Annotation[] bindingTypes = new Annotation[] { new RoleBinding("Admin"), new RoleBinding("Manager") };
-      manager.addObserver(observer, AnEventType.class, bindingTypes);
-      resolvedObservers = manager.resolveObservers(new AnEventType(), bindingTypes);
-      assert !resolvedObservers.isEmpty();
-      assert resolvedObservers.size() == 3;
-      foundObserver = false;
-      for (Observer<AnEventType> obs : resolvedObservers)
-      {
-         if (obs == observer)
-         {
-            foundObserver = true;
-            break;
-         }
-      }
-      assert foundObserver;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.3")
-   public void testManagerRemoveObserver()
-   {
-      Observer<AnEventType> observer = new AnObserver();
-
-      // First test with the Class<T> of the event type
-      manager.addObserver(observer, AnEventType.class);
-      manager.removeObserver(observer, AnEventType.class);
-      Set<Observer<AnEventType>> resolvedObservers = manager.resolveObservers(new AnEventType());
-      assert resolvedObservers.isEmpty();
-
-      // Now test with the TypeLiteral<T> of the event type
-      observer = new AnObserver();
-      manager.addObserver(observer, new TypeLiteral<AnEventType>()
-      {
-      });
-      manager.removeObserver(observer, new TypeLiteral<AnEventType>()
-      {
-      });
-      resolvedObservers = manager.resolveObservers(new AnEventType());
-      assert resolvedObservers.isEmpty();
-
-      // Also test with binding types
-      Annotation[] bindings = new Annotation[] { new RoleBinding("Admin") };
-      manager.addObserver(observer, AnEventType.class, bindings);
-      manager.removeObserver(observer, AnEventType.class);
-      resolvedObservers = manager.resolveObservers(new AnEventType(), bindings);
-      assert !resolvedObservers.isEmpty();
-      manager.removeObserver(observer, AnEventType.class, new RoleBinding("Admin"));
-      resolvedObservers = manager.resolveObservers(new AnEventType(), bindings);
-      assert resolvedObservers.isEmpty();
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DuplicateBindingTypeException.class })
-   @SpecAssertion(section = "8.3")
-   public void testMultipleInstancesOfSameBindingTypeWhenAddingObserverFails()
-   {
-      Observer<AnEventType> observer = new AnObserver();
-      manager.addObserver(observer, AnEventType.class, new RoleBinding("Admin"), new TameAnnotationLiteral(), new TameAnnotationLiteral());
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = "8.3")
-   public void testNonBindingTypePassedToAddObserverFails()
-   {
-      Observer<AnEventType> observer = new AnObserver();
-      manager.addObserver(observer, AnEventType.class, new AnimalStereotypeAnnotationLiteral());
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DuplicateBindingTypeException.class })
-   @SpecAssertion(section = "8.3")
-   public void testMultipleInstancesOfSameBindingTypeWhenRemovingObserverFails()
-   {
-      Observer<AnEventType> observer = new AnObserver();
-      manager.addObserver(observer, AnEventType.class);
-      manager.removeObserver(observer, AnEventType.class, new RoleBinding("Admin"), new TameAnnotationLiteral(), new TameAnnotationLiteral());
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = "8.3")
-   public void testNonBindingTypePassedToRemoveObserverFails()
-   {
-      Observer<AnEventType> observer = new AnObserver();
-      manager.addObserver(observer, AnEventType.class);
-      manager.removeObserver(observer, AnEventType.class, new AnimalStereotypeAnnotationLiteral());
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = { "8.1", "8.4" })
-   public void testConsumerNotifiedWhenEventTypeAndAllBindingsMatch()
-   {
-      AnObserver observer1 = new AnObserver();
-      AnObserver observer2 = new AnObserver();
-      manager.addObserver(observer1, AnEventType.class);
-      manager.addObserver(observer2, AnEventType.class);
-
-      // Fire an event that will be delivered to the two above observers
-      AnEventType anEvent = new AnEventType();
-      manager.fireEvent(anEvent);
-
-      assert observer1.wasNotified;
-      assert observer2.wasNotified;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.4")
-   public void testObserverThrowsExceptionAbortsNotifications()
-   {
-      AnObserver observer = new AnObserver();
-      AnObserverWithException anotherObserver = new AnObserverWithException();
-      manager.addObserver(anotherObserver, AnEventType.class);
-      manager.addObserver(observer, AnEventType.class);
-
-      // Fire an event that will be delivered to the two above observers
-      AnEventType anEvent = new AnEventType();
-      boolean fireFailed = false;
-      try
-      {
-         manager.fireEvent(anEvent);
-      }
-      catch (Exception e)
-      {
-         if (anotherObserver.theException.equals(e))
-            fireFailed = true;
-      }
-      assert fireFailed;
-
-      assert anotherObserver.wasNotified;
-      // TODO This cannot properly test for event processing abort
-      // assert !observer.wasNotified;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.4")
-   public void testObserverCalledBeforeTransactionCompleteMaySetRollbackOnly()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.4")
-   public void testObserverManipulatingJTATransactionsDirectlyFails()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.5")
-   public void testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(Pomeranian.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
-      Set<Observer<MockManagerImpl>> observers = manager.resolveObservers(manager, new InitializedBinding());
-      assert observers.size() == 2;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.5")
-   public void testObserverMethodOnEnterpriseBeanNotBusinessMethodOrStaticFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(TibetanTerrier.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
-      Set<Observer<MockManagerImpl>> observers = manager.resolveObservers(manager, new InitializedBinding());
-      assert observers.size() == 1;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.5")
-   public void testMultipleObserverMethodsOK()
-   {
-      // Somewhat of a cheat, but this other test already does have 2 observer
-      // methods
-      // for the same event type and event bindings.
-      testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic();
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = { "8.5.1", "8.5.2" })
-   public void testObserverMethodMustHaveOnlyOneEventParameter()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(YorkshireTerrier.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans != null;
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.5.1")
-   public void testObserverMethodCannotObserveParameterizedEvents()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(BostonTerrier.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans != null;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.5.1")
-   public void testObserverMethodWithoutBindingTypesObservesEventsWithoutBindingTypes()
-   {
-      // This observer has no binding types specified
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(Pomeranian.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
-
-      // Resolve registered observers with an event containing no binding types
-      Set<Observer<String>> resolvedObservers = manager.resolveObservers("A new event");
-      assert !resolvedObservers.isEmpty();
-      assert resolvedObservers.size() == 1;
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.5.2")
-   public void testObserverMethodAnnotatedProducesFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(BorderTerrier.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans != null;
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.5.2")
-   public void testObserverMethodAnnotatedInitializerFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(AustralianTerrier.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans != null;
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.5.2")
-   public void testObserverMethodAnnotatedDestructorFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(CairnsTerrier.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans != null;
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.5.2")
-   public void testObserverMethodWithDisposesParamFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(FoxTerrier.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans != null;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.5.2")
-   public void testObserverMethodMayHaveMultipleBindingTypes()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(BullTerrier.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans != null;
-      // If we can resolve the observer with the two binding types,
-      // then it worked
-      Set<Observer<String>> resolvedObservers = manager.resolveObservers("An event object", new RoleBinding("Admin"), new TameAnnotationLiteral());
-      assert !resolvedObservers.isEmpty();
-      assert resolvedObservers.size() == 1;
-
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.5.3")
-   public void testXMLDefinedObserverMethodIgnoresBindingAnnotations()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.5.3")
-   public void testXMLDefinedObserverNotFindingImplementationMethodFails()
-   {
-      assert false;
-   }
-   
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.5.4")
-   public void testObserverMethodReceivesInjectionsOnNonObservesParameters()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(BananaSpider.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans != null;
-   }
-
-   /**
-    * Tests that a conditional observer is not notified of events until after it
-    * is created by some other separate action.
-    * 
-    * This test will not be supported till after Alpha 1 of the RI.
-    */
-   @Test(groups = { "broken", "events" })
-   @SpecAssertion(section = "8.5.5")
-   public void testConditionalObserver()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(RecluseSpider.class));
-
-      manager.fireEvent("New string event");
-      // Should not be notified since bean is not instantiated yet
-      assert !RecluseSpider.notified;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.1")
-   public void testTransactionalObserverCanOnlyObserveSinglePhase()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.5.6")
-   public void testTransactionalObserverNotifiedImmediatelyWhenNoTransactionInProgress()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.5.6")
-   public void testAfterTransactionCompletionObserver()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.5.6")
-   public void testAfterTransactionSuccessObserver()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.5.6")
-   public void testAfterTransactionFailureObserver()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.5.6")
-   public void testBeforeTransactionCompletionObserver()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.5.7")
-   public void testObserverMethodRegistration()
-   {
-      // For now, this test is checking the registration of methods
-      testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic();
-   }
-
-   /**
-    * 
-    */
-   @Test(groups = { "broken", "events" })
-   @SpecAssertion(section = "8.5.7")
-   public void testEnterpriseBeanObserverMethodCalledWithCallerContext()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(Pomeranian.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans.size() == 1;
-      String event = "A new event";
-      Set<Observer<String>> observers = manager.resolveObservers(event);
-      assert observers.size() == 1;
-      
-      manager.fireEvent(event);
-      assert Thread.currentThread().equals(Pomeranian.notificationThread);
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.5.7")
-   public void testTransactionalObserverThrownExceptionIsCaughtAndLogged()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "events" }, expectedExceptions={ TeaCupPomeranian.OversizedException.class })
-   @SpecAssertion(section = "8.5.7")
-   public void testNonTransactionalObserverThrownNonCheckedExceptionIsRethrown()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(TeaCupPomeranian.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
-      manager.fireEvent("Another event");
-   }
-
-   @Test(groups = { "events" }, expectedExceptions={ ObserverException.class })
-   @SpecAssertion(section = "8.5.7")
-   public void testNonTransactionalObserverThrownCheckedExceptionIsWrappedAndRethrown()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(TeaCupPomeranian.class));
-      List<Bean<?>> beans = manager.getBeans();
-      assert beans.size() == 1 + MockManagerImpl.BUILT_IN_BEANS;
-      manager.fireEvent(new Integer(1));
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DuplicateBindingTypeException.class })
-   @SpecAssertion(section = "8.6")
-   public void testDuplicateBindingsToFireFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(SweeWaxbill.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         SweeWaxbill bean = manager.getInstanceByType(SweeWaxbill.class);
-         bean.methodThatFiresEvent();
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "events" }, expectedExceptions={ DuplicateBindingTypeException.class })
-   @SpecAssertion(section = "8.6")
-   public void testDuplicateBindingsToObservesFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(SweeWaxbill.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         SweeWaxbill bean = manager.getInstanceByType(SweeWaxbill.class);
-         bean.methodThatRegistersObserver();
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = "8.6")
-   public void testNonBindingTypePassedToFireFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(OwlFinch.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         OwlFinch bean = manager.getInstanceByType(OwlFinch.class);
-         bean.methodThatFiresEvent();
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { IllegalArgumentException.class })
-   @SpecAssertion(section = "8.6")
-   public void testNonBindingTypePassedToObservesFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(OwlFinch.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         OwlFinch bean = manager.getInstanceByType(OwlFinch.class);
-         bean.methodThatRegistersObserver();
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnField()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(BlueFacedParrotFinch.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         BlueFacedParrotFinch bean = manager.getInstanceByType(BlueFacedParrotFinch.class);
-         bean.methodThatRegistersObserver();
-
-         Set<Observer<String>> observers = manager.resolveObservers("String type event");
-         assert observers.size() == 1;
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "broken", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnParameterOfProducerMethod()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(StarFinch.class, FinchKeeper.class, BirdCage.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         StarFinch starFinch = manager.getInstanceByType(StarFinch.class);
-         FinchKeeper birdKeeper = manager.getInstanceByType(FinchKeeper.class);
-         BirdCage birdCage = manager.getInstanceByType(BirdCage.class);
-         assert starFinch != null;
-         assert birdCage != null;
-         assert birdCage.someMess != null;
-         assert birdKeeper.newMessDetected;
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnParameterOfInitializerMethod()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnParameterOfDisposalMethod()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnParameterOfRemoveMethod()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnParameterOfConstructor()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnNonEventTypeInjectionPointFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(CommonWaxbill.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         CommonWaxbill bean = manager.getInstanceByType(CommonWaxbill.class);
-         assert bean != null;
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnInjectionPointWithoutTypeParameterFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(BlackRumpedWaxbill.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         BlackRumpedWaxbill bean = manager.getInstanceByType(BlackRumpedWaxbill.class);
-         assert bean != null;
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnInjectionPointWithWildcardedTypeParameterFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(GoldbreastWaxbill.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         GoldbreastWaxbill bean = manager.getInstanceByType(GoldbreastWaxbill.class);
-         assert bean != null;
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "events" }, expectedExceptions = { DefinitionException.class })
-   @SpecAssertion(section = "8.6")
-   public void testObservableAnnotationOnInjectionPointWithTypeVariabledTypeParameterFails()
-   {
-      webBeansBootstrap.boot(new MockWebBeanDiscovery(JavaSparrow.class));
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         JavaSparrow bean = manager.getInstanceByType(JavaSparrow.class);
-         assert bean != null;
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testImplicitObserverBeanMatchesAPITypeOfInectionPoint()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testImplicitObserverBeanMatchesBindingAnnotationsOfInjectionPoint()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testImplicitObserverBeanHasStandardDeploymentType()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testImplicitObserverBeanHasDependentScope()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testFireMethodCallsManagerFireWithEventObject()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testFireMethodCallsManagerFireWithBindingAnnotationsExceptObservable()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testFireMethodCallsManagerFireWithAllBindingAnnotationInstances()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObserveMethodCallsManagerAddObserverWithObserverObject()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObserveMethodCallsManagerAddObserverWithAllBindingAnnotationsExceptObservable()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.6")
-   public void testObserveMethodCallsManagerAddObserverWithAllBindingAnnotationInstance()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.7")
-   public void testEventObjectContainsTypeVariablesWhenResolvingFails()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.7")
-   public void testEventObjectContainsWildcardsWhenResolvingFails()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.7")
-   public void testDuplicateBindingTypesWhenResolvingFails()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.7")
-   public void testNonBindingTypeAnnotationWhenResolvingFails()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.7")
-   public void testResolvingChecksEventType()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.7")
-   public void testResolvingChecksTypeParameters()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.7")
-   public void testResolvingChecksBindingTypes()
-   {
-      assert false;
-   }
-
-   @Test(groups = { "stub", "events" })
-   @SpecAssertion(section = "8.7")
-   public void testResolvingChecksBindingTypeMembers()
-   {
-      assert false;
-   }
-
-}

Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java	2008-12-16 22:25:06 UTC (rev 537)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java	2008-12-17 09:04:29 UTC (rev 538)
@@ -1,112 +0,0 @@
-package org.jboss.webbeans.test;
-
-import java.lang.reflect.Method;
-
-import javax.webbeans.Observer;
-import javax.webbeans.Observes;
-
-import org.jboss.webbeans.bean.BeanFactory;
-import org.jboss.webbeans.bean.SimpleBean;
-import org.jboss.webbeans.contexts.DependentContext;
-import org.jboss.webbeans.introspector.AnnotatedMethod;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
-import org.jboss.webbeans.introspector.jlr.AnnotatedMethodImpl;
-import org.jboss.webbeans.test.annotations.Role;
-import org.jboss.webbeans.test.bindings.RoleBinding;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the implementation of Observer.
- * 
- * @author David Allen
- * 
- */
- at SpecVersion("20081024-PDR")
-public class ObserverTest extends AbstractTest
-{
-   
-   // private SimpleBean<Tuna> tuna;
-   private SimpleBean<SampleObserver> ob;
-   private AnnotatedMethod<Object> om;
-   Observer<SampleEvent> observer;
-
-   private static boolean notified = false;
-
-   public static class SampleEvent
-   {
-      // Simple class used for testing
-   }
-
-   public static class SampleObserver
-   {
-
-      public void observe(@Observes @Role("Admin") SampleEvent e)
-      {
-         // An observer method
-         notified = true;
-      }
-
-   }
-
-   public static @interface Foo
-   {
-   }
-
-   @BeforeMethod
-   public void beforeObserverTest() throws Exception
-   {
-      super.before();
-      ob = BeanFactory.createSimpleBean(SampleObserver.class, manager);
-      manager.addBean(ob);
-      Method method = SampleObserver.class.getMethod("observe", SampleEvent.class);
-      om = new AnnotatedMethodImpl<Object>(method, new AnnotatedClassImpl<SampleObserver>(SampleObserver.class));
-      observer = BeanFactory.createObserver(om, ob, manager);
-      manager.addObserver(observer, SampleEvent.class, new RoleBinding("Admin"));
-      notified = false;
-   }
-
-   /**
-    * Test method for
-    * {@link org.jboss.webbeans.event.ObserverImpl#notify(javax.webbeans.Container, java.lang.Object)}
-    * .
-    */
-   @Test(groups = "observerMethod")
-   @SpecAssertion(section = { "7.5.7" })
-   public final void testNotify() throws Exception
-   {
-      SampleEvent event = new SampleEvent();
-      notified = false;
-      // The Dependent context isn't automatically activated when calling ObserverImpl.notify, only when through the EventManager
-      try
-      {
-         DependentContext.INSTANCE.setActive(true);
-         observer.notify(event);
-      }
-      finally
-      {
-         DependentContext.INSTANCE.setActive(false);
-      }
-      assert notified == true;
-   }
-
-   @Test(groups = "observerMethod")
-   @SpecAssertion(section = { "7.5.7" })
-   public final void testNotifyViaManager() throws Exception
-   {
-      notified = false;
-      manager.fireEvent(new SampleEvent());
-      assert notified == false;
-      manager.fireEvent(new Object(), new RoleBinding("Admin"));
-      assert notified == false;
-      manager.fireEvent(new SampleEvent(), new RoleBinding("Admin"));
-      assert notified == true;
-      notified = false;
-      manager.fireEvent(new SampleEvent(), new RoleBinding("User"));
-      assert notified == false;
-      notified = false;
-      manager.fireEvent(new SampleEvent(), new RoleBinding("Admin"), new RoleBinding("User"));
-      assert notified == true;
-   }
-
-}

Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java	2008-12-16 22:25:06 UTC (rev 537)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java	2008-12-17 09:04:29 UTC (rev 538)
@@ -1,13 +1,5 @@
 package org.jboss.webbeans.test.mock;
 
-import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.webbeans.Observer;
-import javax.webbeans.manager.Manager;
-
 import org.jboss.webbeans.ManagerImpl;
 
 public class MockManagerImpl extends ManagerImpl
@@ -15,52 +7,4 @@
    
    public static int BUILT_IN_BEANS = 4;
    
-   private Object event = null;
-   private Annotation[] eventBindings = null;
-   private Class<? extends Object> observedEventType = null;
-
-   @Override
-   public void fireEvent(Object event, Annotation... bindings)
-   {
-      // Record the event
-      this.event = event;
-      this.eventBindings = bindings;
-      super.fireEvent(event, bindings);
-   }
-   
-   @Override
-   public <T> Manager addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
-   {
-	   this.observedEventType = eventType;
-	   return super.addObserver(observer, eventType, bindings);
-   }
-
-   /**
-    * Retrieves the event which was last fired with this manager.
-    * @return the event
-    */
-   public final Object getEvent()
-   {
-      return event;
-   }
-
-   /**
-    * @return the eventBindings
-    */
-   public final Set<Annotation> getEventBindings()
-   {
-      if (eventBindings != null)
-         return new HashSet<Annotation>(Arrays.asList(eventBindings));
-      else
-         return null;
-   }
-
-   /**
-    * @return the eventType
-    */
-   public final Class<?> getObservedEventType()
-   {
-      return observedEventType;
-   }
-   
 }




More information about the weld-commits mailing list