/home/mario/oci/jnb/dataaccess/source/test/java/net/sf/hibernate/MockTransaction.java
|
1 /**
2 * This software program, Simple Data Access Layer (SDAL), is copyrighted by Object
3 * Computing inc of St. Louis MO USA. It is provided under the open-source model
4 * and is free of license fees. You are free to modify this code for your own use
5 * but you may not claim copyright.
6 *
7 * Since SDAL is open source and free of licensing fees, you are free to use,
8 * modify, and distribute the source code, as long as you include this copyright
9 * statement.
10 *
11 * In particular, you can use SDAL to build proprietary software and are under no
12 * obligation to redistribute any of your source code that is built using SDAL.
13 * Note, however, that you may not do anything to the SDAL code, such as
14 * copyrighting it yourself or claiming authorship of the SDAL code, that will
15 * prevent SDAL from being distributed freely using an open source development
16 * model.
17 *
18 * Warranty
19 * LICENSED PRODUCT, SDAL, IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
20 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE,
21 * NONINFRINGEMENT, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
22 *
23 * Support
24 * LICENSED PRODUCT, SDAL, IS PROVIDED WITH NO SUPPORT AND WITHOUT ANY OBLIGATION ON THE
25 * PART OF OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES TO ASSIST IN ITS USE,
26 * CORRECTION, MODIFICATION OR ENHANCEMENT.
27 *
28 * Support may be available from OCI to users who have agreed to a support
29 * contract.
30 *
31 * Liability
32 * OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
33 * RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
34 * LICENSED PRODUCT OR ANY PART THEREOF.
35 *
36 * IN NO EVENT WILL OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR ANY
37 * LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL DAMAGES,
38 * EVEN IF OCI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
39 *
40 * Copyright OCI. St. Louis MO USA, 2004
41 *
42 */
43 package net.sf.hibernate;
44
45 public class MockTransaction implements Transaction {
46
47 public boolean commitCalled;
48 public Throwable commitException;
49 public void commit() throws net.sf.hibernate.HibernateException {
50 commitCalled = true;
51 if (commitException != null) {
52 if (commitException instanceof net.sf.hibernate.HibernateException)
53 throw (net.sf.hibernate.HibernateException) commitException;
54 if (commitException instanceof java.lang.RuntimeException)
55 throw (java.lang.RuntimeException) commitException;
56 if (commitException instanceof java.lang.Error)
57 throw (java.lang.Error) commitException;
58 throw new RuntimeException();
59 }
60 }
61
62 public boolean rollbackCalled;
63 public Throwable rollbackException;
64 public void rollback() throws net.sf.hibernate.HibernateException {
65 rollbackCalled = true;
66 if (rollbackException != null) {
67 if (rollbackException instanceof net.sf.hibernate.HibernateException)
68 throw (net.sf.hibernate.HibernateException) rollbackException;
69 if (rollbackException instanceof java.lang.RuntimeException)
70 throw (java.lang.RuntimeException) rollbackException;
71 if (rollbackException instanceof java.lang.Error)
72 throw (java.lang.Error) rollbackException;
73 throw new RuntimeException();
74 }
75 }
76
77 public boolean wasRolledBackCalled;
78 public boolean wasRolledBackReturn;
79 public Throwable wasRolledBackException;
80 public boolean wasRolledBack() throws net.sf.hibernate.HibernateException {
81 wasRolledBackCalled = true;
82 if (wasRolledBackException != null) {
83 if (wasRolledBackException instanceof net.sf.hibernate.HibernateException)
84 throw (net.sf.hibernate.HibernateException) wasRolledBackException;
85 if (wasRolledBackException instanceof java.lang.RuntimeException)
86 throw (java.lang.RuntimeException) wasRolledBackException;
87 if (wasRolledBackException instanceof java.lang.Error)
88 throw (java.lang.Error) wasRolledBackException;
89 throw new RuntimeException();
90 }
91 return this.wasRolledBackReturn;
92 }
93
94 public boolean wasCommittedCalled;
95 public boolean wasCommittedReturn;
96 public Throwable wasCommittedException;
97 public boolean wasCommitted() throws net.sf.hibernate.HibernateException {
98 wasCommittedCalled = true;
99 if (wasCommittedException != null) {
100 if (wasCommittedException instanceof net.sf.hibernate.HibernateException)
101 throw (net.sf.hibernate.HibernateException) wasCommittedException;
102 if (wasCommittedException instanceof java.lang.RuntimeException)
103 throw (java.lang.RuntimeException) wasCommittedException;
104 if (wasCommittedException instanceof java.lang.Error)
105 throw (java.lang.Error) wasCommittedException;
106 throw new RuntimeException();
107 }
108 return this.wasCommittedReturn;
109 }
110
111 }