[seam-commits] Seam SVN: r13468 - in modules/persistence/trunk: impl/src/main/java/org/jboss/seam/persistence/transaction and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Jul 22 02:28:56 EDT 2010


Author: swd847
Date: 2010-07-22 02:28:55 -0400 (Thu, 22 Jul 2010)
New Revision: 13468

Removed:
   modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/event/
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionObserver.java
Modified:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SynchronizationRegistry.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionInterceptorTest.java
Log:
removed transaction events, they were not documented in seam 2 and cannot really be made to work reliably



Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SynchronizationRegistry.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SynchronizationRegistry.java	2010-07-22 05:35:50 UTC (rev 13467)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SynchronizationRegistry.java	2010-07-22 06:28:55 UTC (rev 13468)
@@ -28,8 +28,6 @@
 import javax.transaction.Status;
 import javax.transaction.Synchronization;
 
-import org.jboss.seam.persistence.transaction.event.AfterTransactionCompletion;
-import org.jboss.seam.persistence.transaction.event.BeforeTransactionCompletion;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -62,7 +60,6 @@
 
    void afterTransactionCompletion(boolean success)
    {
-      beanManager.fireEvent(new AfterTransactionCompletion(success));
       for (Synchronization sync : synchronizations)
       {
          try
@@ -79,7 +76,6 @@
 
    void beforeTransactionCompletion()
    {
-      beanManager.fireEvent(new BeforeTransactionCompletion());
       for (Synchronization sync : synchronizations)
       {
          try

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionInterceptorTest.java	2010-07-22 05:35:50 UTC (rev 13467)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionInterceptorTest.java	2010-07-22 06:28:55 UTC (rev 13468)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.seam.transactions.test;
 
 import java.util.List;
@@ -30,6 +51,12 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+/**
+ * Tests the @Transactional interceptor
+ * 
+ * @author stuart
+ * 
+ */
 @RunWith(Arquillian.class)
 public class TransactionInterceptorTest
 {
@@ -41,7 +68,7 @@
       war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
       war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
       war.addPackage(Transaction.class.getPackage());
-      war.addClasses(TransactionInterceptorTest.class, TransactionManagedBean.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class, TransactionObserver.class);
+      war.addClasses(TransactionInterceptorTest.class, TransactionManagedBean.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
       war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
       war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
       war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
@@ -57,50 +84,28 @@
    @PersistenceContext
    EntityManager em;
 
-   @Inject
-   TransactionObserver observer;
-
    @Test
    public void testTransactionInterceptor() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
    {
-      observer.setEnabled(true);
+
+      bean.addHotel();
+      assertHotels(1);
       try
       {
-         observer.reset(true);
-         bean.addHotel();
-         assertHotels(1);
-         observer.verify();
-         observer.reset(false);
-         try
-         {
-            bean.failToAddHotel();
-         }
-         catch (Exception e)
-         {
-         }
-         assertHotels(1);
-         observer.verify();
-         observer.reset(true);
-         try
-         {
-            bean.addHotelWithApplicationException();
-         }
-         catch (DontRollBackException e)
-         {
-         }
-         observer.setEnabled(false);
-         assertHotels(2);
-         observer.verify();
+         bean.failToAddHotel();
       }
       catch (Exception e)
       {
-         throw new RuntimeException(e);
       }
-      finally
+      assertHotels(1);
+      try
       {
-         observer.setEnabled(false);
+         bean.addHotelWithApplicationException();
       }
-
+      catch (DontRollBackException e)
+      {
+      }
+      assertHotels(2);
    }
 
    public void assertHotels(int count) throws NotSupportedException, SystemException

Deleted: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionObserver.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionObserver.java	2010-07-22 05:35:50 UTC (rev 13467)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionObserver.java	2010-07-22 06:28:55 UTC (rev 13468)
@@ -1,66 +0,0 @@
-package org.jboss.seam.transactions.test;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Observes;
-
-import org.jboss.seam.persistence.transaction.event.AfterTransactionCompletion;
-import org.jboss.seam.persistence.transaction.event.BeforeTransactionCompletion;
-
- at ApplicationScoped
-public class TransactionObserver
-{
-   private boolean expectSuccess, beforeTransaction, afterTransaction;
-   private boolean enabled = false;
-
-   public boolean isEnabled()
-   {
-      return enabled;
-   }
-
-   public void setEnabled(boolean enabled)
-   {
-      this.enabled = enabled;
-   }
-
-   public void reset(boolean expected)
-   {
-      beforeTransaction = false;
-      afterTransaction = false;
-      expectSuccess = expected;
-   }
-
-   public boolean isBeforeTransaction()
-   {
-      return beforeTransaction;
-   }
-
-   public boolean isAfterTransaction()
-   {
-      return afterTransaction;
-   }
-
-   public void observeBeforeTransactionCommit(@Observes BeforeTransactionCompletion event)
-   {
-      beforeTransaction = true;
-   }
-
-   public void observeBeforeTransactionCommit(@Observes AfterTransactionCompletion event)
-   {
-      afterTransaction = true;
-      if (enabled)
-      {
-         if (expectSuccess != event.success())
-         {
-            throw new RuntimeException("Expected success to be " + expectSuccess);
-         }
-      }
-   }
-
-   public void verify()
-   {
-      if (!((beforeTransaction || !expectSuccess) && afterTransaction))
-      {
-         throw new RuntimeException("Events not recieved before:" + beforeTransaction + " after:" + afterTransaction);
-      }
-   }
-}



More information about the seam-commits mailing list