Source Code Cross Referenced for MockUserTransaction.java in  » Testing » mockrunner-0.4 » com » mockrunner » mock » ejb » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » mockrunner 0.4 » com.mockrunner.mock.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.mockrunner.mock.ejb;
002:
003:        import javax.transaction.HeuristicMixedException;
004:        import javax.transaction.HeuristicRollbackException;
005:        import javax.transaction.NotSupportedException;
006:        import javax.transaction.RollbackException;
007:        import javax.transaction.Status;
008:        import javax.transaction.SystemException;
009:        import javax.transaction.UserTransaction;
010:
011:        /**
012:         * Mock implementation of <code>UserTransaction</code>.
013:         */
014:        public class MockUserTransaction implements  UserTransaction {
015:            private boolean beginCalled;
016:            private boolean commitCalled;
017:            private boolean rollbackCalled;
018:            private boolean rollbackOnlyCalled;
019:            private int transactionTimeout;
020:            private int beginCalls;
021:            private int commitCalls;
022:            private int rollbackCalls;
023:            private int rollbackOnlyCalls;
024:
025:            public MockUserTransaction() {
026:                reset();
027:            }
028:
029:            /**
030:             * Resets the state, i.e. sets the status to
031:             * <code>Status.STATUS_NO_TRANSACTION</code>
032:             * and the number of calls to 0.
033:             */
034:            public void reset() {
035:                beginCalled = false;
036:                commitCalled = false;
037:                rollbackCalled = false;
038:                rollbackOnlyCalled = false;
039:                transactionTimeout = 0;
040:                beginCalls = 0;
041:                commitCalls = 0;
042:                rollbackCalls = 0;
043:                rollbackOnlyCalls = 0;
044:            }
045:
046:            /**
047:             * Returns if {@link #begin} was called.
048:             * @return was {@link #begin} called
049:             */
050:            public boolean wasBeginCalled() {
051:                return beginCalled;
052:            }
053:
054:            /**
055:             * Returns if {@link #commit} was called.
056:             * @return was {@link #commit} called
057:             */
058:            public boolean wasCommitCalled() {
059:                return commitCalled;
060:            }
061:
062:            /**
063:             * Returns if {@link #rollback} was called.
064:             * @return was {@link #rollback} called
065:             */
066:            public boolean wasRollbackCalled() {
067:                return rollbackCalled;
068:            }
069:
070:            /**
071:             * Returns if {@link #setRollbackOnly} was called.
072:             * @return was {@link #setRollbackOnly} called
073:             */
074:            public boolean wasRollbackOnlyCalled() {
075:                return rollbackOnlyCalled;
076:            }
077:
078:            /**
079:             * Returns the transaction timeout.
080:             * @return the transaction timeout
081:             */
082:            public int getTransactionTimeout() {
083:                return transactionTimeout;
084:            }
085:
086:            /**
087:             * Returns the number of overall {@link #begin} calls.
088:             * @return the number of overall {@link #begin} calls
089:             */
090:            public int getNumberBeginCalls() {
091:                return beginCalls;
092:            }
093:
094:            /**
095:             * Returns the number of overall {@link #commit} calls.
096:             * @return the number of overall {@link #commit} calls
097:             */
098:            public int getNumberCommitCalls() {
099:                return commitCalls;
100:            }
101:
102:            /**
103:             * Returns the number of overall {@link #rollback} calls.
104:             * @return the number of overall {@link #rollback} calls
105:             */
106:            public int getNumberRollbackCalls() {
107:                return rollbackCalls;
108:            }
109:
110:            /**
111:             * Returns the number of overall {@link #setRollbackOnly} calls.
112:             * @return the number of overall {@link #setRollbackOnly} calls
113:             */
114:            public int getNumberRollbackOnlyCalls() {
115:                return rollbackOnlyCalls;
116:            }
117:
118:            /**
119:             * Returns the status of this transaction.
120:             * @return the status of this transaction
121:             */
122:            public int getStatus() throws SystemException {
123:                if (rollbackCalled)
124:                    return Status.STATUS_ROLLEDBACK;
125:                if (commitCalled)
126:                    return Status.STATUS_COMMITTED;
127:                if (rollbackOnlyCalled)
128:                    return Status.STATUS_MARKED_ROLLBACK;
129:                if (beginCalled)
130:                    return Status.STATUS_ACTIVE;
131:                return Status.STATUS_NO_TRANSACTION;
132:            }
133:
134:            /**
135:             * Starts the transaction. The status will be
136:             * <code>Status.STATUS_ACTIVE</code> and the
137:             * flags regarding <code>wasXYZCalled</code>
138:             * are reset to <code>false</code>. This method
139:             * does not reset the number of overall calls.
140:             */
141:            public void begin() throws NotSupportedException, SystemException {
142:                beginCalled = true;
143:                commitCalled = false;
144:                rollbackCalled = false;
145:                rollbackOnlyCalled = false;
146:                beginCalls++;
147:            }
148:
149:            /**
150:             * Commits the transaction.
151:             */
152:            public void commit() throws RollbackException,
153:                    HeuristicMixedException, HeuristicRollbackException,
154:                    SecurityException, IllegalStateException, SystemException {
155:
156:                commitCalled = true;
157:                commitCalls++;
158:            }
159:
160:            /**
161:             * Rolls back the transaction.
162:             */
163:            public void rollback() throws IllegalStateException,
164:                    SecurityException, SystemException {
165:                rollbackCalled = true;
166:                rollbackCalls++;
167:            }
168:
169:            /**
170:             * Sets the rollback only flag.
171:             */
172:            public void setRollbackOnly() throws IllegalStateException,
173:                    SystemException {
174:                rollbackOnlyCalled = true;
175:                rollbackOnlyCalls++;
176:            }
177:
178:            /**
179:             * Sets the transaction timeout.
180:             * @param timeout the transaction timeout
181:             */
182:            public void setTransactionTimeout(int timeout)
183:                    throws SystemException {
184:                transactionTimeout = timeout;
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.