Source Code Cross Referenced for F_runtimeTest.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_runtimeTest.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.runtimeCA;
037:        import org.objectweb.jonas.jtests.beans.j2eeca.runtimeCAHome;
038:        import org.objectweb.jonas.jtests.util.JTestCase;
039:
040:        /**
041:         * Tests Jonas Connector Architecture Basic error logging and tracing and component-managed sign-on.
042:         */
043:
044:        public class F_runtimeTest extends JTestCase {
045:
046:            private static UserTransaction utx = null;
047:
048:            static Context ctx = null;
049:
050:            // Lookup bean home
051:
052:            protected static String BEAN_HOME = "runtimeCAHome";
053:            protected static runtimeCAHome home = null;
054:            private static final String RAR_JNDI_NAME = "FictionalNolog";
055:            static runtimeCA bean = null;
056:            final private int CLOSE_HANDLE = 0;
057:            final private int CLOSE_PHYSICAL = 1;
058:            int CloseType = 0;
059:
060:            public F_runtimeTest(String name) {
061:                super (name);
062:            }
063:
064:            protected void setUp() {
065:                super .setUp();
066:
067:                // Get InitialContext
068:
069:                try {
070:
071:                    // get JNDI initial context
072:
073:                    if (ctx == null) {
074:                        ctx = new InitialContext();
075:                    }
076:
077:                    // We want to start transactions from client: get UserTransaction
078:
079:                    if (utx == null) {
080:                        utx = (UserTransaction) ctx
081:                                .lookup("javax.transaction.UserTransaction");
082:                    }
083:
084:                    if (home == null) {
085:                        useBeans("j2eeca", false);
086:                    }
087:
088:                    // Connecting to runtimeHome thru JNDI
089:
090:                    if (home == null) {
091:                        home = (runtimeCAHome) PortableRemoteObject.narrow(ctx
092:                                .lookup(BEAN_HOME), runtimeCAHome.class);
093:                        bean = home.create();
094:                    }
095:
096:                    assertTrue(5 == 5);
097:
098:                } catch (Exception e) {
099:                    fail("Cannot lookup UserTransaction in setUp: " + e);
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:             * Basic error logging and tracing negative test.
119:             *
120:             * An application server is required to use the following interfaces (supported 
121:             * by the resource adapter) to provide basic error logging and tracing for its 
122:             * configured set of resource adapters.
123:             * <pre>
124:             *   • ManagedConnectionFactory.set/getLogWriter
125:             *   • ManagedConnection.set/getLogWriter
126:             * </pre>
127:             *
128:             *  This test 
129:             *  includes in <code>jonas-ra.xml</code> file the log-enabled info as 
130:             *  shown below.  The Nolog.rar
131:             *  is used. This test looks up "FictionalNolog" in the JNDI name space. The F_runtimeTest is 
132:             *  deployed with log-enabled set to false.
133:             * <p><pre>
134:             *    &lt;log-enabled>false&lt;/log-enabled&gt;
135:             *    &lt;log-topic&gt;&lt;/log-topic&gt;
136:             *   </pre>
137:             */
138:            public void testPrintWriterNull() throws Exception {
139:                CloseType = CLOSE_PHYSICAL;
140:                int isNull = 0;
141:                int isNotNull = 1;
142:                int isError = 2;
143:                startUp("testPrintWriterNull");
144:                int x = bean.getMCF_Pwriter();
145:                assertEquals(isNull, x);
146:                x = bean.getMC_Pwriter();
147:                assertEquals(isNull, x);
148:            }
149:
150:            /**
151:             *  Component managed sign-on.
152:             *
153:             *  The application server relies on the resource adapter to manage EIS 
154:             *  sign-on. Username and password are passed during connection.
155:             *  When this class is deployed, the <code>runtime.xml</code> file contains:
156:             * <p>
157:             *  <code>&lt;res-auth&gt;Application&lt;/res-auth&gt;</code>
158:             */
159:            public void testSecurityContextApplication() throws Exception {
160:                CloseType = CLOSE_PHYSICAL;
161:                bean.setResAuth("Application");
162:                startUp("testSecurityContextApplication");
163:                //bean.setMatchNull(true);
164:                String pw = bean.getSecurityPassword();
165:                String u = bean.getSecurityUserName();
166:                String realResAuth = bean.getResAuth();
167:                if (realResAuth.equals("Application")) {
168:                    assertEquals("__Jtest_Pass_word__", pw);
169:                    assertEquals("Fictional_User_Name", u);
170:                } else {
171:                    assertFalse(pw.equals("__Jtest_Pass_word__"));
172:                }
173:
174:            }
175:
176:            public static Test suite() {
177:                return new TestSuite(F_runtimeTest.class);
178:            }
179:
180:            public static void main(String args[]) {
181:
182:                String testtorun = null;
183:
184:                // Get args
185:
186:                for (int argn = 0; argn < args.length; argn++) {
187:
188:                    String s_arg = args[argn];
189:                    Integer i_arg;
190:
191:                    if (s_arg.equals("-n")) {
192:                        testtorun = args[++argn];
193:                    }
194:                }
195:
196:                if (testtorun == null) {
197:                    junit.textui.TestRunner.run(suite());
198:                } else {
199:                    junit.textui.TestRunner.run(new F_runtimeTest(testtorun));
200:                }
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.