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