You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/08/16 17:19:06 UTC
svn commit: r431919 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests:
tests/store/BootAllTest.java util/BaseJDBCTestCase.java
util/BaseJDBCTestSetup.java util/TestConfiguration.java
Author: djd
Date: Wed Aug 16 08:19:05 2006
New Revision: 431919
URL: http://svn.apache.org/viewvc?rev=431919&view=rev
Log:
DERBY-1555 DERBY-1701 (partial) Change the name of the TestConfiguration methods to openConnection from getConnection.
Step to having BaseJDBCTestCase.getConnection() be a method matching BaseJDBCTestSetup.getConnection, a handle
to a default connection stored in the instance. This will remove a lot of code in the classes that extend BaseJDBCTestCase
that store a connection locally and have N different ways of cleaning it up.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestSetup.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java?rev=431919&r1=431918&r2=431919&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java Wed Aug 16 08:19:05 2006
@@ -21,7 +21,7 @@
package org.apache.derbyTesting.functionTests.tests.store;
-import org.apache.derbyTesting.functionTests.util.BaseTestCase;
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
import org.apache.derbyTesting.functionTests.util.TestUtil;
import junit.framework.*;
@@ -35,7 +35,7 @@
* DERBY-1296 - Setting property derby.system.bootAll causes an Exception
*
*/
-public class BootAllTest extends BaseTestCase {
+public class BootAllTest extends BaseJDBCTestCase {
/** JDBC Connection */
private Connection con;
@@ -57,11 +57,10 @@
*/
public void setUp() throws Exception {
for (int i = 0; i < databases.length; i++) {
- con = CONFIG.getConnection(databases[i]);
+ con = openConnection(databases[i]);
con.close();
try {
- con = CONFIG.
- getConnection(databases[i] + ";shutdown=true");
+ con = openConnection(databases[i] + ";shutdown=true");
} catch (SQLException se) {
assertEquals("Expected exception on setUp " + se.getSQLState(),
DATABASE_SHUT_DOWN, se.getSQLState());
@@ -88,8 +87,7 @@
Class.forName(driverName);
println("Teardown of: " + getName());
try {
- con = CONFIG.
- getConnection(";shutdown=true");
+ con = openConnection(";shutdown=true");
} catch (SQLException se) {
assertEquals("Expected exception on tearDown " + se.getSQLState(),
ALL_DATABASES_SHUT_DOWN, se.getSQLState());
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java?rev=431919&r1=431918&r2=431919&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java Wed Aug 16 08:19:05 2006
@@ -41,20 +41,30 @@
super(name);
}
+ // TEMP
+ public static Connection getConnection() throws SQLException
+ {
+ return openDefaultConnection();
+ }
+
/**
- * Get connection to the default database.
+ * Open a connection to the default database.
* If the database does not exist, it will be created.
* A default username and password will be used for the connection.
*
* @return connection to default database.
+ * @see TestConfiguration#openDefaultConnection()
*/
- public static Connection getConnection()
+ public static Connection openDefaultConnection()
throws SQLException {
- return CONFIG.getDefaultConnection();
+ return CONFIG.openDefaultConnection();
+ }
+
+ public Connection openConnection(String databaseName) throws SQLException
+ {
+ return getTestConfiguration().openConnection(databaseName);
}
-
-
/**
* Tell if the client is embedded.
*
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestSetup.java?rev=431919&r1=431918&r2=431919&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestSetup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestSetup.java Wed Aug 16 08:19:05 2006
@@ -60,7 +60,7 @@
* <P>
* The tearDown method will close the connection if
* it is open.
- * @see TestConfiguration#getDefaultConnection()
+ * @see TestConfiguration#openDefaultConnection()
*/
public final Connection getConnection() throws SQLException
{
@@ -70,7 +70,7 @@
return conn;
conn = null;
}
- return conn = getTestConfiguration().getDefaultConnection();
+ return conn = getTestConfiguration().openDefaultConnection();
}
/**
@@ -92,5 +92,6 @@
throws java.lang.Exception
{
JDBC.cleanup(conn);
+ conn = null;
}
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java?rev=431919&r1=431918&r2=431919&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java Wed Aug 16 08:19:05 2006
@@ -189,27 +189,27 @@
}
/**
- * Get connection to the default database.
+ * Open connection to the default database.
* If the database does not exist, it will be created.
* A default username and password will be used for the connection.
*
* @return connection to default database.
*/
- public Connection getDefaultConnection()
+ public Connection openDefaultConnection()
throws SQLException {
- return getConnection(getDatabaseName());
+ return openConnection(getDatabaseName());
}
/**
- * Get connection to a database.
+ * Open a connection to a database.
* If the database does not exist, it will be created.
* A default username and password will be used for the connection.
*
* @param databaseName database to connect to
*
- * @return connection to default database.
+ * @return connection to database.
*/
- public Connection getConnection (String databaseName) throws SQLException {
+ public Connection openConnection (String databaseName) throws SQLException {
Connection con = null;
JDBCClient client =getJDBCClient();
if (JDBC.vmSupportsJDBC2()) {