Source Code Cross Referenced for F_connectorTest.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_connectorTest.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.connectorCA;
037:        import org.objectweb.jonas.jtests.beans.j2eeca.connectorCAHome;
038:        import org.objectweb.jonas.jtests.util.JTestCase;
039:
040:        /**
041:         * Tests JOnAS Connector Architecture setter methods
042:         */
043:
044:        public class F_connectorTest 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 = "connectorCAHome";
053:            static connectorCAHome home = null;
054:            static connectorCA bean = null;
055:            static connectorCA bean2 = null;
056:            private static final String RAR_JNDI_NAME = "FictionalEIS";
057:            final private int CLOSE_HANDLE = 0;
058:            final private int CLOSE_PHYSICAL = 1;
059:            int CloseType = 0;
060:
061:            public F_connectorTest(String name) {
062:                super (name);
063:            }
064:
065:            protected void setUp() {
066:                super .setUp();
067:
068:                // Get InitialContext
069:
070:                try {
071:
072:                    // get JNDI initial context
073:
074:                    if (ctx == null) {
075:                        ctx = new InitialContext();
076:                    }
077:
078:                    // We want to start transactions from client: get UserTransaction
079:
080:                    if (utx == null) {
081:                        utx = (UserTransaction) ctx
082:                                .lookup("javax.transaction.UserTransaction");
083:                    }
084:
085:                    if (home == null) {
086:                        useBeans("j2eeca", false); // does jonas admin -j connector.jar
087:                    }
088:
089:                    // Connecting to connectorCAHome thru JNDI
090:
091:                    if (home == null) {
092:                        home = (connectorCAHome) PortableRemoteObject.narrow(
093:                                ctx.lookup(BEAN_HOME), connectorCAHome.class);
094:                        bean = home.create();
095:                    }
096:
097:                    assertTrue(5 == 5);
098:
099:                } catch (Exception e) {
100:                    fail("Cannot lookup UserTransaction in setUp: " + e);
101:                }
102:            }
103:
104:            /**
105:             * 
106:             * Common tearDown method, used for every test.
107:             * Verify some Application Server tests by reviewing the log file.
108:             * 
109:             * The application server also calls ManagedConnection.destroy when it 
110:             * receives a connection error event notification that signals a fatal error 
111:             * on the physical connection. When method closeUp(int x) is called by
112:             * tearDown with x>0, a connection error event notification is sent to
113:             * the application server. Look for <code>ManagedConnection.destroy</code> entry.
114:             *
115:             */
116:            protected void tearDown() throws Exception {
117:                bean.closeUp(CloseType);
118:            }
119:
120:            protected void startUp(String testName) {
121:                try {
122:                    bean.method1(RAR_JNDI_NAME, testName);
123:                } catch (Exception ee) {
124:                    ee.printStackTrace();
125:                    System.exit(2);
126:                }
127:            }
128:
129:            // test list ****************************************************
130:            /**
131:             *
132:             * The application server calls setter methods on the ManagedConnectionFactory 
133:             * instance to set various configuration properties on this instance.     
134:             *
135:             */
136:            public void testSetterMethods() throws Exception {
137:                // the jonas-ra.xml file contains these properties. The Application Server
138:                // calls setter methods on the ManagedConnectionFactory instance
139:                // ServerName = 111.222.333.444     PortNumber= ak41
140:                // protocol   = LINE                DUserName = defaultUserName
141:                // DPassword  = defaultPassword
142:                CloseType = CLOSE_PHYSICAL;
143:                startUp("testSetterMethods");
144:                String cp = bean.getServerName();
145:                assertEquals("111.222.333.444", cp);
146:                cp = bean.getProtocolProperty();
147:                assertEquals("LINE", cp);
148:            }
149:
150:            /**
151:             * An application server is required to provide an implementation of the
152:             * javax.resource.spi.ConnectionManager interface.
153:             *
154:             */
155:            public void testCreatedCMInstance() throws Exception {
156:                CloseType = CLOSE_PHYSICAL;
157:                startUp("testCreatedCMInstance");
158:                assertTrue(bean.getCMInstance());
159:            }
160:
161:            /**
162:             *  Verify connection is useful by accessing ManagedConnectionMetaData instance
163:             */
164:            public void testConnectionProduct() throws Exception {
165:                CloseType = CLOSE_PHYSICAL;
166:                startUp("testConnectionProduct");
167:                String p = bean.getConnectionProduct();
168:                assertEquals("Fictional EIS", p);
169:            }
170:
171:            /**
172:             *
173:             * An application server is required to implement the javax.resource.spi.-
174:             * ConnectionEventListener interface and to register ConnectionEventListener 
175:             * with resource adapter to get connection-related event notifications.
176:             *
177:             * Count (at least) one listener
178:             */
179:            public void testRegisteredListener() throws Exception {
180:                CloseType = CLOSE_PHYSICAL;
181:                startUp("testRegisteredListener");
182:                int b = bean.cntListeners();
183:                assertTrue(b > 0);
184:            }
185:
186:            /**
187:             *  Verify connection was made
188:             */
189:            public void testConnectionBasics() throws Exception {
190:                CloseType = CLOSE_PHYSICAL;
191:                startUp("testConnectionBasics");
192:                assertTrue(bean.isConnectionSpec());
193:                assertTrue(bean.isConnection());
194:                assertTrue(bean.isInteraction());
195:            }
196:
197:            /**
198:             * Basic error logging and tracing.
199:             *
200:             * An application server is required to use the following interfaces (supported 
201:             * by the resource adapter) to provide basic error logging and tracing for its 
202:             * configured set of resource adapters.
203:             * <pre>
204:             *   • ManagedConnectionFactory.set/getLogWriter
205:             *   • ManagedConnection.set/getLogWriter
206:             * </pre>
207:             *
208:             *  This test includes in <code>jonas-ra.xml</code> file the log-enabled 
209:             *  info as shown below.  
210:             *  The JtestResourceAdapter.rar
211:             *  is used. This test looks up "FictionalEIS" in the JNDI name space.
212:             *  The F_connectorTest is 
213:             *  deployed with log-enabled set to true.
214:             * <p>
215:             * <pre>
216:             *     &lt;log-enabled&gt;true&lt;/log-enabled&gt;
217:             *     &lt;log-topic&gt;org.objectweb.jtests.resourceAdapter&lt;/log-topic&gt;
218:             *    </pre>
219:             */
220:            public void testPrintWriter() throws Exception {
221:                CloseType = CLOSE_PHYSICAL;
222:                int isNull = 0;
223:                int isNotNull = 1;
224:                int isError = 2;
225:                startUp("testPrintWriter");
226:                int x = bean.getMCF_Pwriter();
227:                assertEquals(isNotNull, x);
228:                x = bean.getMC_Pwriter();
229:                assertEquals(isNotNull, x);
230:            }
231:
232:            // end test list ****************************************************
233:
234:            public static Test suite() {
235:                return new TestSuite(F_connectorTest.class);
236:            }
237:
238:            public static void main(String args[]) {
239:
240:                String testtorun = null;
241:
242:                // Get args
243:
244:                for (int argn = 0; argn < args.length; argn++) {
245:
246:                    String s_arg = args[argn];
247:                    Integer i_arg;
248:
249:                    if (s_arg.equals("-n")) {
250:                        testtorun = args[++argn];
251:                    }
252:                }
253:
254:                if (testtorun == null) {
255:                    junit.textui.TestRunner.run(suite());
256:                } else {
257:                    junit.textui.TestRunner.run(new F_connectorTest(testtorun));
258:                }
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.