Author: dallen6
Date: 2009-04-03 16:40:25 -0400 (Fri, 03 Apr 2009)
New Revision: 2296
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
A few more event test implementations
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-04-03
14:34:40 UTC (rev 2295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-04-03
20:40:25 UTC (rev 2296)
@@ -196,27 +196,47 @@
assert observer != null;
}
- @Test(groups = { "events", "broken" }, expectedExceptions = {
IllegalArgumentException.class })
+ //TODO The exception is never thrown with parameterized types
+ @Test(groups = { "ri-broken", "events" }, expectedExceptions = {
IllegalArgumentException.class })
@SpecAssertions( { @SpecAssertion(section = "7.3", id = "f") })
public void testManagerAddObserverWithEventTypeParametersFails()
{
- assert false;
- // ATemplatedEventType<String> anEvent = new
- // ATemplatedEventType<String>();
- // Observer<AnEventType> observer = new AnObserver();
- // getCurrentManager().addObserver(observer, anEvent.getClass());
+ ArrayList<String> anEvent = new ArrayList<String>();
+ Observer<ArrayList<String>> observer = new
Observer<ArrayList<String>>() {
+
+ public void notify(ArrayList<String> event)
+ {
+ }
+
+ };
+ observerWithEventObjectContainsTypeVariables(anEvent, observer);
}
+ private <E> void observerWithEventObjectContainsTypeVariables(ArrayList<E>
eventToFire, Observer<ArrayList<E>> observer)
+ {
+ getCurrentManager().addObserver(observer, new
TypeLiteral<ArrayList<E>>() {});
+ }
+
@Test(groups = { "events", "broken" }, expectedExceptions = {
IllegalArgumentException.class })
@SpecAssertions( { @SpecAssertion(section = "7.3", id = "g") })
public void testManagerAddObserverWithEventTypeWildcardsFails()
{
- // 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>();
- assert false;
+// ArrayList<?> anEvent = new ArrayList<String>();
+// Observer<ArrayList<String>> observer = new
Observer<ArrayList<String>>() {
+//
+// public void notify(ArrayList<String> event)
+// {
+// }
+//
+// };
+// observerWithEventObjectContainsTypeWildcard(anEvent, observer);
}
+// private void observerWithEventObjectContainsTypeWildcard(ArrayList<?>
eventToFire, Observer<ArrayList<?>> observer)
+// {
+// getCurrentManager().addObserver(observer, new
TypeLiteral<ArrayList<?>>() {});
+// }
+
@Test(groups = { "events", "underInvestigation" },
expectedExceptions = { IllegalArgumentException.class })
@SpecAssertions( { @SpecAssertion(section = "7.3", id = "h") })
public void testManagerRemoveObserverWithEventTypeParametersFails()
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java 2009-04-03
20:40:25 UTC (rev 2296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+class DisobedientDog
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java 2009-04-03
20:40:25 UTC (rev 2296)
@@ -0,0 +1,69 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+import static javax.ejb.TransactionManagementType.BEAN;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.event.BeforeTransactionCompletion;
+import javax.event.Observes;
+import javax.transaction.UserTransaction;
+
+@Stateless
+@TransactionManagement(BEAN)
+public class DogTrainer implements Trainer
+{
+ @Resource
+ private UserTransaction userTransaction;
+
+ public void train(@Observes @BeforeTransactionCompletion DisobedientDog dog)
+ {
+ try
+ {
+ userTransaction.setRollbackOnly();
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Failed to set transaction rollback only", e);
+ }
+ }
+
+ public void trainNewTricks(@Observes @BeforeTransactionCompletion ShowDog dog)
+ {
+ try
+ {
+ userTransaction.begin();
+ userTransaction.rollback();
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Failed to start new transaction", e);
+ }
+ }
+
+ public void trainCompanion(@Observes @BeforeTransactionCompletion SmallDog dog)
+ {
+ try
+ {
+ userTransaction.rollback();
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Failed to start new transaction", e);
+ }
+ }
+
+ public void trainSightSeeing(@Observes @BeforeTransactionCompletion LargeDog dog)
+ {
+ try
+ {
+ userTransaction.commit();
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Failed to start new transaction", e);
+ }
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java 2009-04-03
14:34:40 UTC (rev 2295)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java 2009-04-03
20:40:25 UTC (rev 2296)
@@ -20,6 +20,7 @@
import java.lang.annotation.Annotation;
import java.math.BigInteger;
+import javax.ejb.EJBException;
import javax.inject.AnnotationLiteral;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -42,7 +43,6 @@
@Artifact
@Packaging(PackagingType.EAR)
@IntegrationTest
-@Test
public class EventTest extends AbstractJSR299Test
{
@@ -97,8 +97,10 @@
assert dog.isCorrectTransactionState();
}
- @Test(groups = { "events", "integration", "broken" })
- @SpecAssertions( { @SpecAssertion(section = "7.5.6", id = "d"),
@SpecAssertion(section = "7.5.6", id = "j") })
+ @Test(groups = { "events", "integration" })
+ @SpecAssertions( {
+ @SpecAssertion(section = "7.5.6", id = "d"),
+ @SpecAssertion(section = "7.5.6", id = "j") })
public void testAfterTransactionSuccessObserver() throws InterruptedException
{
dog.setCorrectContext(false);
@@ -110,7 +112,9 @@
}
@Test(groups = { "events", "integration", "ri-broken"
})
- @SpecAssertions( { @SpecAssertion(section = "7.5.6", id = "e"),
@SpecAssertion(section = "7.5.6", id = "k") })
+ @SpecAssertions( {
+ @SpecAssertion(section = "7.5.6", id = "e"),
+ @SpecAssertion(section = "7.5.6", id = "k") })
public void testAfterTransactionFailureObserver() throws InterruptedException
{
dog.setCorrectContext(false);
@@ -122,7 +126,10 @@
}
@Test(groups = { "events", "integration" })
- @SpecAssertions( { @SpecAssertion(section = "7.5.6", id = "b"),
@SpecAssertion(section = "7.5.6", id = "h"), @SpecAssertion(section =
"7.5.8", id = "e") })
+ @SpecAssertions( {
+ @SpecAssertion(section = "7.5.6", id = "b"),
+ @SpecAssertion(section = "7.5.6", id = "h"),
+ @SpecAssertion(section = "7.5.8", id = "e") })
public void testBeforeTransactionCompletionObserver()
{
dog.setCorrectContext(false);
@@ -211,32 +218,36 @@
{
assert false;
}
-
- @Test(groups = { "stub", "events", "integration" })
+
+ @Test(groups = { "events", "integration" })
@SpecAssertion(section = "7.4", id = "d")
public void testObserverCanSetRollbackOnlyOnTransaction()
{
- assert false;
+ Agent dogAgent = getCurrentManager().getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new DisobedientDog());
}
- @Test(groups = { "stub", "events", "integration" })
+ @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
@SpecAssertion(section = "7.4", id = "e")
public void testObserverCannotInitiateJtaTransaction()
{
- assert false;
+ Agent dogAgent = getCurrentManager().getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new ShowDog());
}
- @Test(groups = { "stub", "events", "integration" })
+ @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
@SpecAssertion(section = "7.4", id = "f")
public void testObserverCannotCommitJtaTransaction()
{
- assert false;
+ Agent dogAgent = getCurrentManager().getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new LargeDog());
}
- @Test(groups = { "stub", "events", "integration" })
+ @Test(groups = { "ri-broken", "events", "integration" },
expectedExceptions = EJBException.class)
@SpecAssertion(section = "7.4", id = "g")
public void testObserverCannotRollbackJtaTransaction()
{
- assert false;
+ Agent dogAgent = getCurrentManager().getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new SmallDog());
}
}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java 2009-04-03
20:40:25 UTC (rev 2296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+public class LargeDog
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java 2009-04-03
20:40:25 UTC (rev 2296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+public class ShowDog
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java 2009-04-03
20:40:25 UTC (rev 2296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+public class SmallDog
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java 2009-04-03
20:40:25 UTC (rev 2296)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+import javax.ejb.Local;
+
+@Local
+public interface Trainer
+{
+ public void train(DisobedientDog dog);
+
+ public void trainNewTricks(ShowDog dog);
+
+ public void trainSightSeeing(LargeDog dog);
+
+ public void trainCompanion(SmallDog dog);
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-04-03 14:34:40 UTC (rev 2295)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-04-03 20:40:25 UTC (rev 2296)
@@ -4007,8 +4007,9 @@
<section id="7.4" title="Observer notification">
- <assertion id="a">
+ <assertion id="a" testable="false">
<text>When an event is fired by the application the container must determine
the observers for that event by calling |Manager.resolveObservers()|, passing the event
object and all event bindings</text>
+ <note>This is not testable</note>
</assertion>
<assertion id="b">