KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > tests > jdbc4 > ClosedObjectTest


1 /*
2  * Derby - org.apache.derbyTesting.functionTests.tests.jdbc4.ClosedObjectTest
3  *
4    Licensed to the Apache Software Foundation (ASF) under one or more
5    contributor license agreements. See the NOTICE file distributed with
6    this work for additional information regarding copyright ownership.
7    The ASF licenses this file to You under the Apache License, Version 2.0
8    (the "License"); you may not use this file except in compliance with
9    the License. You may obtain a copy of the License at
10
11       http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18  *
19  */

20
21 package org.apache.derbyTesting.functionTests.tests.jdbc4;
22
23 import java.lang.reflect.InvocationTargetException JavaDoc;
24 import java.lang.reflect.Method JavaDoc;
25 import java.sql.CallableStatement JavaDoc;
26 import java.sql.SQLClientInfoException JavaDoc;
27 import java.sql.Connection JavaDoc;
28 import java.sql.PreparedStatement JavaDoc;
29 import java.sql.ResultSet JavaDoc;
30 import java.sql.SQLException JavaDoc;
31 import java.sql.SQLFeatureNotSupportedException JavaDoc;
32 import java.sql.Statement JavaDoc;
33 import java.util.Arrays JavaDoc;
34 import java.util.Properties JavaDoc;
35 import javax.sql.ConnectionPoolDataSource JavaDoc;
36 import javax.sql.DataSource JavaDoc;
37 import javax.sql.PooledConnection JavaDoc;
38 import javax.sql.XAConnection JavaDoc;
39 import javax.sql.XADataSource JavaDoc;
40 import junit.extensions.TestSetup;
41 import junit.framework.Test;
42 import junit.framework.TestSuite;
43 import org.apache.derbyTesting.functionTests.util.TestDataSourceFactory;
44 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
45 import org.apache.derbyTesting.junit.TestConfiguration;
46
47 /**
48  * Test that all methods on <code>ResultSet</code>,
49  * <code>Statement</code>, <code>PreparedStatement</code>,
50  * <code>CallableStatement</code> and <code>Connection</code> objects
51  * throw the appropriate exceptions when the objects are closed.
52  */

