[webbeans-commits] Webbeans SVN: r1473 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck: unit/event and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Mon Feb 9 16:39:49 EST 2009
Author: dallen6
Date: 2009-02-09 16:39:49 -0500 (Mon, 09 Feb 2009)
New Revision: 1473
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/StaticObserver.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/BorderTerrier.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java
Log:
Added a few event tests
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/EventTest.java 2009-02-09 20:18:28 UTC (rev 1472)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/EventTest.java 2009-02-09 21:39:49 UTC (rev 1473)
@@ -148,6 +148,18 @@
}
/**
+ * Otherwise, the observer method is called in the same transaction context,
+ * client security context and lifecycle contexts as the invocation of
+ * Event.fire().
+ */
+ @Test(groups = { "stub", "events", "integration" })
+ @SpecAssertion(section = "7.5.9", id = "unknown")
+ public void testObserverMethodCalledInSameContexts()
+ {
+ assert false;
+ }
+
+ /**
* Otherwise, if the observer method is a @BeforeTransactionCompletion
* transactional observer method, it is called within the context of the
* transaction that is about to complete and with the same client security
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/BorderTerrier.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/BorderTerrier.java 2009-02-09 20:18:28 UTC (rev 1472)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/BorderTerrier.java 2009-02-09 21:39:49 UTC (rev 1473)
@@ -10,7 +10,8 @@
class BorderTerrier
{
@Produces
- public void observeInitialized(@Observes @Initialized Manager manager)
+ public String observeInitialized(@Observes @Initialized Manager manager)
{
+ return "product";
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java 2009-02-09 20:18:28 UTC (rev 1472)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java 2009-02-09 21:39:49 UTC (rev 1473)
@@ -727,17 +727,20 @@
@SpecAssertion(section = "7.5.8", id = "unknown")
public void testObserverMethodCalledImmediately()
{
+
assert false;
}
/**
* If the observer method is static, the container must invoke the method.
*/
- @Test(groups = { "stub", "events" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "7.5.8", id = "unknown")
public void testStaticObserverMethodInvoked()
{
- assert false;
+ deployBeans(StaticObserver.class);
+ manager.fireEvent(new Delivery());
+ assert StaticObserver.isDeliveryReceived();
}
/**
@@ -833,18 +836,6 @@
}
/**
- * Otherwise, the observer method is called in the same transaction context,
- * client security context and lifecycle contexts as the invocation of
- * Event.fire().
- */
- @Test(groups = { "stub", "events" })
- @SpecAssertion(section = "7.5.9", id = "unknown")
- public void testObserverMethodCalledInSameContexts()
- {
- assert false;
- }
-
- /**
* If two instances of the same binding type are passed to fire() or
* observes(), a DuplicateBindingTypeException is thrown.
*/
@@ -1168,49 +1159,79 @@
}
/**
- * @Dependent scope,
+ * the @Dependent scope,
+ * @throws Exception
*/
@Test(groups = { "events" })
@SpecAssertion(section = "7.6", id = "unknown")
- public void testImplicitEventBeanHasDependentScope()
+ public void testImplicitEventBeanHasDependentScope() throws Exception
{
deployBeans(BlueFacedParrotFinch.class);
- try
+ new RunInDependentContext()
{
- activateDependentContext();
- BlueFacedParrotFinch bean = manager.getInstanceByType(BlueFacedParrotFinch.class);
- assert bean != null;
- // Retrieve the implicit event bean from the manager only by its API
- // type
- Set<?> eventBeans = manager.resolveByType(Event.class, new FiresBinding());
- assert eventBeans.size() == 1;
- Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
- assert eventBean.getScopeType().equals(Dependent.class);
- }
- finally
- {
- deactivateDependentContext();
- }
+ @Override
+ protected void execute() throws Exception
+ {
+ BlueFacedParrotFinch bean = manager.getInstanceByType(BlueFacedParrotFinch.class);
+ assert bean != null;
+ // Retrieve the implicit event bean from the manager only by its API
+ // type
+ Set<?> eventBeans = manager.resolveByType(Event.class, new FiresBinding());
+ assert eventBeans.size() == 1;
+ Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
+ assert eventBean.getScopeType().equals(Dependent.class);
+ }
+ }.run();
}
/**
* no bean name, and
+ * @throws Exception
*/
- @Test(groups = { "events", "stub" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "7.6", id = "unknown")
- public void testImplicitEventBeanHasNoName()
+ public void testImplicitEventBeanHasNoName() throws Exception
{
- assert false;
+ deployBeans(BlueFacedParrotFinch.class);
+ new RunInDependentContext()
+ {
+ @Override
+ protected void execute() throws Exception
+ {
+ BlueFacedParrotFinch bean = manager.getInstanceByType(BlueFacedParrotFinch.class);
+ assert bean != null;
+ // Retrieve the implicit event bean from the manager only by its API
+ // type
+ Set<?> eventBeans = manager.resolveByType(Event.class, new FiresBinding());
+ assert eventBeans.size() == 1;
+ Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
+ assert eventBean.getName() == null;
+ }
+ }.run();
}
/**
* an implementation provided automatically by the container.
+ * @throws Exception
*/
- @Test(groups = { "events", "stub" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "7.6", id = "unknown")
- public void testImplicitEventBeanProvidedByContainer()
+ public void testImplicitEventBeanProvidedByContainer() throws Exception
{
- assert false;
+ deployBeans(BlueFacedParrotFinch.class);
+ new RunInDependentContext()
+ {
+ @Override
+ protected void execute() throws Exception
+ {
+ BlueFacedParrotFinch bean = manager.getInstanceByType(BlueFacedParrotFinch.class);
+ assert bean != null;
+ // Retrieve the implicit event bean from the manager only by its API
+ // type
+ Set<?> eventBeans = manager.resolveByType(Event.class, new FiresBinding());
+ assert eventBeans.size() == 1;
+ }
+ }.run();
}
/**
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/StaticObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/StaticObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/StaticObserver.java 2009-02-09 21:39:49 UTC (rev 1473)
@@ -0,0 +1,23 @@
+package org.jboss.jsr299.tck.unit.event;
+
+import javax.event.Observes;
+
+class StaticObserver
+{
+ private static boolean deliveryReceived = false;
+
+ public static void accept(@Observes Delivery delivery)
+ {
+ setDeliveryReceived(true);
+ }
+
+ public static boolean isDeliveryReceived()
+ {
+ return deliveryReceived;
+ }
+
+ public static void setDeliveryReceived(boolean deliveryReceived)
+ {
+ StaticObserver.deliveryReceived = deliveryReceived;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/StaticObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list