Source Code Cross Referenced for F_TxAttributeEB.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: F_TxAttributeEB.java 3313 2003-09-17 08:56:40Z durieuxp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.clients.transaction;
027:
028:        import javax.naming.NamingException;
029:        import javax.rmi.PortableRemoteObject;
030:        import junit.framework.Test;
031:        import junit.framework.TestSuite;
032:        import org.objectweb.jonas.jtests.beans.transacted.Simple;
033:        import org.objectweb.jonas.jtests.beans.transacted.SimpleEHome;
034:
035:        /**
036:         * TxAttribute tests on on entity bean
037:         */
038:        public class F_TxAttributeEB extends A_TxAttributeEntity {
039:
040:            private static String BEAN_HOME = "transactedSimpleEBHome";
041:            protected static SimpleEHome home = null;
042:
043:            public F_TxAttributeEB(String name) {
044:                super (name);
045:            }
046:
047:            // --------------------------------------------------------------------
048:            // tests on finder methods
049:            // These tests are specific to BMP because there is no ejb<Find> methods
050:            // in CMP.
051:            // ---------------------------------------------------------------------
052:
053:            /**
054:             * Test NotSupported transactional attributes on finder method
055:             * the finder method is called outside TX
056:             */
057:            public void testFinderNotSupported() throws Exception {
058:
059:                getHome().finder_notsupported();
060:            }
061:
062:            /**
063:             * Test NotSupported  transactional attributes on finder method
064:             * the finder method is called inside TX
065:             */
066:            public void testFinderNotSupportedTx() throws Exception {
067:
068:                utx.begin();
069:                try {
070:                    getHome().finder_notsupported();
071:                } finally {
072:                    utx.rollback();
073:                }
074:            }
075:
076:            /**
077:             * Test required transactional attributes on finder method
078:             * the finder method is called outside TX
079:             */
080:            public void testFinderRequired() throws Exception {
081:
082:                getHome().finder_required();
083:            }
084:
085:            /**
086:             * Test Required  transactional attributes on finder method
087:             * the finder method is called inside TX
088:             */
089:            public void testFinderRequiredTx() throws Exception {
090:
091:                utx.begin();
092:                try {
093:                    getHome().finder_required();
094:                } finally {
095:                    utx.rollback();
096:                }
097:            }
098:
099:            /**
100:             * Test supports  transactional attributes on finder method
101:             * the finder method is called outside TX
102:             * the finder method is called with false that mean that the method must not be associated 
103:             *                to a transaction
104:             */
105:            public void testFinderSupports() throws Exception {
106:
107:                getHome().finder_supports(false);
108:            }
109:
110:            /**
111:             * Test supports  transactional attributes on finder method
112:             * the finder method is called inside TX
113:             * the finder method is called with true  that mean that the method must be associated 
114:             *                to a transaction
115:             */
116:            public void testFinderSupportsTx() throws Exception {
117:                utx.begin();
118:                try {
119:                    getHome().finder_supports(true);
120:                } finally {
121:                    utx.rollback();
122:                }
123:            }
124:
125:            /**
126:             * Test requiresNew  transactional attributes on finder method
127:             * the finder method is called outside TX
128:             */
129:            public void testFinderRequiresNew() throws Exception {
130:
131:                getHome().finder_requiresnew();
132:            }
133:
134:            /**
135:             * Test RequiresNew  transactional attributes on finder method
136:             * the finder method is called inside TX
137:             */
138:            public void testFinderRequiresNewTx() throws Exception {
139:
140:                utx.begin();
141:                try {
142:                    getHome().finder_requiresnew();
143:                } finally {
144:                    utx.rollback();
145:                }
146:            }
147:
148:            /**
149:             * Test Mandatory  transactional attributes on finder method
150:             * the finder method is called outside TX
151:             * TransactionRequiredException must be received
152:             */
153:            public void testFinderMandatory() throws Exception {
154:                try {
155:                    getHome().finder_mandatory();
156:                    fail("mandatory: should raise exception");
157:                } catch (javax.transaction.TransactionRequiredException e) {
158:                } catch (java.rmi.RemoteException e) {
159:                    assertTrue(e.detail instanceof  javax.transaction.TransactionRequiredException);
160:                }
161:            }
162:
163:            /**
164:             * Test Mandatory  transactional attributes on finder method
165:             * the finder method is called inside TX
166:             */
167:            public void testFinderMandatoryTx() throws Exception {
168:
169:                utx.begin();
170:                try {
171:                    getHome().finder_mandatory();
172:                } finally {
173:                    utx.rollback();
174:                }
175:            }
176:
177:            /**
178:             * Test Never  transactional attributes on finder method
179:             * the finder method is called outside TX
180:             */
181:            public void testFinderNever() throws Exception {
182:
183:                getHome().finder_never();
184:            }
185:
186:            /**
187:             * Test Never  transactional attributes on finder method
188:             * the finder method is called inside TX
189:             */
190:            public void testFinderNeverTx() throws Exception {
191:                utx.begin();
192:                try {
193:                    getHome().finder_never();
194:                    fail("never: should raise exception");
195:                } catch (java.rmi.RemoteException e) {
196:                } finally {
197:                    utx.rollback();
198:                }
199:            }
200:
201:            // -----------------------------------------------------------------
202:            // Methods for Suite handling
203:            // -----------------------------------------------------------------
204:
205:            protected SimpleEHome getHome() {
206:                if (home == null) {
207:                    try {
208:                        home = (SimpleEHome) PortableRemoteObject.narrow(ictx
209:                                .lookup(BEAN_HOME), SimpleEHome.class);
210:                    } catch (NamingException e) {
211:                        fail("Cannot get bean home");
212:                    }
213:                }
214:                return home;
215:            }
216:
217:            /**
218:             * Create a bean and return it.
219:             */
220:            public Simple getSimple(int i) throws Exception {
221:                return getHome().create(i);
222:            }
223:
224:            /**
225:             * This suite is all BMP test cases
226:             */
227:            public static Test suite() {
228:                return new TestSuite(F_TxAttributeEB.class);
229:            }
230:
231:            public static void main(String args[]) {
232:                String testtorun = null;
233:                // Get args
234:                for (int argn = 0; argn < args.length; argn++) {
235:                    String sarg = args[argn];
236:                    if (sarg.equals("-n")) {
237:                        testtorun = args[++argn];
238:                    }
239:                }
240:                if (testtorun == null) {
241:                    junit.textui.TestRunner.run(suite());
242:                } else {
243:                    junit.textui.TestRunner.run(new F_TxAttributeEB(testtorun));
244:                }
245:            }
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.