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


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 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_Catcher.java 5486 2004-09-23 08:23:20Z joaninh $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jtests.clients.exception;
025:
026:        import java.rmi.RemoteException;
027:
028:        import javax.transaction.Status;
029:        import javax.transaction.TransactionRolledbackException;
030:
031:        import org.objectweb.jonas.jtests.beans.beanexc.AccountS;
032:        import org.objectweb.jonas.jtests.beans.beanexc.AppException;
033:        import org.objectweb.jonas.jtests.util.JTestCase;
034:
035:        /**
036:         * Exception test cases common for all type of beans (Entity/Session)
037:         * @author Ph.Coq
038:         */
039:        public abstract class A_Catcher extends JTestCase {
040:
041:            public A_Catcher(String name) {
042:                super (name);
043:            }
044:
045:            protected void setUp() {
046:                super .setUp();
047:                useBeans("beanexc", true);
048:            }
049:
050:            /**
051:             * This method depends on the home used to get it. AccountS is the base
052:             * interface of Account (common to Session/Entity)
053:             */
054:            public abstract AccountS getAccountS(int i);
055:
056:            // -----------------------------------------------------
057:            // ApplicationException
058:            // -----------------------------------------------------
059:
060:            /**
061:             * Test business method throwing an Application exception. It must be caught
062:             * by the client. The business method has NotSupported attribute. Spec 2.0
063:             * page 376 (table15)
064:             */
065:            public void testApplicationNoTx() throws Exception {
066:                AccountS acs = getAccountS(83);
067:                try {
068:                    acs.doAppException_3();
069:                    fail("No AppException");
070:                } catch (AppException e) {
071:                }
072:            }
073:
074:            /**
075:             * Test business method throwing an Application exception. It must be caught
076:             * by the client. The business method has NotSupported attribute. Test that
077:             * the transaction has not been marked rollback. Spec 2.0 page 376 (table15)
078:             */
079:            public void testApplicationNotTx() throws Exception {
080:                AccountS acs = getAccountS(83);
081:                utx.begin();
082:                try {
083:                    acs.doAppException_3();
084:                    fail("No AppException");
085:                } catch (AppException e) {
086:                    assertTrue(utx.getStatus() == Status.STATUS_ACTIVE);
087:                } finally {
088:                    utx.rollback();
089:                }
090:            }
091:
092:            /**
093:             * Test business method throwing an Application exception. It must be caught
094:             * by the client. A transaction is started in the container. (RequiresNew)
095:             * Bean does NOT call setRollbackOnly Test that the AppException has been
096:             * caught. Spec 2.0 page 376 (table15)
097:             */
098:            public void testApplicationContTx1() throws Exception {
099:                AccountS acs = getAccountS(82);
100:                try {
101:                    // the instance doesn't call setRollbackOnly
102:                    acs.doAppException_2(false);
103:                    fail("No AppException");
104:                } catch (AppException e) {
105:
106:                }
107:            }
108:
109:            /**
110:             * Test business method throwing an Application exception. It must be caught
111:             * by the client. A transaction is started in the container. (RequiresNew)
112:             * Bean calls setRollbackOnly Test that the AppException has been caught.
113:             * Spec 2.0 page 376 (table15)
114:             */
115:            public void testApplicationContTxRb1() throws Exception {
116:                AccountS acs = getAccountS(82);
117:                try {
118:                    // the instance calls setRollbackOnly
119:                    acs.doAppException_2(true);
120:                    fail("No AppException");
121:                } catch (AppException e) {
122:                }
123:            }
124:
125:            /**
126:             * Test business method throwing an Application exception. It must be caught
127:             * by the client. Methods runs in the context of the caller's transaction
128:             * The business method has Mandatory attribute. Test that the transaction
129:             * has not been marked rollback. Spec 2.0 page 375 (table15)
130:             */
131:            public void testApplicationCallerTx1() throws Exception {
132:                AccountS acs = getAccountS(81);
133:                utx.begin();
134:                try {
135:                    acs.doAppException_1();
136:                    fail("No AppException");
137:                } catch (AppException e) {
138:                    assertTrue(utx.getStatus() == Status.STATUS_ACTIVE);
139:                } finally {
140:                    utx.rollback();
141:                }
142:            }
143:
144:            // -----------------------------------------------------
145:            // UncheckedException
146:            // -----------------------------------------------------
147:
148:            /**
149:             * Test business method throwing an unchecked exception. Methods runs in the
150:             * context of the caller's transaction TransactionRolledbackException must
151:             * be caught by the client. The business method has Mandatory attribute. See
152:             * EJB2.0 specs page 375 (table 15)
153:             */
154:            public void testUncheckedCallerTx() throws Exception {
155:                AccountS acs = getAccountS(85);
156:                utx.begin();
157:                try {
158:                    acs.doUncheckedException_1();
159:                    fail("No RemoteException");
160:                } catch (RemoteException e) {
161:                    assertTrue((e.detail instanceof  TransactionRolledbackException)
162:                            || (e instanceof  TransactionRolledbackException));
163:                } finally {
164:                    utx.rollback();
165:                }
166:            }
167:
168:            /**
169:             * Test business method throwing an unchecked exception. Called inside a
170:             * containertransaction. The client must receive RemoteException See EJB2.0
171:             * specs page 376 (table 15)
172:             */
173:            public void testUncheckedContTx() throws Exception {
174:                AccountS acs = getAccountS(84);
175:                try {
176:                    acs.doUncheckedException_2(); // RequiresNew
177:                    fail("No RemoteException");
178:                } catch (RemoteException e) {
179:                }
180:
181:            }
182:
183:            /**
184:             * Test business method throwing an unchecked exception. Method runs with an
185:             * unspecified transaction context (NotSupported) The client must receive
186:             * RemoteException See EJB2.0 specs page 376 (table 15)
187:             */
188:            public void testUncheckedNoTx() throws Exception {
189:                AccountS acs = getAccountS(84);
190:                try {
191:                    acs.doUncheckedException_3(); // NotSupported
192:                    fail("No RemoteException");
193:                } catch (RemoteException e) {
194:                }
195:            }
196:
197:            // -----------------------------------------------------
198:            // EJBException
199:            // -----------------------------------------------------
200:
201:            /**
202:             * Test business method throwing an EJBException Called inside a
203:             * containertransaction (RequiresNew). The client must receive
204:             * RemoteException See EJB2.0 specs page 376 (table 15)
205:             */
206:            public void testEJBContTx() throws Exception {
207:                AccountS acs = getAccountS(84);
208:                try {
209:                    acs.doEJBException_1(); // RequiresNew
210:                    fail("No RemoteException");
211:                } catch (RemoteException e) {
212:                }
213:            }
214:
215:            // -----------------------------------------------------
216:            // RemoteException
217:            // -----------------------------------------------------
218:
219:            /**
220:             * Test business method throwing a RemoteException. Methods runs in the
221:             * context of the caller's transaction The bean method is TxMandatory The
222:             * client must receive TransactionRolledbackException See EJB2.0 specs page
223:             * 375 (table 15)
224:             */
225:            public void testRemoteCallerTx() throws Exception {
226:                AccountS acs = getAccountS(86);
227:                utx.begin();
228:                acs.ping(); // avoid another bug with RMI
229:                try {
230:                    acs.doRemoteException_1(); // TxMandatory
231:                    fail("No RemoteException");
232:                } catch (RemoteException e) {
233:                    assertTrue((e.detail instanceof  TransactionRolledbackException)
234:                            || (e instanceof  TransactionRolledbackException));
235:                } finally {
236:                    utx.rollback();
237:                }
238:            }
239:
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.