1   /*
2    * $Id: TestTransaction.java 11468 2008-03-21 17:54:46Z rossmason $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.tck.testmodels.mule;
11  
12  import org.mule.api.transaction.TransactionException;
13  import org.mule.transaction.AbstractSingleResourceTransaction;
14  
15  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
16  
17  /**
18   * A test transaction that does nothing on commit or rollback. The transaction does retain a status so that
19   * developers can determine if the the transaction was rolled back or committed.
20   */
21  public class TestTransaction extends AbstractSingleResourceTransaction
22  {
23      private AtomicBoolean committed = new AtomicBoolean(false);
24      private AtomicBoolean rolledBack = new AtomicBoolean(false);
25  
26      /**
27       * Really begin the transaction. Note that resources are enlisted yet.
28       *
29       * @throws org.mule.api.transaction.TransactionException
30       *
31       */
32      protected void doBegin() throws TransactionException
33      {
34          //do nothing
35      }
36  
37      /**
38       * Commit the transaction on the underlying resource
39       *
40       * @throws org.mule.api.transaction.TransactionException
41       *
42       */
43      protected void doCommit() throws TransactionException
44      {
45          committed.set(true);
46      }
47  
48      /**
49       * Rollback the transaction on the underlying resource
50       *
51       * @throws org.mule.api.transaction.TransactionException
52       *
53       */
54      protected void doRollback() throws TransactionException
55      {
56          rolledBack.set(true);
57      }
58  
59  //    public boolean isCommitted()
60  //    {
61  //        return committed.get();
62  //    }
63  //
64  //    public boolean isRolledBack()
65  //    {
66  //        return rolledBack.get();
67  //    }
68  }