db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r529838 - in /db/derby/code/trunk/java: client/org/apache/derby/jdbc/ClientBaseDataSource.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DSCreateShutdownDBTest.java
Date Wed, 18 Apr 2007 02:42:26 GMT
Author: myrnavl
Date: Tue Apr 17 19:42:26 2007
New Revision: 529838

URL: http://svn.apache.org/viewvc?view=rev&rev=529838
Log:
DERBY-2296 - ensure values for createDatabase and shutdownDatabase get reset when the value
is invalid. Add test case to DSCreateShutdownDBTest.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DSCreateShutdownDBTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?view=diff&rev=529838&r1=529837&r2=529838
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Tue Apr
17 19:42:26 2007
@@ -877,6 +877,8 @@
     public final void setCreateDatabase(String create) {
         if (create != null && create.equalsIgnoreCase("create"))
             this.createDatabase = true;
+        else // reset
+            this.createDatabase = false;
     }
     
     /** @return "create" if create is set, or null if not 
@@ -898,6 +900,8 @@
     public final void setShutdownDatabase(String shutdown) {
         if (shutdown != null && shutdown.equalsIgnoreCase("shutdown"))
             this.shutdownDatabase = true;
+        else // reset
+            this.shutdownDatabase = false;
     }
 
     /** @return "shutdown" if shutdown is set, or null if not 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DSCreateShutdownDBTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DSCreateShutdownDBTest.java?view=diff&rev=529838&r1=529837&r2=529838
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DSCreateShutdownDBTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DSCreateShutdownDBTest.java
Tue Apr 17 19:42:26 2007
@@ -164,6 +164,8 @@
         assertNotSetAndGet(dbName, "shutdownDatabase", "false");
         assertNotSetAndGet(dbName, "createDatabase", "false");
         
+        assertReset(dbName);
+        
         // check that shutting down using Attributes works
         assertShutdownUsingConnAttrsOK(dbName);
         // re-vive db
@@ -230,6 +232,48 @@
         DataSource ds = JDBCDataSource.getDataSourceLogical(dbName);
         JDBCDataSource.setBeanProperty(ds, propertyString, setValue);
         assertNull(getBeanProperty(ds, propertyString));
+    }
+    
+    protected void assertReset(String dbName) 
+    throws SQLException {
+        DataSource ds = JDBCDataSource.getDataSourceLogical(dbName);
+        JDBCDataSource.setBeanProperty(ds, "createDatabase", "");
+        assertNull(getBeanProperty(ds, "createDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "createDatabase", "create");
+        assertEquals("create", getBeanProperty(ds, "createDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "createDatabase", "boo");
+        assertNull(getBeanProperty(ds, "createDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "createDatabase", "create");
+        assertEquals("create", getBeanProperty(ds, "createDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "createDatabase", "false");
+        assertNull(getBeanProperty(ds, "createDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "createDatabase", "create");
+        assertEquals("create", getBeanProperty(ds, "createDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "createDatabase", "");
+        assertNull(getBeanProperty(ds, "createDatabase"));
+        try { 
+            JDBCDataSource.setBeanProperty(ds, "createDatabase", "");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "");
+        assertNull(getBeanProperty(ds, "shutdownDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
+        assertEquals("shutdown", getBeanProperty(ds, "shutdownDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "boo");
+        assertNull(getBeanProperty(ds, "shutdownDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "false");
+        assertNull(getBeanProperty(ds, "shutdownDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
+        assertEquals("shutdown", getBeanProperty(ds, "shutdownDatabase"));
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "");
+        assertNull(getBeanProperty(ds, "shutdownDatabase"));
+        try { 
+            JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
     
     public static Object getBeanProperty(Object ds, String propertyString)



Mime
View raw message