KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > util > TestDataSourceFactory


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

21
22
23 package org.apache.derbyTesting.functionTests.util;
24
25 import java.util.Properties JavaDoc;
26 import javax.sql.DataSource JavaDoc;
27 import javax.sql.ConnectionPoolDataSource JavaDoc;
28 import javax.sql.XADataSource JavaDoc;
29
30 import org.apache.derbyTesting.junit.TestConfiguration;
31
32 /**
33  * Utility class for JDBC JUnit tests.
34  * Contains methods to obtain the various datasources.
35  */

36
37 public class TestDataSourceFactory {
38
39     /**
40      * Return a <code>DataSource</code> for the appropriate framework.
41      *
42      * @param attrs properties for the data source
43      * @return a <code>DataSource</code> object
44      * @see TestUtil#getDataSource(Properties)
45      */

46     public static DataSource JavaDoc getDataSource(Properties JavaDoc attrs) {
47         return TestUtil.getDataSource(attrs);
48     }
49
50     /**
51      * Return a <code>DataSource</code> which can establish a
52      * connection to the default database.
53      *
54      * @return a <code>DataSource</code> object
55      */

56     public static DataSource JavaDoc getDataSource() {
57         return getDataSource(TestConfiguration.getDefaultDataSourceProperties());
58     }
59
60     /**
61      * Return a <code>ConnectionPoolDataSource</code> for the
62      * appropriate framework.
63      *
64      * @param attrs properties for the data source
65      * @return a <code>ConnectionPoolDataSource</code> object
66      * @see TestUtil#getConnectionPoolDataSource(Properties)
67      */

68     public static ConnectionPoolDataSource JavaDoc
69         getConnectionPoolDataSource(Properties JavaDoc attrs)
70     {
71         return TestUtil.getConnectionPoolDataSource(attrs);
72     }
73
74     /**
75      * Return a <code>ConnectionPoolDataSource</code> which can
76      * establish a connection to the default database.
77      *
78      * @return a <code>ConnectionPoolDataSource</code> object
79      */

80     public static ConnectionPoolDataSource JavaDoc getConnectionPoolDataSource() {
81         return getConnectionPoolDataSource(TestConfiguration.getDefaultDataSourceProperties());
82     }
83
84     /**
85      * Return an <code>XADataSource</code> for the appropriate
86      * framework.
87      *
88      * @param attrs properties for the data source
89      * @return an <code>XADataSource</code> object
90      * @see TestUtil#getXADataSource(Properties)
91      */

92     public static XADataSource JavaDoc getXADataSource(Properties JavaDoc attrs) {
93         return TestUtil.getXADataSource(attrs);
94     }
95
96     /**
97      * Return an <code>XADataSource</code> which can establish a
98      * connection to the default database.
99      *
100      * @return an <code>XADataSource</code> object
101      */

102     public static XADataSource JavaDoc getXADataSource() {
103         return getXADataSource(TestConfiguration.getDefaultDataSourceProperties());
104     }
105
106 }
107
108
Popular Tags