Source Code Cross Referenced for A_TxAttributeEntity.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: A_TxAttributeEntity.java 3313 2003-09-17 08:56:40Z durieuxp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.clients.transaction;
027:
028:        import java.rmi.RemoteException;
029:        import javax.transaction.TransactionRequiredException;
030:        import org.objectweb.jonas.jtests.beans.transacted.Simple;
031:        import org.objectweb.jonas.jtests.beans.transacted.SimpleEHome;
032:
033:        /**
034:         * Here are found transactional attribute tests
035:         * common but specific for all type of entity beans (BMP, CMP1.1, CMP2.0)
036:         * Tests on finder and create methods
037:         * @author Philippe Durieux (jonas team)
038:         */
039:        public abstract class A_TxAttributeEntity extends A_TxAttribute {
040:
041:            /**
042:             * constructor
043:             * @param name name of the test suite.
044:             */
045:            public A_TxAttributeEntity(String name) {
046:                super (name);
047:            }
048:
049:            /**
050:             * return SimpleHome, that can be either BMP, CMP1, or CMP2 bean.
051:             */
052:            protected abstract SimpleEHome getHome();
053:
054:            // -----------------------------------------------------------------
055:            // tests on Create methods
056:            // -----------------------------------------------------------------
057:
058:            /**
059:             * Test Required transactional attributes on create method
060:             * the create method xith required is called outside TX 
061:             * 
062:             */
063:            public void testCreateRequired() throws Exception {
064:                long i = 10;
065:                Simple entity = getHome().createForRequired(i);
066:                entity.remove();
067:            }
068:
069:            /**
070:             * Test Required transactional attributes on create method
071:             * the create method xith required is called inside TX 
072:             * 
073:             */
074:            public void testCreateRequiredTx() throws Exception {
075:                utx.begin();
076:                long i = 11;
077:                Simple entity = null;
078:                try {
079:                    entity = getHome().createForRequired(i);
080:                } finally {
081:                    utx.rollback();
082:                }
083:
084:            }
085:
086:            /**
087:             * Test NotSupported transactional attributes on create method
088:             * the create method xith required is called outside TX 
089:             * 
090:             */
091:            public void testCreateNotSupported() throws Exception {
092:                int i = 12;
093:                Simple entity = getHome().create(i);
094:                entity.remove();
095:            }
096:
097:            /**
098:             * Test NotSupported transactional attributes on create method
099:             * the create method xith required is called inside TX 
100:             * 
101:             */
102:            public void testCreateNotSupportedTx() throws Exception {
103:                utx.begin();
104:                int i = 13;
105:                Simple entity = null;
106:                try {
107:                    entity = getHome().create(i);
108:                } finally {
109:                    utx.rollback();
110:                    entity.remove();
111:                }
112:            }
113:
114:            /**
115:             * Test Never transactional attributes on create method
116:             * the create method xith required is called outside TX 
117:             * 
118:             */
119:            public void testCreateNever() throws Exception {
120:                short i = 14;
121:                Simple entity = getHome().createForNever(i);
122:                entity.remove();
123:            }
124:
125:            /**
126:             * Test Never transactional attributes on create method
127:             * the create method xith required is called inside TX 
128:             * 
129:             */
130:            public void testCreateNeverTx() throws Exception {
131:                utx.begin();
132:                short i = 15;
133:                Simple entity = null;
134:                try {
135:                    entity = getHome().createForNever(i);
136:                    entity.remove();
137:                    fail("never: should raise exception");
138:                } catch (java.rmi.RemoteException e) {
139:                } finally {
140:                    utx.rollback();
141:
142:                }
143:
144:            }
145:
146:            /**
147:             * Test RequiresNew transactional attributes on create method
148:             * the create method xith required is called outside TX 
149:             * 
150:             */
151:            public void testCreateRequiresNew() throws Exception {
152:                String s = "16";
153:                Simple entity = getHome().createForRequiresNew(s);
154:                entity.remove();
155:            }
156:
157:            /**
158:             * Test RequiresNew transactional attributes on create method
159:             * the create method xith required is called inside TX 
160:             * 
161:             */
162:            public void testCreateRequiresNewTx() throws Exception {
163:                utx.begin();
164:                String s = "17";
165:                Simple entity = null;
166:                try {
167:                    entity = getHome().createForRequiresNew(s);
168:                } finally {
169:                    utx.rollback();
170:                    entity.remove();
171:                }
172:            }
173:
174:            /**
175:             * Test Mandatory transactional attributes on create method
176:             * the create method xith required is called outside TX 
177:             * 
178:             */
179:            public void testCreateMandatory() throws Exception {
180:                char c = 'a';
181:                try {
182:                    Simple entity = getHome().createForMandatory(c);
183:                    entity.remove();
184:                    fail("mandatory: should raise exception");
185:                } catch (javax.transaction.TransactionRequiredException e) {
186:                } catch (java.rmi.RemoteException e) {
187:                    assertTrue(e.detail instanceof  javax.transaction.TransactionRequiredException);
188:                }
189:            }
190:
191:            /**
192:             * Test Mandatory transactional attributes on create method
193:             * the create method xith required is called inside TX 
194:             * 
195:             */
196:            public void testCreateMandatoryTx() throws Exception {
197:                utx.begin();
198:                char c = 'b';
199:                Simple entity = null;
200:                try {
201:                    entity = getHome().createForMandatory(c);
202:                } finally {
203:                    utx.rollback();
204:
205:                }
206:            }
207:
208:            /**
209:             * Test Supports transactional attributes on create method
210:             * the create method xith required is called outside TX 
211:             * 
212:             */
213:            public void testCreateSupports() throws Exception {
214:
215:                Simple entity = getHome().createForSupports(false);
216:                entity.remove();
217:            }
218:
219:            /**
220:             * Test Supports transactional attributes on create method
221:             * the create method xith required is called inside TX 
222:             * 
223:             */
224:            public void testCreateSupportsTx() throws Exception {
225:                utx.begin();
226:                Simple entity = null;
227:                try {
228:                    entity = getHome().createForSupports(true);
229:                } finally {
230:                    utx.rollback();
231:
232:                }
233:            }
234:
235:            // -----------------------------------------------------------------
236:            // tests on Home methods
237:            // -----------------------------------------------------------------
238:
239:            /**
240:             * Test of NotSupported attribute
241:             * A home method with NotSupported is called outside TX
242:             * this method returns if the thread is associated to a transaction
243:             * 
244:             * the expected value is  false
245:             */
246:            public void testHomeNotSupported() throws Exception {
247:                assertEquals(false, getHome().opwith_notsupported());
248:            }
249:
250:            /**
251:             * Test of RequiresNew attribute
252:             * A home method with RequiresNew is called outside TX
253:             * this method returns if the thread is associated to a transaction
254:             *
255:             * the expected value is  true
256:             */
257:            public void testHomeRequiresNew() throws Exception {
258:                assertEquals(true, getHome().opwith_requires_new());
259:            }
260:
261:            /**
262:             * Test of Required attribute
263:             * A home method with Required is called outside TX
264:             * this method returns if the thread is associated to a transaction
265:             *
266:             * the expected value is  true
267:             */
268:            public void testHomeRequired() throws Exception {
269:                assertEquals(true, getHome().opwith_required());
270:            }
271:
272:            /**
273:             * Test of Mandatory attribute
274:             * A home method with Mandatory is called outside TX
275:             * this method returns if the thread is associated to a transaction
276:             *
277:             * A javax.transaction.TransactionRequiredException must be received
278:             */
279:
280:            public void testHomeMandatory() throws Exception {
281:                try {
282:                    getHome().opwith_mandatory();
283:                    fail("mandatory: should raise exception");
284:                } catch (javax.transaction.TransactionRequiredException e) {
285:                } catch (RemoteException e) {
286:                    assertTrue(e.detail instanceof  TransactionRequiredException);
287:                }
288:            }
289:
290:            /**
291:             * Test of Never  attribute
292:             * A home method with Never is called outside TX
293:             * this method returns if the thread is associated to a transaction
294:             * 
295:             * the expected value is  false
296:             */
297:            public void testHomeNever() throws Exception {
298:                assertEquals(false, getHome().opwith_never());
299:            }
300:
301:            /**
302:             * Test of Supports  attribute
303:             * A home method with Supports is called outside TX
304:             * this method returns if the thread is associated to a transaction
305:             * 
306:             * the expected value is  false
307:             */
308:            public void testHomeSupports() throws Exception {
309:                assertEquals(false, getHome().opwith_supports());
310:            }
311:
312:            /**
313:             * Test of NotSupported attribute
314:             * A home method with NotSupported is called inside  TX
315:             * this method returns if the thread is associated to a transaction
316:             * 
317:             * the expected value is  false
318:             */
319:            public void testHomeNotSupportedTx() throws Exception {
320:                utx.begin();
321:                try {
322:                    assertEquals(false, getHome().opwith_notsupported());
323:                } finally {
324:                    utx.rollback();
325:                }
326:            }
327:
328:            /**
329:             * Test of RequiresNew attribute
330:             * A home method with RequiresNew is called inside TX
331:             * this method returns if the thread is associated to a transaction
332:             *
333:             * the expected value is  true
334:             */
335:            public void testHomeRequiresNewTx() throws Exception {
336:                utx.begin();
337:                try {
338:                    assertEquals(true, getHome().opwith_requires_new());
339:                } finally {
340:                    utx.rollback();
341:                }
342:            }
343:
344:            /**
345:             * Test of Required attribute
346:             * A home method with Required is called inside  TX
347:             * this method returns if the thread is associated to a transaction
348:             *
349:             * the expected value is  true
350:             */
351:            public void testHomeRequiredTx() throws Exception {
352:                utx.begin();
353:                try {
354:                    assertEquals(true, getHome().opwith_required());
355:                } finally {
356:                    utx.rollback();
357:                }
358:
359:            }
360:
361:            /**
362:             * Test of Mandatory  attribute
363:             * A home method with Mandatory is called inside  TX
364:             * this method returns if the thread is associated to a transaction
365:             *
366:             * the expected value is  true
367:             */
368:            public void testHomeMandatoryTx() throws Exception {
369:                utx.begin();
370:                try {
371:                    assertEquals(true, getHome().opwith_mandatory());
372:                } finally {
373:                    utx.rollback();
374:                }
375:            }
376:
377:            /**
378:             * Test of Never attribute
379:             * A home method with Mandatory is called inside TX
380:             * this method returns if the thread is associated to a transaction
381:             *
382:             * A java.rmi.RemoteException must be received
383:             */
384:            public void testHomeNeverTx() throws Exception {
385:                utx.begin();
386:                try {
387:                    getHome().opwith_never();
388:                    fail("never: should raise exception");
389:                } catch (RemoteException e) {
390:                } finally {
391:                    utx.rollback();
392:                }
393:            }
394:
395:            /**
396:             * Test of Supports  attribute
397:             * A home method with Supports is called inside TX
398:             * this method returns if the thread is associated to a transaction
399:             * 
400:             * the expected value is  true
401:             */
402:            public void testHomeSupportsTx() throws Exception {
403:                utx.begin();
404:                try {
405:                    assertEquals(true, getHome().opwith_supports());
406:                } finally {
407:                    utx.rollback();
408:                }
409:
410:            }
411:
412:            /**
413:             * Test the sequence of several calls to home methods
414:             * with different transactional contexts
415:             */
416:            public void testHomeNoTx() throws Exception {
417:                assertEquals(false, getHome().opwith_notsupported());
418:                assertEquals(true, getHome().opwith_requires_new());
419:                assertEquals(true, getHome().opwith_required());
420:                assertEquals(false, getHome().opwith_never());
421:                assertEquals(false, getHome().opwith_supports());
422:            }
423:
424:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.