Source Code Cross Referenced for F_transactionTest.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » clients » j2eeca » 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.j2eeca 
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_transactionTest.java 4406 2004-03-19 11:57:20Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.clients.j2eeca;
027:
028:        import javax.naming.Context;
029:        import javax.naming.InitialContext;
030:        import javax.rmi.PortableRemoteObject;
031:        import javax.transaction.UserTransaction;
032:
033:        import junit.framework.Test;
034:        import junit.framework.TestSuite;
035:
036:        import org.objectweb.jonas.jtests.beans.j2eeca.transactedCA;
037:        import org.objectweb.jonas.jtests.beans.j2eeca.transactedCAHome;
038:        import org.objectweb.jonas.jtests.util.JTestCase;
039:
040:        /**
041:         * Tests Jonas Connector Architecture Local Transaction.
042:         * F_transactionTests tests Jonas CA Local Transaction
043:         */
044:
045:        public class F_transactionTest extends JTestCase {
046:
047:            private static UserTransaction utx = null;
048:
049:            static Context ctx = null;
050:
051:            // Lookup bean home
052:
053:            protected static String BEAN_HOME = "transactedCAHome";
054:            protected static transactedCAHome home = null;
055:            private static final String RAR_JNDI_NAME = "FictionalLoTransaction";
056:            final public int CLOSE_HANDLE = 0;
057:            final public int CLOSE_PHYSICAL = 1;
058:            public int CloseType = 0;
059:            static transactedCA bean = null;
060:            public String UseBeans = "j2eeca";
061:
062:            public F_transactionTest(String name) {
063:                super (name);
064:            }
065:
066:            protected void setUp() {
067:                super .setUp();
068:                try {
069:                    // get JNDI initial context
070:
071:                    if (ctx == null) {
072:                        ctx = new InitialContext();
073:                    }
074:
075:                    // We want to start transactions from client: get UserTransaction
076:
077:                    if (utx == null) {
078:                        utx = (UserTransaction) ctx
079:                                .lookup("javax.transaction.UserTransaction");
080:                    }
081:
082:                    if (home == null) {
083:                        useBeans(UseBeans, false);
084:                    }
085:                    getBean();
086:                    assertTrue(6 == 6);
087:
088:                } catch (Exception e) {
089:                    fail("Cannot lookup UserTransaction in setUp: " + e);
090:                }
091:            }
092:
093:            private void getBean() throws Exception {
094:                // Connecting to transactedCAHome thru JNDI
095:
096:                if (home == null) {
097:                    home = (transactedCAHome) PortableRemoteObject.narrow(ctx
098:                            .lookup(BEAN_HOME), transactedCAHome.class);
099:                    bean = home.create();
100:                }
101:            }
102:
103:            protected void tearDown() throws Exception {
104:                //bean.closeUp(CloseType);
105:            }
106:
107:            protected void startUp(String testName) {
108:                try {
109:                    bean.method1(RAR_JNDI_NAME, testName);
110:                } catch (Exception ee) {
111:                    ee.printStackTrace();
112:                    System.exit(2);
113:                }
114:            }
115:
116:            // test list ****************************************************
117:
118:            /**
119:            Test Local Transaction with component-managed demarcation.
120:            
121:            The application component uses a transaction demarcation API specific 
122:            to an EIS. The resource adapter needs to notify the application server of 
123:            the events (transaction begin, commit, and rollback) related to the local 
124:            transaction. An application server uses this part of the contract.
125:
126:             */
127:            public void testTransaction1() {
128:                CloseType = CLOSE_PHYSICAL;
129:                startUp("testTransaction1");
130:                try {
131:                    bean.beginLoTransaction();
132:                    assertTrue(6 == 6);
133:                    bean.closeUp(CloseType);
134:                    bean.commitLoTransaction();
135:                    assertTrue(6 == 6);
136:                } catch (Exception e) {
137:                    assertTrue(6 == 7);
138:                }
139:            }
140:
141:            public void testTransaction2() {
142:                CloseType = CLOSE_PHYSICAL;
143:                startUp("testTransaction2");
144:                try {
145:                    bean.closeUp(CloseType);
146:                    bean.commitLoTransaction();
147:                    assertTrue(6 == 7);
148:                } catch (Exception e) {
149:                    assertTrue(6 == 6); // should get here
150:                }
151:            }
152:
153:            public static Test suite() {
154:                return new TestSuite(F_transactionTest.class);
155:            }
156:
157:            public static void main(String args[]) {
158:
159:                String testtorun = null;
160:
161:                // Get args
162:
163:                for (int argn = 0; argn < args.length; argn++) {
164:
165:                    String s_arg = args[argn];
166:                    Integer i_arg;
167:
168:                    if (s_arg.equals("-n")) {
169:                        testtorun = args[++argn];
170:                    }
171:                }
172:
173:                if (testtorun == null) {
174:                    junit.textui.TestRunner.run(suite());
175:                } else {
176:                    junit.textui.TestRunner
177:                            .run(new F_transactionTest(testtorun));
178:                }
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.