001: /*
002:
003: Derby - Class org.apache.derbyTesting.functionTests.util.TestUtil
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derbyTesting.functionTests.util;
023:
024: import java.util.Properties;
025: import javax.sql.DataSource;
026: import javax.sql.ConnectionPoolDataSource;
027: import javax.sql.XADataSource;
028:
029: import org.apache.derbyTesting.junit.TestConfiguration;
030:
031: /**
032: * Utility class for JDBC JUnit tests.
033: * Contains methods to obtain the various datasources.
034: */
035:
036: public class TestDataSourceFactory {
037:
038: /**
039: * Return a <code>DataSource</code> for the appropriate framework.
040: *
041: * @param attrs properties for the data source
042: * @return a <code>DataSource</code> object
043: * @see TestUtil#getDataSource(Properties)
044: */
045: public static DataSource getDataSource(Properties attrs) {
046: return TestUtil.getDataSource(attrs);
047: }
048:
049: /**
050: * Return a <code>DataSource</code> which can establish a
051: * connection to the default database.
052: *
053: * @return a <code>DataSource</code> object
054: */
055: public static DataSource getDataSource() {
056: return getDataSource(TestConfiguration
057: .getDefaultDataSourceProperties());
058: }
059:
060: /**
061: * Return a <code>ConnectionPoolDataSource</code> for the
062: * appropriate framework.
063: *
064: * @param attrs properties for the data source
065: * @return a <code>ConnectionPoolDataSource</code> object
066: * @see TestUtil#getConnectionPoolDataSource(Properties)
067: */
068: public static ConnectionPoolDataSource getConnectionPoolDataSource(
069: Properties attrs) {
070: return TestUtil.getConnectionPoolDataSource(attrs);
071: }
072:
073: /**
074: * Return a <code>ConnectionPoolDataSource</code> which can
075: * establish a connection to the default database.
076: *
077: * @return a <code>ConnectionPoolDataSource</code> object
078: */
079: public static ConnectionPoolDataSource getConnectionPoolDataSource() {
080: return getConnectionPoolDataSource(TestConfiguration
081: .getDefaultDataSourceProperties());
082: }
083:
084: /**
085: * Return an <code>XADataSource</code> for the appropriate
086: * framework.
087: *
088: * @param attrs properties for the data source
089: * @return an <code>XADataSource</code> object
090: * @see TestUtil#getXADataSource(Properties)
091: */
092: public static XADataSource getXADataSource(Properties attrs) {
093: return TestUtil.getXADataSource(attrs);
094: }
095:
096: /**
097: * Return an <code>XADataSource</code> which can establish a
098: * connection to the default database.
099: *
100: * @return an <code>XADataSource</code> object
101: */
102: public static XADataSource getXADataSource() {
103: return getXADataSource(TestConfiguration
104: .getDefaultDataSourceProperties());
105: }
106:
107: }
|