Source Code Cross Referenced for B_TxAttribute.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » clients » transaction » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.jtests.clients.transaction 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         * 
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         * 
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         * 
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id:
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.clients.transaction;
027:
028:        import java.rmi.RemoteException;
029:
030:        import org.objectweb.jonas.jtests.beans.transacted.Simple;
031:        import org.objectweb.jonas.jtests.util.JTestCase;
032:
033:        /**
034:         * Transactional attribute test cases
035:         * tests here are common to entity and session beans.
036:         * beans used : transacted
037:         * @author Ph.Coq, Ph.Durieux (jonas team)
038:         */
039:        public abstract class B_TxAttribute extends JTestCase {
040:
041:            /**
042:             * constructor
043:             * @param name name of the test suite.
044:             */
045:            public B_TxAttribute(String name) {
046:                super (name);
047:            }
048:
049:            /**
050:             * Sets up the fixture, here load the beans if not loaded yet.
051:             * This method is called before a test is executed.
052:             */
053:            protected void setUp() {
054:                super .setUp();
055:                useBeans("transacted", true);
056:            }
057:
058:            /**
059:             * Get an instance of the bean.
060:             * This method depends on the home used to get it.
061:             * For entity bean, the arg is used to get a particular instance.
062:             * For session beans, we get any session bean from the pool.
063:             */
064:            public abstract Simple getSimple(int i) throws Exception;
065:
066:            // --------------------------------------------------------------------
067:            // test cases
068:            // --------------------------------------------------------------------
069:
070:            /**
071:             * Test of NotSupported attribute
072:             * A business method with NotSupported is called outside TX
073:             * this method returns if the thread is associated to a transaction
074:             * 
075:             * the expected value is  false
076:             */
077:            public void testSimpleOptNotSupportedRemove() throws Exception {
078:
079:                Simple s = getSimple(10);
080:                assertEquals(false, s.opwith_notsupported());
081:                s.remove();
082:
083:            }
084:
085:            /**
086:             * Test of RequiresNew attribute
087:             * A business method with RequiresNew is called outside TX
088:             * this method returns if the thread is associated to a transaction
089:             *
090:             * the expected value is  true
091:             */
092:            public void testGetSimpleOptRequiresNewRemove() throws Exception {
093:
094:                Simple s = getSimple(11);
095:                assertEquals(true, s.opwith_requires_new());
096:                s.remove();
097:
098:            }
099:
100:            /**
101:             * Test of Required attribute
102:             * A business method with Required is called outside TX
103:             * this method returns if the thread is associated to a transaction
104:             *
105:             * the expected value is  true
106:             */
107:            public void testGetSimpleOptRequiredRemove() throws Exception {
108:
109:                Simple s = getSimple(12);
110:                assertEquals(true, s.opwith_required());
111:                s.remove();
112:            }
113:
114:            /**
115:             * Test of RequiresNew attribute
116:             * A business method with RequiresNew is called inside TX
117:             * this method returns if the thread is associated to a transaction
118:             *
119:             * the expected value is  true
120:             */
121:            public void testGetSimpleOptRequiresNewRemoveInTx()
122:                    throws Exception {
123:                Simple s = getSimple(21);
124:                utx.begin();
125:                try {
126:                    assertEquals(true, s.opwith_requires_new());
127:                } finally {
128:                    utx.rollback();
129:                    s.remove();
130:                }
131:            }
132:
133:            /**
134:             * Test of Required attribute
135:             * A business method with Required is called inside  TX
136:             * this method returns if the thread is associated to a transaction
137:             *
138:             * the expected value is  true
139:             */
140:            public void testGetSimpleOptRequiredRemoveInTx() throws Exception {
141:
142:                Simple s = getSimple(22);
143:                utx.begin();
144:                try {
145:                    assertEquals(true, s.opwith_required());
146:                } finally {
147:                    utx.rollback();
148:                    s.remove();
149:                }
150:
151:            }
152:
153:            /**
154:             * Test of Mandatory  attribute
155:             * A business method with Mandatory is called inside  TX
156:             * this method returns if the thread is associated to a transaction
157:             *
158:             * the expected value is  true
159:             */
160:            public void testMandatoryTx() throws Exception {
161:
162:                Simple s = getSimple(23);
163:                utx.begin();
164:                try {
165:                    assertEquals(true, s.opwith_mandatory());
166:                } finally {
167:                    utx.rollback();
168:                    s.remove();
169:                }
170:            }
171:
172:            /**
173:             * Test of Never attribute
174:             * A business method with Mandatory is called inside TX
175:             * this method returns if the thread is associated to a transaction
176:             *
177:             * A java.rmi.RemoteException must be received
178:             */
179:            public void testNeverTx() throws Exception {
180:
181:                Simple s = getSimple(24);
182:                utx.begin();
183:                try {
184:                    s.opwith_never();
185:                    fail("never: should raise exception");
186:                } catch (RemoteException e) {
187:                } finally {
188:                    utx.rollback();
189:                    s.remove();
190:                }
191:            }
192:
193:            /**
194:             * Test of Supports  attribute
195:             * A business method with Supports is called inside TX
196:             * this method returns if the thread is associated to a transaction
197:             * 
198:             * the expected value is  true
199:             */
200:            public void testSupportsTx() throws Exception {
201:
202:                Simple s = getSimple(25);
203:                utx.begin();
204:                try {
205:                    assertEquals(true, s.opwith_supports());
206:                } finally {
207:                    utx.rollback();
208:                    s.remove();
209:                }
210:
211:            }
212:
213:            /**
214:             * Test the sequence of several calls to methods
215:             * with different transactional contexts
216:             */
217:            public void testNoTx() throws Exception {
218:
219:                Simple s = getSimple(1);
220:                assertEquals(false, s.opwith_notsupported());
221:                assertEquals(true, s.opwith_requires_new());
222:                assertEquals(true, s.opwith_required());
223:                assertEquals(false, s.opwith_never());
224:                assertEquals(false, s.opwith_supports());
225:                s.remove();
226:            }
227:
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.