[webbeans-commits] Webbeans SVN: r1560 - 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
Tue Feb 17 13:35:45 EST 2009


Author: dallen6
Date: 2009-02-17 13:35:44 -0500 (Tue, 17 Feb 2009)
New Revision: 1560

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/DogAgent.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/PomeranianInterface.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Spitz.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/integration/event/Pomeranian.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java
Log:
Added some integration tests which are not activated yet

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/DogAgent.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/DogAgent.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/DogAgent.java	2009-02-17 18:35:44 UTC (rev 1560)
@@ -0,0 +1,41 @@
+package org.jboss.jsr299.tck.integration.event;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import javax.transaction.UserTransaction;
+
+import static javax.ejb.TransactionManagementType.BEAN;
+
+ at Stateless
+ at TransactionManagement(BEAN)
+public class DogAgent
+{
+   @Resource
+   private UserTransaction userTransaction;
+
+   @Current
+   private Manager jsr299Manager;
+
+   public void sendInTransaction(Object event) throws EJBException
+   {
+      try
+      {
+         userTransaction.begin();
+         jsr299Manager.fireEvent(event);
+         userTransaction.commit();
+      }
+      catch (Exception e)
+      {
+         throw new EJBException("Transaction failure", e);
+      }
+   }
+
+   public void sendOutsideTransaction(Object event)
+   {
+      jsr299Manager.fireEvent(event);
+   }
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/DogAgent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

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-17 13:49:31 UTC (rev 1559)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/EventTest.java	2009-02-17 18:35:44 UTC (rev 1560)
@@ -23,6 +23,8 @@
 import javax.inject.manager.Bean;
 
 import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.EjbArtifact;
+import org.jboss.jsr299.tck.impl.packaging.IntegrationTest;
 import org.hibernate.tck.annotations.SpecAssertion;
 import org.testng.annotations.Test;
 
@@ -34,6 +36,8 @@
  *         Spec version: Public Release Draft 2
  * 
  */
+//@EjbArtifact
+//@IntegrationTest
 public class EventTest extends AbstractDeclarativeTest
 {
    @Test(groups = { "stub", "events", "integration" })
@@ -50,43 +54,37 @@
       assert false;
    }
 
-   @Test(groups = { "events", "integration" })
-   @SpecAssertion(section = "7.5", id = "unknown")
-   public void testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic()
-   {
-      deployBeans(Pomeranian.class);
-      Set<Bean<Object>> beans = getCurrentManager().resolveByType(Object.class);
-      assert beans.size() >= 2;
-      Set<Observer<String>> observers = getCurrentManager().resolveObservers("An event");
-      assert observers.size() == 2;
-   }
-
    @Test(groups = { "stub", "events", "integration" })
    @SpecAssertion(section = "7.5.6", id = "unknown")
    public void testTransactionalObserverNotifiedImmediatelyWhenNoTransactionInProgress()
    {
-      assert false;
+      Pomeranian dog = (Pomeranian) getCurrentManager().getInstanceByName("pomeranian");
+      DogAgent dogAgent = (DogAgent) getCurrentManager().getInstanceByName("dogAgent");
+      dogAgent.sendOutsideTransaction("event");
+      assert dog.getNotificationThread().equals(Thread.currentThread());
    }
 
    @Test(groups = { "stub", "events", "integration" })
    @SpecAssertion(section = "7.5.6", id = "unknown")
    public void testAfterTransactionCompletionObserver()
    {
-      assert false;
+      DogAgent dogAgent = (DogAgent) getCurrentManager().getInstanceByName("dogAgent");
+      dogAgent.sendInTransaction("event");
    }
 
    @Test(groups = { "stub", "events", "integration" })
    @SpecAssertion(section = "7.5.6", id = "unknown")
    public void testAfterTransactionSuccessObserver()
    {
-      assert false;
+      DogAgent dogAgent = (DogAgent) getCurrentManager().getInstanceByName("dogAgent");
+      dogAgent.sendInTransaction(new Integer(4));
    }
 
-   @Test(groups = { "stub", "events", "integration" })
+   @Test(groups = { "events", "integration" })
    @SpecAssertion(section = "7.5.6", id = "unknown")
    public void testAfterTransactionFailureObserver()
    {
-      assert false;
+      getCurrentManager().fireEvent(new Float(4.0));
    }
 
    @Test(groups = { "stub", "events", "integration" })
@@ -125,19 +123,19 @@
    /**
     * 
     */
-   @Test(groups = { "events", "integration", "broken" })
+   @Test(groups = { "stub", "events", "integration" })
    @SpecAssertion(section = "7.5.8", id = "unknown")
    public void testEnterpriseBeanObserverMethodCalledWithCallerContext()
    {
-      deployBeans(Pomeranian.class);
-      Set<Bean<Object>> beans = getCurrentManager().resolveByType(Object.class);
-      assert beans.size() >= 1;
+      Set<Bean<Pomeranian>> beans = getCurrentManager().resolveByType(Pomeranian.class);
+      assert !beans.isEmpty();
       String event = "A new event";
       Set<Observer<String>> observers = getCurrentManager().resolveObservers(event);
-      assert observers.size() == 2;
+      assert observers.size() == 1;
 
       getCurrentManager().fireEvent(event);
-      assert Thread.currentThread().equals(Pomeranian.notificationThread);
+      Pomeranian dog = (Pomeranian) getCurrentManager().getInstanceByName("pomeranian");
+      assert Thread.currentThread().equals(dog.getNotificationThread());
    }
 
    @Test(groups = { "stub", "events", "integration" })

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/Pomeranian.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/Pomeranian.java	2009-02-17 13:49:31 UTC (rev 1559)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/Pomeranian.java	2009-02-17 18:35:44 UTC (rev 1560)
@@ -1,22 +1,48 @@
 package org.jboss.jsr299.tck.integration.event;
 
+import java.math.BigInteger;
+
 import javax.annotation.Named;
+import javax.annotation.Resource;
 import javax.ejb.Stateful;
+import javax.event.AfterTransactionCompletion;
+import javax.event.AfterTransactionFailure;
+import javax.event.AfterTransactionSuccess;
 import javax.event.Observes;
+import javax.transaction.UserTransaction;
 
 @Stateful
 @Tame
 @Named("Teddy")
 class Pomeranian implements PomeranianInterface
 {
-   public static Thread notificationThread;
-   
-   public void observeSimpleEvent(@Observes String someEvent)
+   @Resource
+   private UserTransaction transaction;
+
+   public Thread notificationThread;
+
+   public void observeStringEvent(@Observes @AfterTransactionCompletion String someEvent)
    {
       notificationThread = Thread.currentThread();
    }
 
-   public static void staticallyObserveEvent(@Observes String someEvent)
+   public void observeIntegerEvent(@Observes @AfterTransactionSuccess Integer event)
    {
+
    }
+
+   public void observeFloatEvent(@Observes @AfterTransactionFailure Float event)
+   {
+
+   }
+
+   public void observeBigIntegerEvent(@Observes BigInteger event)
+   {
+
+   }
+
+   public Thread getNotificationThread()
+   {
+      return notificationThread;
+   }
 }

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-17 13:49:31 UTC (rev 1559)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/EventTest.java	2009-02-17 18:35:44 UTC (rev 1560)
@@ -15,9 +15,9 @@
 import javax.inject.TypeLiteral;
 import javax.inject.manager.Bean;
 
-import org.jboss.jsr299.tck.AbstractDeclarativeTest;
 import org.hibernate.tck.annotations.SpecAssertion;
 import org.hibernate.tck.annotations.SpecAssertions;
+import org.jboss.jsr299.tck.AbstractDeclarativeTest;
 import org.testng.annotations.Test;
 
 /**
@@ -356,6 +356,15 @@
       assert resolvedIntegerObservers.size() == 1;
    }
 
+   @Test(groups = { "events", "ejb" })
+   @SpecAssertion(section = "7.5", id = "d")
+   public void testObserverMethodOnEnterpriseBeanIsBusinessMethodOrStatic()
+   {
+      deployBeans(Spitz.class);
+      Set<Observer<String>> observers = getCurrentManager().resolveObservers("An event");
+      assert observers.size() == 2;
+   }
+
    @Test(groups = { "events" }, expectedExceptions = DefinitionException.class)
    @SpecAssertion(section = "7.5", id = "d")
    public void testObserverMethodOnEnterpriseBeanNotBusinessMethodOrStaticFails()

Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/PomeranianInterface.java (from rev 1558, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/integration/event/PomeranianInterface.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/PomeranianInterface.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/PomeranianInterface.java	2009-02-17 18:35:44 UTC (rev 1560)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.unit.event;
+
+public interface PomeranianInterface
+{
+   
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Spitz.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Spitz.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Spitz.java	2009-02-17 18:35:44 UTC (rev 1560)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.unit.event;
+
+import javax.annotation.Named;
+import javax.ejb.Stateful;
+import javax.event.Observes;
+
+ at Stateful
+ at Tame
+ at Named("Teddy")
+public class Spitz implements PomeranianInterface
+{
+   public static Thread notificationThread;
+
+   public void observeSimpleEvent(@Observes String someEvent)
+   {
+      notificationThread = Thread.currentThread();
+   }
+
+   public static void staticallyObserveEvent(@Observes String someEvent)
+   {
+   }
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/event/Spitz.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list