53 public class ClosedObjectTest extends BaseJDBCTestCase {
54     /** The method to test. */
55     private final Method JavaDoc method_;
56     /** Test decorator which provides a closed object to invoke a
57      * method on. */

58     private final ObjectDecorator decorator_;
59     /** Name of the test. */
60     private String JavaDoc name_;
61
62     /**
63      * Creates a new <code>ClosedObjectTest</code> instance.
64      *
65      * @param method the method to test
66      * @param decorator a decorator which provides a closed object
67      */

68     public ClosedObjectTest(Method JavaDoc method, ObjectDecorator decorator) {
69         super("testClosedObjects");
70         method_ = method;
71         decorator_ = decorator;
72         // setting name temporarily, we don't know the real class name yet
73
name_ = method.getDeclaringClass().getName() + "." + method.getName();
74     }
75
76     /**
77      * Gets the name of the test.
78      *
79      * @return name of the test
80      */

81     public String JavaDoc getName() {
82         return name_;
83     }
84
85     /**
86      * Runs a test case. A method is called on a closed object, and it
87      * is checked that the appropriate exception is thrown.
88      *
89      * @exception Throwable if an error occurs
90      */

91     public void testClosedObjects() throws Throwable JavaDoc {
92         try {
93             Object JavaDoc object = decorator_.getClosedObject();
94
95             // update name of test with real class name
96
name_ = object.getClass() + "." + method_.getName();
97
98             method_.invoke(object,
99                            getNullArguments(method_.getParameterTypes()));
100             assertFalse("No exception was thrown",
101                         decorator_.expectsException(method_));
102         } catch (InvocationTargetException JavaDoc ite) {
103             try {
104                 throw ite.getCause();
105             } catch (SQLFeatureNotSupportedException JavaDoc fnse) {
106                 // if we don't support the method, it is OK that we
107
// throw this exception
108
} catch (SQLException JavaDoc sqle) {
109                 decorator_.checkException(method_, sqle);
110             }
111         }
112     }
113
114     /**
115      * Creates the test suite and fills it with tests using
116      * <code>DataSource</code>, <code>ConnectionPoolDataSource</code>
117      * and <code>XADataSource</code> to obtain objects.
118      *
119      * @return a <code>Test</code> value
120      * @exception Exception if an error occurs while building the test suite
121      */

122     public static Test suite() {
123         TestSuite topSuite = new TestSuite();
124
125         TestSuite dsSuite = new TestSuite();
126         DataSourceDecorator dsDecorator = new DataSourceDecorator(dsSuite);
127         topSuite.addTest(dsDecorator);
128         fillDataSourceSuite(dsSuite, dsDecorator);
129
130         TestSuite poolSuite = new TestSuite();
131         PoolDataSourceDecorator poolDecorator =
132             new PoolDataSourceDecorator(poolSuite);
133         topSuite.addTest(poolDecorator);
134         fillDataSourceSuite(poolSuite, poolDecorator);
135
136         TestSuite xaSuite = new TestSuite();
137         XADataSourceDecorator xaDecorator = new XADataSourceDecorator(xaSuite);
138         topSuite.addTest(xaDecorator);
139         fillDataSourceSuite(xaSuite, xaDecorator);
140
141         return topSuite;
142     }
143
144     /**
145      * Fills a test suite which is contained in a
146      * <code>DataSourceDecorator</code> with tests for
147      * <code>ResultSet</code>, <code>Statement</code>,
148      * <code>PreparedStatement</code>, <code>CallableStatement</code>
149      * and <code>Connection</code>.
150      *
151      * @param suite the test suite to fill
152      * @param dsDecorator the decorator for the test suite
153      */

154     private static void fillDataSourceSuite(TestSuite suite,
155                                             DataSourceDecorator dsDecorator)
156     {
157         TestSuite rsSuite = new TestSuite();
158         ResultSetObjectDecorator rsDecorator =
159             new ResultSetObjectDecorator(rsSuite, dsDecorator);
160         suite.addTest(rsDecorator);
161         fillObjectSuite(rsSuite, rsDecorator, ResultSet JavaDoc.class);
162
163         TestSuite stmtSuite = new TestSuite();
164         StatementObjectDecorator stmtDecorator =
165             new StatementObjectDecorator(stmtSuite, dsDecorator);
166         suite.addTest(stmtDecorator);
167         fillObjectSuite(stmtSuite, stmtDecorator, Statement JavaDoc.class);
168
169         TestSuite psSuite = new TestSuite();
170         PreparedStatementObjectDecorator psDecorator =
171             new PreparedStatementObjectDecorator(psSuite, dsDecorator);
172         suite.addTest(psDecorator);
173         fillObjectSuite(psSuite, psDecorator, PreparedStatement JavaDoc.class);
174
175         TestSuite csSuite = new TestSuite();
176         CallableStatementObjectDecorator csDecorator =
177             new CallableStatementObjectDecorator(csSuite, dsDecorator);
178         suite.addTest(csDecorator);
179         fillObjectSuite(csSuite, csDecorator, CallableStatement JavaDoc.class);
180
181         TestSuite connSuite = new TestSuite();
182         ConnectionObjectDecorator connDecorator =
183             new ConnectionObjectDecorator(connSuite, dsDecorator);
184         suite.addTest(connDecorator);
185         fillObjectSuite(connSuite, connDecorator, Connection JavaDoc.class);
186     }
187
188     /**
189      * Fills a suite with tests for all the methods of an interface.
190      *
191      * @param suite the suite to fill
192      * @param decorator a decorator for the test (used for obtaining a
193      * closed object to test the method on)
194      * @param iface the interface which contains the methods to test
195      */

196     private static void fillObjectSuite(TestSuite suite,
197                                         ObjectDecorator decorator,
198                                         Class JavaDoc iface)
199     {
200         for (Method JavaDoc m : iface.getMethods()) {
201             ClosedObjectTest cot = new ClosedObjectTest(m, decorator);
202             suite.addTest(cot);
203         }
204     }
205
206     /**
207      * Takes an array of classes and returns an array of objects with
208      * null values compatible with the classes. Helper method for
209      * converting a parameter list to an argument list.
210      *
211      * @param params a <code>Class[]</code> value
212      * @return an <code>Object[]</code> value
213      */

214     private static Object JavaDoc[] getNullArguments(Class JavaDoc[] params) {
215         Object JavaDoc[] args = new Object JavaDoc[params.length];
216         for (int i = 0; i < params.length; i++) {
217             args[i] = getNullValueForType(params[i]);
218         }
219         return args;
220     }
221
222     /**
223      * Returns a null value compatible with the class. For instance,
224      * return <code>Boolean.FALSE</code> for primitive booleans, 0 for
225      * primitive integers and <code>null</code> for non-primitive
226      * types.
227      *
228      * @param type a <code>Class</code> value
229      * @return a null value
230      */

231     private static Object JavaDoc getNullValueForType(Class JavaDoc type) {
232         if (!type.isPrimitive()) {
233             return null;
234         }
235         if (type == Boolean.TYPE) {
236             return Boolean.FALSE;
237         }
238         if (type == Character.TYPE) {
239             return new Character JavaDoc((char) 0);
240         }
241         if (type == Byte.TYPE) {
242             return new Byte JavaDoc((byte) 0);
243         }
244         if (type == Short.TYPE) {
245             return new Short JavaDoc((short) 0);
246         }
247         if (type == Integer.TYPE) {
248             return new Integer JavaDoc(0);
249         }
250         if (type == Long.TYPE) {
251             return new Long JavaDoc(0L);
252         }
253         if (type == Float.TYPE) {
254             return new Float JavaDoc(0f);
255         }
256         if (type == Double.TYPE) {
257             return new Double JavaDoc(0d);
258         }
259         fail("Don't know how to handle type " + type);
260         return null; // unreachable statement
261
}
262
263     /**
264      * Abstract decorator class with functionality for obtaining a
265      * closed object.
266      */

267     private static abstract class ObjectDecorator extends TestSetup {
268         /** Decorator which provides a connection. */
269         private final DataSourceDecorator decorator_;
270         /** The closed object. Must be set by a sub-class. */
271         protected Object JavaDoc object_;
272
273         /**
274          * Creates a new <code>ObjectDecorator</code> instance.
275          *
276          * @param test a test or suite to decorate
277          * @param decorator a decorator which provides a connection
278          */

279         public ObjectDecorator(Test test, DataSourceDecorator decorator) {
280             super(test);
281             decorator_ = decorator;
282         }
283
284         /**
285          * Returns the closed object.
286          *
287          * @return a closed object
288          */

289         public Object JavaDoc getClosedObject() {
290             return object_;
291         }
292
293         /**
294          * Checks whether a method expects an exception to be thrown
295          * when the object is closed. Currently, only
296          * <code>close()</code>, <code>isClosed()</code> and
297          * <code>isValid()</code> don't expect exceptions.
298          *
299          * @param method a method
300          * @return <code>true</code> if an exception is expected
301          */

302         public boolean expectsException(Method JavaDoc method) {
303             final String JavaDoc[] exceptionLessMethods = {
304                 "close",
305                 "isClosed",
306                 "isValid",
307             };
308             for (String JavaDoc name : exceptionLessMethods) {
309                 if (name.equals(method.getName())) return false;
310             }
311             return true;
312         }
313
314         /**
315          * Checks whether an exception is of the expected type for
316          * that method.
317          *
318          * @param method a method
319          * @param sqle an exception
320          * @exception SQLException if the exception was not expected
321          */

322         public final void checkException(Method JavaDoc method, SQLException JavaDoc sqle)
323             throws SQLException JavaDoc
324         {
325             if (!expectsException(method)) {
326                 throw sqle;
327             }
328             checkSQLState(method, sqle);
329         }
330
331         /**
332          * Checks whether the SQL state is as expected.
333          *
334          * @param method a <code>Method</code> value
335          * @param sqle a <code>SQLException</code> value
336          * @exception SQLException if an error occurs
337          */

338         protected abstract void checkSQLState(Method JavaDoc method,
339                                               SQLException JavaDoc sqle)
340             throws SQLException JavaDoc;
341
342         /**
343          * Helper method for creating a connection.
344          *
345          * @return a connection
346          * @exception SQLException if an error occurs
347          */

348         protected Connection JavaDoc createConnection() throws SQLException JavaDoc {
349             return decorator_.newConnection();
350         }
351
352         /**
353          * Helper method for creating a statement.
354          *
355          * @return a statement
356          * @exception SQLException if an error occurs
357          */

358         protected Statement JavaDoc createStatement() throws SQLException JavaDoc {
359             return decorator_.getConnection().createStatement();
360         }
361
362         /**
363          * Helper method for creating a prepared statement.
364          *
365          * @param sql statement text
366          * @return a prepared statement
367          * @exception SQLException if an error occurs
368          */

369         protected PreparedStatement JavaDoc prepareStatement(String JavaDoc sql)
370             throws SQLException JavaDoc
371         {
372             return decorator_.getConnection().prepareStatement(sql);
373         }
374
375         /**
376          * Helper method for creating a callable statement.
377          *
378          * @param call statement text
379          * @return a callable statement
380          * @exception SQLException if an error occurs
381          */

382         protected CallableStatement JavaDoc prepareCall(String JavaDoc call)
383             throws SQLException JavaDoc
384         {
385             return decorator_.getConnection().prepareCall(call);
386         }
387     }
388
389     /**
390      * Decorator class for testing methods on a closed result set.
391      */

392     private static class ResultSetObjectDecorator extends ObjectDecorator {
393         /** Statement used for creating the result set to test. */
394         private Statement JavaDoc stmt_;
395
396         /**
397          * Creates a new <code>ResultSetObjectDecorator</code> instance.
398          *
399          * @param test the test to decorate
400          * @param decorator decorator used for obtaining a statement
401          */

402         public ResultSetObjectDecorator(Test test,
403                                         DataSourceDecorator decorator) {
404             super(test, decorator);
405         }
406
407         /**
408          * Sets up the test. Creates a result set and closes it.
409          *
410          * @exception SQLException if an error occurs
411          */

412         public void setUp() throws SQLException JavaDoc {
413             stmt_ = createStatement();
414             ResultSet JavaDoc rs = stmt_.executeQuery("VALUES(1)");
415             rs.close();
416             object_ = rs;
417         }
418
419         /**
420          * Tears down the test. Closes open resources.
421          *
422          * @exception SQLException if an error occurs
423          */

424         public void tearDown() throws SQLException JavaDoc {
425             stmt_.close();
426         }
427
428         /**
429          * Checks whether the exception has the expected SQL state
430          * (XCL16 - result set is closed).
431          *
432          * @param method a <code>Method</code> value
433          * @param sqle a <code>SQLException</code> value
434          * @exception SQLException if an error occurs
435          */

436         protected void checkSQLState(Method JavaDoc method, SQLException JavaDoc sqle)
437             throws SQLException JavaDoc
438         {
439             if (sqle.getSQLState().equals("XCL16")) {
440                 // everything is OK, do nothing
441
} else {
442                 // unexpected exception
443
throw sqle;
444             }
445         }
446     }
447
448     /**
449      * Decorator class for testing methods on a closed statement.
450      */

451     private static class StatementObjectDecorator extends ObjectDecorator {
452         /**
453          * Creates a new <code>StatementObjectDecorator</code> instance.
454          *
455          * @param test the test to decorate
456          * @param decorator decorator which provides a statement
457          */

458         public StatementObjectDecorator(Test test,
459                                         DataSourceDecorator decorator) {
460             super(test, decorator);
461         }
462
463         /**
464          * Sets up the test. Creates a statement and closes it.
465          *
466          * @exception SQLException if an error occurs
467          */

468         public void setUp() throws SQLException JavaDoc {
469             Statement JavaDoc stmt = createStatement();
470             stmt.close();
471             object_ = stmt;
472         }
473
474         /**
475          * Checks whether the exception has the expected SQL state
476          * (statement is closed). When using embedded, XJ012 is
477          * expected. When using the client driver, XCL31 is expected.
478          *
479          * @param method a <code>Method</code> value
480          * @param sqle a <code>SQLException</code> value
481          * @exception SQLException if an error occurs
482          */

483         protected void checkSQLState(Method JavaDoc method, SQLException JavaDoc sqle)
484             throws SQLException JavaDoc
485         {
486             String JavaDoc sqlState = sqle.getSQLState();
487             if (sqlState.equals("XJ012")) {
488                 // expected, do nothing
489
} else {
490                 // unexpected exception
491
throw sqle;
492             }
493         }
494     }
495
496     /**
497      * Decorator class for testing methods on a closed prepared statement.
498      */

499     private static class PreparedStatementObjectDecorator
500         extends StatementObjectDecorator
501     {
502         /**
503          * Creates a new <code>PreparedStatementObjectDecorator</code>
504          * instance.
505          *
506          * @param test the test to decorate
507          * @param decorator decorator which provides a prepared statement
508          */

509         public PreparedStatementObjectDecorator(Test test,
510                                                 DataSourceDecorator decorator)
511         {
512             super(test, decorator);
513         }
514
515         /**
516          * Sets up the test. Prepares a statement and closes it.
517          *
518          * @exception SQLException if an error occurs
519          */

520         public void setUp() throws SQLException JavaDoc {
521             PreparedStatement JavaDoc ps = prepareStatement("VALUES(1)");
522             ps.close();
523             object_ = ps;
524         }
525
526         /**
527          * Checks whether the exception has the expected SQL state
528          * (statement is closed), or XJ016 indicating it is a
529          * Statement method not meant to be invoked on a
530          * PreparedStatement.
531          *
532          * @param method a <code>Method</code> value
533          * @param sqle a <code>SQLException</code> value
534          * @exception SQLException if an error occurs
535          */

536         protected void checkSQLState(Method JavaDoc method, SQLException JavaDoc sqle)
537             throws SQLException JavaDoc
538         {
539             if (method.getDeclaringClass() == Statement JavaDoc.class &&
540                 sqle.getSQLState().equals("XJ016")) {
541                 // XJ016 is "blah,blah not allowed on a prepared
542
// statement", so it's OK to get this one
543
} else {
544                 super.checkSQLState(method, sqle);
545             }
546
547         }
548     }
549
550     /**
551      * Decorator class for testing methods on a closed callable statement.
552      */

553     private static class CallableStatementObjectDecorator
554         extends PreparedStatementObjectDecorator
555     {
556         /**
557          * Creates a new <code>CallableStatementObjectDecorator</code>
558          * instance.
559          *
560          * @param test the test to decorate
561          * @param decorator decorator which provides a callable statement
562          */

563         public CallableStatementObjectDecorator(Test test,
564                                                 DataSourceDecorator decorator)
565         {
566             super(test, decorator);
567         }
568
569         /**
570          * Sets up the test. Prepares a call and closes the statement.
571          *
572          * @exception SQLException if an error occurs
573          */

574         public void setUp() throws SQLException JavaDoc {
575             CallableStatement JavaDoc cs =
576                 prepareCall("CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1)");
577             cs.close();
578             object_ = cs;
579         }
580     }
581
582     /**
583      * Decorator class for testing methods on a closed connection.
584      */

585     private static class ConnectionObjectDecorator extends ObjectDecorator {
586         /**
587          * Creates a new <code>ConnectionObjectDecorator</code> instance.
588          *
589          * @param test the test to decorate
590          * @param decorator decorator which provides a connection
591          */

592         public ConnectionObjectDecorator(Test test,
593                                          DataSourceDecorator decorator) {
594             super(test, decorator);
595         }
596
597         /**
598          * Sets up the test. Creates a connection and closes it.
599          *
600          * @exception SQLException if an error occurs
601          */

602         public void setUp() throws SQLException JavaDoc {
603             Connection JavaDoc conn = createConnection();
604             conn.rollback(); // cannot close active transactions
605
conn.close();
606             object_ = conn;
607         }
608
609         /**
610          * Checks that the exception has an expected SQL state (08003
611          * - no current connection). Also accept
612          * <code>SQLClientInfoException</code>s from
613          * <code>setClientInfo()</code>.
614          *
615          * @param method a <code>Method</code> value
616          * @param sqle a <code>SQLException</code> value
617          * @exception SQLException if an error occurs
618          */

619         protected void checkSQLState(Method JavaDoc method, SQLException JavaDoc sqle)
620             throws SQLException JavaDoc
621         {
622             if (sqle instanceof SQLClientInfoException JavaDoc &&
623                 method.getName().equals("setClientInfo") &&
624                 Arrays.asList(method.getParameterTypes())
625                 .equals(Arrays.asList(new Class JavaDoc[] { Properties JavaDoc.class }))) {
626                 // setClientInfo(Properties) should throw
627
// ClientInfoException, so this is OK
628
} else if (sqle.getSQLState().equals("08003")) {
629                 // expected, connection closed
630
} else {
631                 // unexpected exception
632
throw sqle;
633             }
634         }
635     }
636
637     /**
638      * Decorator class used for obtaining connections through a
639      * <code>DataSource</code>.
640      */

641     private static class DataSourceDecorator extends TestSetup {
642         /** Connection shared by many tests. */
643         private Connection JavaDoc connection_;
644
645         /**
646          * Creates a new <code>DataSourceDecorator</code> instance.
647          *
648          * @param test the test to decorate
649          */

650         public DataSourceDecorator(Test test) {
651             super(test);
652         }
653
654         /**
655          * Sets up the test by creating a connection.
656          *
657          * @exception SQLException if an error occurs
658          */

659         public final void setUp() throws SQLException JavaDoc {
660             connection_ = newConnection();
661         }
662
663         /**
664          * Gets the connection created when the test was set up.
665          *
666          * @return a <code>Connection</code> value
667          */

668         public final Connection JavaDoc getConnection() {
669             return connection_;
670         }
671
672         /**
673          * Creates a new connection with auto-commit set to false.
674          *
675          * @return a <code>Connection</code> value
676          * @exception SQLException if an error occurs
677          */

678         public final Connection JavaDoc newConnection() throws SQLException JavaDoc {
679             Connection JavaDoc conn = newConnection_();
680             conn.setAutoCommit(false);
681             return conn;
682         }
683
684         /**
685          * Tears down the test and closes the connection.
686          *
687          * @exception SQLException if an error occurs
688          */

689         public final void tearDown() throws SQLException JavaDoc {
690             connection_.rollback();
691             connection_.close();
692         }
693
694         /**
695          * Creates a new connection using a <code>DataSource</code>.
696          *
697          * @return a <code>Connection</code> value
698          * @exception SQLException if an error occurs
699          */

700         protected Connection JavaDoc newConnection_() throws SQLException JavaDoc {
701             DataSource JavaDoc ds = TestDataSourceFactory.getDataSource();
702             return ds.getConnection(TestConfiguration.getCurrent().getUserName(),
703                     TestConfiguration.getCurrent().getUserPassword());
704         }
705     }
706
707     /**
708      * Decorator class used for obtaining connections through a
709      * <code>ConnectionPoolDataSource</code>.
710      */

711     private static class PoolDataSourceDecorator extends DataSourceDecorator {
712         /**
713          * Creates a new <code>PoolDataSourceDecorator</code> instance.
714          *
715          * @param test the test to decorate
716          */

717         public PoolDataSourceDecorator(Test test) {
718             super(test);
719         }
720
721         /**
722          * Creates a new connection using a
723          * <code>ConnectionPoolDataSource</code>.
724          *
725          * @return a <code>Connection</code> value
726          * @exception SQLException if an error occurs
727          */

728         protected Connection JavaDoc newConnection_() throws SQLException JavaDoc {
729             ConnectionPoolDataSource JavaDoc ds = TestDataSourceFactory.getConnectionPoolDataSource();
730             PooledConnection JavaDoc pc =
731                 ds.getPooledConnection(TestConfiguration.getCurrent().getUserName(),
732                         TestConfiguration.getCurrent().getUserPassword());
733             return pc.getConnection();
734         }
735     }
736
737     /**
738      * Decorator class used for obtaining connections through an
739      * <code>XADataSource</code>.
740      */

741     private static class XADataSourceDecorator extends DataSourceDecorator {
742         /**
743          * Creates a new <code>XADataSourceDecorator</code> instance.
744          *
745          * @param test the test to decorate
746          */

747         public XADataSourceDecorator(Test test) {
748             super(test);
749         }
750
751         /**
752          * Creates a new connection using an <code>XADataSource</code>.
753          *
754          * @return a <code>Connection</code> value
755          * @exception SQLException if an error occurs
756          */

757         protected Connection JavaDoc newConnection_() throws SQLException JavaDoc {
758             XADataSource JavaDoc ds = TestDataSourceFactory.getXADataSource();
759             XAConnection JavaDoc xac = ds.getXAConnection(TestConfiguration.getCurrent().getUserName(),
760                     TestConfiguration.getCurrent().getUserPassword());
761             return xac.getConnection();
762         }
763     }
764 }
765
Popular Tags