db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r471104 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
Date Sat, 04 Nov 2006 02:47:30 GMT
Author: djd
Date: Fri Nov  3 18:47:29 2006
New Revision: 471104

URL: http://svn.apache.org/viewvc?view=rev&rev=471104
Log:
DERBY-2033 (partial) Add login in CleanDatabaseTestSetup to unset database properties as
part of the cleanup. Specifcally unset derby.database.classpath for the DatabaseClassLoadingTest
but others can be added in the future.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java?view=diff&rev=471104&r1=471103&r2=471104
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
Fri Nov  3 18:47:29 2006
@@ -107,6 +107,43 @@
      * @throws SQLException database error
      */
      public static void cleanDatabase(Connection conn) throws SQLException {
+         clearProperties(conn);
+         removeObjects(conn);
+
+     }
+     
+     /**
+      * Set of database properties that will be set to NULL (unset)
+      * as part of cleaning a database.
+      */
+     private static final String[] CLEAR_DB_PROPERTIES =
+     {
+         "derby.database.classpath",
+     };
+     
+     /**
+      * Clear all database properties.
+      */
+     private static void clearProperties(Connection conn) throws SQLException {
+
+         PreparedStatement ps = conn.prepareCall(
+           "CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, NULL)");
+         
+         for (int i = 0; i < CLEAR_DB_PROPERTIES.length; i++)
+         {
+             ps.setString(1, CLEAR_DB_PROPERTIES[i]);
+             ps.executeUpdate();
+         }
+         ps.close();
+         conn.commit();
+     }
+     
+     
+     /**
+      * Remove all objects in all schemas from the database.
+      */
+     private static void removeObjects(Connection conn) throws SQLException {
+   
         DatabaseMetaData dmd = conn.getMetaData();
 
         SQLException sqle = null;



Mime
View raw message