db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r530863 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/jdbcapi/ junit/
Date Fri, 20 Apr 2007 17:32:35 GMT
Author: myrnavl
Date: Fri Apr 20 10:32:34 2007
New Revision: 530863

URL: http://svn.apache.org/viewvc?view=rev&rev=530863
Log:
DERBY-2296 - reinstating setShutdownDB in JDBCDataSource after implementing it for ClientDataSource; simplifying *AuthenticationTest by removing if(usingEmbedded()) and usingDerbyNetClient()) blocks for shutdown is now possible.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DSCreateShutdownDBTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/PoolDSAuthenticationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XADSAuthenticationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java?view=diff&rev=530863&r1=530862&r2=530863
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java Fri Apr 20 10:32:34 2007
@@ -35,7 +35,6 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.derby.jdbc.ClientDataSource;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
 import org.apache.derbyTesting.junit.JDBC;
@@ -170,7 +169,7 @@
         assertShutdownWOUPFail("2850H", dbName, "dan", ("dan" + PASSWORD_SUFFIX));
         assertShutdownFail("2850H", dbName, "system", "admin");
         assertShutdownWOUPFail("2850H", dbName, "system", "admin");
-        assertShutdownOK(dbName, "APP", ("APP" + PASSWORD_SUFFIX));
+        assertShutdownUsingConnAttrsOK(dbName, "APP", ("APP" + PASSWORD_SUFFIX));
         
         // ensure that a password is encrypted
         Connection conn1 = openDefaultConnection(
@@ -532,7 +531,8 @@
             assertConnectionOK(dbName, apollo, zeus);
             assertShutdownFail("08004", dbName, zeus, zeus);
             assertShutdownFail("2850H", dbName, apollo, zeus);
-            assertShutdownOK(dbName, "APP", ("APP" + PASSWORD_SUFFIX));
+            assertShutdownUsingSetShutdownOK(
+                dbName, "APP", ("APP" + PASSWORD_SUFFIX));
 
             conn1 = openDefaultConnection(zeus, apollo);
             Statement stmt = conn1.createStatement();
@@ -582,7 +582,8 @@
                 }
         });
         // bring down the database
-        assertShutdownOK(dbName, "APP", "APP" + PASSWORD_SUFFIX);
+        assertShutdownUsingSetShutdownOK(
+            dbName, "APP", "APP" + PASSWORD_SUFFIX);
         // recheck
         assertConnectionOK(dbName, "system", "admin");
         assertConnectionOK(dbName, "dan", ("dan" + PASSWORD_SUFFIX));
@@ -616,7 +617,8 @@
         conn1.commit();
         conn1.close();
         openDefaultConnection("system", "admin");
-        assertShutdownOK(dbName, "APP", "APP" + PASSWORD_SUFFIX);
+        assertShutdownUsingSetShutdownOK(
+            dbName, "APP", "APP" + PASSWORD_SUFFIX);
         assertSystemShutdownOK("", "system", "admin");
         openDefaultConnection("system", "admin"); // just so teardown works.
     }
@@ -745,34 +747,31 @@
         }
     }
 
-    protected void assertShutdownOK(
-        String dbName, String user, String password)
-    throws SQLException {
-
-        if (usingEmbedded())
-        {
-            DataSource ds = JDBCDataSource.getDataSource(dbName);
-            JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
-            try {
-                ds.getConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
+    protected void assertShutdownUsingSetShutdownOK(
+            String dbName, String user, String password) throws SQLException {
+        DataSource ds = JDBCDataSource.getDataSource(dbName);
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
+        try {
+            ds.getConnection(user, password);
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
         }
-        else if (usingDerbyNetClient())
-        {
-            ClientDataSource ds = 
-                (ClientDataSource)JDBCDataSource.getDataSource(dbName);
-            ds.setConnectionAttributes("shutdown=true");
-            try {
-                ds.getConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
+    }
+
+    protected void assertShutdownUsingConnAttrsOK(
+        String dbName, String user, String password) throws SQLException {
+
+        DataSource ds = JDBCDataSource.getDataSource(dbName);
+        JDBCDataSource.setBeanProperty(
+            ds, "connectionAttributes", "shutdown=true");
+        try {
+            ds.getConnection(user, password);
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
         }
     }
 
@@ -783,33 +782,16 @@
         String dbName, String user, String password)
     throws SQLException {
 
-        if (usingEmbedded())
-        {
-            DataSource ds = JDBCDataSource.getDataSource(dbName);
-            JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(ds, "user", user);
-            JDBCDataSource.setBeanProperty(ds, "password", password);
-            try {
-                ds.getConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientDataSource ds = 
-                (ClientDataSource)JDBCDataSource.getDataSource(dbName);
-            ds.setConnectionAttributes(
-                    "shutdown=true;user=" + user + ";password="+password);
-            try {
-                ds.getConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
+        DataSource ds = JDBCDataSource.getDataSource(dbName);
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(ds, "user", user);
+        JDBCDataSource.setBeanProperty(ds, "password", password);
+        try {
+            ds.getConnection();
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
         }
     }
     
@@ -817,30 +799,13 @@
         String expectedSqlState, String dbName, String user, String password) 
     throws SQLException
     {
-
-        // with DerbyNetClient there is no Datasource setShutdownDatabase method
-        if (usingEmbedded()) 
-        {
-            DataSource ds = JDBCDataSource.getDataSource(dbName);
-            JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
-            try {
-                ds.getConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientDataSource ds = 
-                (ClientDataSource)JDBCDataSource.getDataSource(dbName);
-            ds.setConnectionAttributes("shutdown=true");
-            try {
-                ds.getConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
+        DataSource ds = JDBCDataSource.getDataSource(dbName);
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
+        try {
+            ds.getConnection(user, password);
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            assertSQLState(expectedSqlState, e);
         }
     }
     
@@ -848,39 +813,22 @@
         String expectedSqlState, String dbName, String user, String password) 
     throws SQLException
     {
-        // with DerbyNetClient there is no Datasource setShutdownDatabase 
-        // method so can't use the same setBeanProperty as with embedded
-        if (usingEmbedded()) 
-        {
-            DataSource ds = JDBCDataSource.getDataSource(dbName);
-            JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(ds, "user", user);
-            JDBCDataSource.setBeanProperty(ds, "password", password);
-            try {
-                ds.getConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientDataSource ds = 
-                (ClientDataSource)JDBCDataSource.getDataSource(dbName);
-            ds.setConnectionAttributes(
-                "shutdown=true;user=" + user + ";password="+password);
-            try {
-                ds.getConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
+        DataSource ds = JDBCDataSource.getDataSource(dbName);
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(ds, "user", user);
+        JDBCDataSource.setBeanProperty(ds, "password", password);
+        try {
+            ds.getConnection();
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            assertSQLState(expectedSqlState, e);
         }
     }
     
     protected void assertSystemShutdownOK(
         String dbName, String user, String password)
     throws SQLException {
+        DataSource ds;
         if (usingEmbedded())
         {
             // we cannot use JDBCDataSource.getDataSource() (which uses the
@@ -889,78 +837,59 @@
             // The alternative is to use jDBCDataSource.getDatasource(dbName),
             // where dbName is an empty string - this will in the current code
             // be interpreted as a system shutdown.
-            DataSource ds = JDBCDataSource.getDataSource();
+            
+            ds = JDBCDataSource.getDataSource();
             JDBCDataSource.clearStringBeanProperty(ds, "databaseName");
-            JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
-            try {
-                ds.getConnection(user, password);
-                fail("expected system shutdown resulting in XJ015 error");
-            } catch (SQLException e) {
-                // expect XJ015, system shutdown, on successful shutdown
-                assertSQLState("XJ015", e);
-            }
         }
-        else if (usingDerbyNetClient())
+        else 
         {
-            // ds.setShutdown is not currently suppported by client, so we need
-            // to use ds.setConnectionAttributes.
             // With client, we cannot user clearStringBeanProperty on the  
             // databaseName, that will result in error 08001 - 
             // Required DataSource property databaseName not set.
             // So, we pass an empty string as databaseName, which the current
             // code interprets as a system shutdown.
-            ClientDataSource ds = 
-                (ClientDataSource)JDBCDataSource.getDataSource(dbName);
-            ds.setConnectionAttributes("shutdown=true");
-            try {
-                ds.getConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect XJ015 on successful shutdown
-                assertSQLState("XJ015", e);
-            }
+            ds = JDBCDataSource.getDataSource(dbName);
+        }
+        
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
+        try {
+            ds.getConnection(user, password);
+            fail("expected system shutdown resulting in XJ015 error");
+        } catch (SQLException e) {
+            // expect XJ015, system shutdown, on successful shutdown
+            assertSQLState("XJ015", e);
         }
     }
 
     protected void assertSystemShutdownFail(
         String expectedError, String dbName, String user, String password)
     throws SQLException {
+        DataSource ds;
         if (usingEmbedded())
         {
-            DataSource ds = JDBCDataSource.getDataSource();
+            ds = JDBCDataSource.getDataSource();
             JDBCDataSource.clearStringBeanProperty(ds, "databaseName");
-            JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(ds, "user", user);
-            JDBCDataSource.setBeanProperty(ds, "password", password);
-            try {
-                ds.getConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedError, e);
-            }
         }
-        else if (usingDerbyNetClient())
+        else
         {
-            ClientDataSource ds = 
-                (ClientDataSource)JDBCDataSource.getDataSource(dbName);
-            // note: with network server, you cannot set the databaseName
+            // note: with network server/client, you can't set the databaseName
             // to null, that results in error 08001 - Required DataSource
             // property databaseName not set.
             // so, we rely on passing of an empty string for databaseName,
             // which in the current code is interpreted as system shutdown.
-            // also, we need to use setConnectionAttributes.
-            ds.setConnectionAttributes(
-                "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                ds.getConnection();
-                fail("expected shutdown to fail");
-                ds.getConnection(user, password);
-            } catch (SQLException e) {
-                assertSQLState(expectedError, e);
-            }
+            ds = JDBCDataSource.getDataSource(dbName);
+        }
+        JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(ds, "user", user);
+        JDBCDataSource.setBeanProperty(ds, "password", password);
+        try {
+            ds.getConnection();
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            assertSQLState(expectedError, e);
         }
     }
-    
+
     public void assertConnectionFail(String dbName) throws SQLException {
         
         // Get the default data source but clear the user and

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=530863&r1=530862&r2=530863
==============================================================================
--- 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 Fri Apr 20 10:32:34 2007
@@ -39,6 +39,7 @@
 public class DSCreateShutdownDBTest extends BaseJDBCTestCase {
 
     static final String[] ADDITIONAL_DBS = {
+        "dscreateconatdb1",
         "dscreateshutdowndb1", 
         "dscreateshutdowndb2",
         "conflict1",
@@ -58,7 +59,7 @@
 
     public static Test suite() 
     {
-        TestSuite suite = new TestSuite("DSCreateShutdownTest"); 
+        TestSuite suite = new TestSuite("DSCreateShutdownDBTest"); 
         Test test = TestConfiguration.defaultSuite(DSCreateShutdownDBTest.class);        
         //Test test = TestConfiguration.clientServerSuite(DSCreateShutdownDBTest.class);
         suite.addTest(test);
@@ -78,8 +79,8 @@
     
     public void tearDown() throws Exception {
         // attempt to get rid of any databases. 
-        // only 4 dbs (in addition to defaultdb) should actually get
-        // created, but just in case...
+        // only 5 dbs (in addition to defaultdb) should actually get
+        // created, but just in case, try all...
         AccessController.doPrivileged(new java.security.PrivilegedAction() {
             public Object run() {
                 for (int i=0 ; i < ADDITIONAL_DBS.length ; i++)
@@ -166,21 +167,24 @@
         
         assertReset(dbName);
         
-        // check that shutting down using Attributes works
+        // check that create using ConnAttributes works
+        assertCreateUsingConnAttrsOK(composeDatabaseName(ADDITIONAL_DBS[0]));
+        
+        // check that shutting down using ConnAttributes works
         assertShutdownUsingConnAttrsOK(dbName);
         // re-vive db
         getConnection();
         
         // now, actually create, and shutdown a database
         // first ensure it's not there yet
-        dbName = composeDatabaseName(ADDITIONAL_DBS[0]);
+        dbName = composeDatabaseName(ADDITIONAL_DBS[1]);
         assertNoDB(dbName);
         // straightforward create and shutdown
         assertPositive(dbName);
         
         // what happens when you combine set*Database and 
         // matching connection attribute? (should work)
-        dbName = composeDatabaseName(ADDITIONAL_DBS[1]);
+        dbName = composeDatabaseName(ADDITIONAL_DBS[2]);
         assertNoDB(dbName);
         assertTwiceOK(dbName);
         
@@ -190,15 +194,15 @@
         // what happens when you combine create and shutdown connattr?
         // database does not get created.
         assertShutdownAndCreateConnAttr(DBNotFoundState, 
-            composeDatabaseName(ADDITIONAL_DBS[2]), 
+            composeDatabaseName(ADDITIONAL_DBS[3]), 
             "shutdown=true;create=true");
         assertShutdownAndCreateConnAttr(DBNotFoundState, 
-            composeDatabaseName(ADDITIONAL_DBS[3]), 
+            composeDatabaseName(ADDITIONAL_DBS[4]), 
             "create=true;shutdown=true");
 
         // and when you set both setShutdownDatabase and setCreateDatabase?
         // database does not get created
-        assertConflictedSettersOK(composeDatabaseName(ADDITIONAL_DBS[4]));
+        assertConflictedSettersOK(composeDatabaseName(ADDITIONAL_DBS[5]));
         
         // what happens when you combine set*Database and
         // opposing connection attributes? database does not get created. 
@@ -237,6 +241,7 @@
     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");
@@ -281,7 +286,6 @@
         String getterName = getGetterName(propertyString);
 
         // Base the type of the setter method from the value's class.
-
         Object retObject=null;
         try {
             Method getter = ds.getClass().getMethod(getterName, null);
@@ -310,9 +314,20 @@
         assertDSConnectionFailed("08006", ds);
     }
     
+    // for completeness' sake, test create=true conn attr.
+    protected void assertCreateUsingConnAttrsOK(String dbName)
+    throws SQLException {
+        DataSource ds = JDBCDataSource.getDataSource(dbName);
+        JDBCDataSource.setBeanProperty(
+                ds, "ConnectionAttributes", "create=true");
+        assertUpdateCount(
+            ds.getConnection().createStatement(), 0, "set schema APP");
+        JDBCDataSource.clearStringBeanProperty(ds, "ConnectionAttributes");
+        assertShutdownUsingSetOK(dbName, false);
+    }
+    
     protected void assertShutdownUsingConnAttrsOK(String dbName)
     throws SQLException {
-
         DataSource ds = JDBCDataSource.getDataSourceLogical(dbName);
         JDBCDataSource.setBeanProperty(
             ds, "ConnectionAttributes", "shutdown=true");
@@ -379,17 +394,16 @@
 
     protected void assertConflictedSetterConnAttrOK() 
     throws SQLException {
-        assertConSetOK(DBNotFoundState, composeDatabaseName(ADDITIONAL_DBS[5]), 
+        assertConSetOK(DBNotFoundState, composeDatabaseName(ADDITIONAL_DBS[6]), 
             "shutdown=true", "CreateDatabase", "create");
         // with the new networkserver methods, this actually works...
-        assertConSetOK(DBNotFoundState, composeDatabaseName(ADDITIONAL_DBS[6]),
+        assertConSetOK(DBNotFoundState, composeDatabaseName(ADDITIONAL_DBS[7]),
             "create=true", "ShutdownDatabase", "shutdown");
-        assertSetConOK(DBNotFoundState, composeDatabaseName(ADDITIONAL_DBS[7]), 
+        assertSetConOK(DBNotFoundState, composeDatabaseName(ADDITIONAL_DBS[8]), 
             "shutdown=true", "CreateDatabase", "create");
         // with the new networkserver methods, this actually works...
-        assertSetConOK(DBNotFoundState, composeDatabaseName(ADDITIONAL_DBS[8]),
+        assertSetConOK(DBNotFoundState, composeDatabaseName(ADDITIONAL_DBS[9]),
             "create=true", "ShutdownDatabase", "shutdown");
-
     }
     
     // first sets setCreate/ShutdownDB, then sets ConnectionAttributes
@@ -397,7 +411,6 @@
         String connAttrValue, String setter, String setValue) 
     throws SQLException {
         DataSource ds = JDBCDataSource.getDataSource(dbName);
-        
         JDBCDataSource.setBeanProperty(ds, setter, setValue);
         JDBCDataSource.setBeanProperty(
             ds, "ConnectionAttributes", connAttrValue);
@@ -416,7 +429,6 @@
         String connAttrValue, String setter, String setValue) 
     throws SQLException {
         DataSource ds = JDBCDataSource.getDataSource(dbName);
-        
         JDBCDataSource.setBeanProperty(
             ds, "ConnectionAttributes", connAttrValue);
         JDBCDataSource.setBeanProperty(ds, setter, setValue);
@@ -429,5 +441,4 @@
         JDBCDataSource.clearStringBeanProperty(ds, "ConnectionAttributes");
         JDBCDataSource.clearStringBeanProperty(ds, setter);
     }
-
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/PoolDSAuthenticationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/PoolDSAuthenticationTest.java?view=diff&rev=530863&r1=530862&r2=530863
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/PoolDSAuthenticationTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/PoolDSAuthenticationTest.java Fri Apr 20 10:32:34 2007
@@ -23,15 +23,12 @@
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
 import java.sql.SQLException;
-import java.util.Properties;
 
 import javax.sql.ConnectionPoolDataSource;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.derby.jdbc.ClientConnectionPoolDataSource;
-import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource;
 import org.apache.derbyTesting.junit.J2EEDataSource;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.JDBCDataSource;
@@ -155,72 +152,49 @@
         }
     }
     
-    protected void assertShutdownOK(
+    protected void assertShutdownUsingSetShutdownOK(
         String dbName, String user, String password)
     throws SQLException {
-        if (usingEmbedded())
-        {
-            pds = J2EEDataSource.getConnectionPoolDataSource();
-            JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
-            JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
-            try {
-                pds.getPooledConnection(user, password);
-                fail ("expected a failed shutdown connection");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientConnectionPoolDataSource pds = 
-                (ClientConnectionPoolDataSource)
-                J2EEDataSource.getConnectionPoolDataSource();
-            pds.setDatabaseName(dbName);
-            pds.setConnectionAttributes("shutdown=true");
-            try {
-                pds.getPooledConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
+        pds = J2EEDataSource.getConnectionPoolDataSource();
+        JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
+        try {
+            pds.getPooledConnection(user, password);
+            fail ("expected a failed shutdown connection");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
+        }
+    }
+    
+    protected void assertShutdownUsingConnAttrsOK(
+        String dbName, String user, String password) throws SQLException {
+        pds = J2EEDataSource.getConnectionPoolDataSource();
+        JDBCDataSource.setBeanProperty(
+            pds, "connectionAttributes", "shutdown=true");
+        try {
+            pds.getPooledConnection(user, password);
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
         }
     }
 
     protected void assertShutdownWOUPOK(
         String dbName, String user, String password)
     throws SQLException {
-        if (usingEmbedded())
-        {
-            pds = J2EEDataSource.getConnectionPoolDataSource();
-            JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
-            JDBCDataSource.setBeanProperty(pds, "user", user);
-            JDBCDataSource.setBeanProperty(pds, "password", password);
-            JDBCDataSource.setBeanProperty(pds, "shutdownDatabase","shutdown");
-            try {
-                pds.getPooledConnection();
-                fail ("expected a failed shutdown connection");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientConnectionPoolDataSource pds = 
-                (ClientConnectionPoolDataSource)
-                J2EEDataSource.getConnectionPoolDataSource();
-            pds.setDatabaseName(dbName);
-            pds.setConnectionAttributes(
-                "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                pds.getPooledConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
+        pds = J2EEDataSource.getConnectionPoolDataSource();
+        JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(pds, "user", user);
+        JDBCDataSource.setBeanProperty(pds, "password", password);
+        JDBCDataSource.setBeanProperty(pds, "shutdownDatabase","shutdown");
+        try {
+            pds.getPooledConnection();
+            fail ("expected a failed shutdown connection");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
         }
     }
 
@@ -228,31 +202,14 @@
         String expectedSqlState, String dbName, String user, String password) 
     throws SQLException
     {
-        if (usingEmbedded()) 
-        {
-            pds = J2EEDataSource.getConnectionPoolDataSource();
-            JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
-            try {
-                pds.getPooledConnection(user, password);
-                fail("expected failed shutdown");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientConnectionPoolDataSource pds = 
-                (ClientConnectionPoolDataSource)
-                J2EEDataSource.getConnectionPoolDataSource();
-            pds.setConnectionAttributes("shutdown=true");
-            pds.setDatabaseName(dbName);
-            try {
-                pds.getPooledConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
+        pds = J2EEDataSource.getConnectionPoolDataSource();
+        JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
+        try {
+            pds.getPooledConnection(user, password);
+            fail("expected failed shutdown");
+        } catch (SQLException e) {
+            assertSQLState(expectedSqlState, e);
         }
     }
     
@@ -260,139 +217,70 @@
         String expectedSqlState, String dbName, String user, String password) 
     throws SQLException
     {
-        if (usingEmbedded()) 
-        {
-            pds = J2EEDataSource.getConnectionPoolDataSource();
-            JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(pds, "user", user);
-            JDBCDataSource.setBeanProperty(pds, "password", password);
-            JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
-            try {
-                pds.getPooledConnection();
-                fail("expected failed shutdown");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientConnectionPoolDataSource pds = 
-                (ClientConnectionPoolDataSource)
-                J2EEDataSource.getConnectionPoolDataSource();
-            pds.setDatabaseName(dbName);
-            pds.setConnectionAttributes(
-                    "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                pds.getPooledConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
+        pds = J2EEDataSource.getConnectionPoolDataSource();
+        JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(pds, "user", user);
+        JDBCDataSource.setBeanProperty(pds, "password", password);
+        JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
+        try {
+            pds.getPooledConnection();
+            fail("expected failed shutdown");
+        } catch (SQLException e) {
+            assertSQLState(expectedSqlState, e);
         }
     }
 
+    // using an empty dbName is interpreted as system shutdown
     protected void assertSystemShutdownOK(
         String dbName, String user, String password)
     throws SQLException {
-        if (usingEmbedded())
-        {
-            pds = J2EEDataSource.getConnectionPoolDataSource();
-            JDBCDataSource.clearStringBeanProperty(pds, "databaseName");
-            JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(pds, "user", user);
-            JDBCDataSource.setBeanProperty(pds, "password", password);
-            try {
-                pds.getPooledConnection();
-                fail("expected system shutdown resulting in XJ015 error");
-            } catch (SQLException e) {
-                // expect XJ015, system shutdown, on successful shutdown
-                assertSQLState("XJ015", e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientConnectionPoolDataSource pds = 
-                (ClientConnectionPoolDataSource)
-                J2EEDataSource.getConnectionPoolDataSource();
-            // current client/server code interprets shutdown with an
-            // empty databaseName string as a system shutdown
-            pds.setDatabaseName(dbName);
-            // Client does not support *ds*.setShutdown(), use set Conn Attrs 
-            pds.setConnectionAttributes(
-                    "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                pds.getPooledConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect XJ015 on successful shutdown
-                assertSQLState("XJ015", e);
-            }
+        pds = J2EEDataSource.getConnectionPoolDataSource();
+        JDBCDataSource.clearStringBeanProperty(pds, "databaseName");
+        JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(pds, "user", user);
+        JDBCDataSource.setBeanProperty(pds, "password", password);
+        try {
+            pds.getPooledConnection();
+            fail("expected system shutdown resulting in XJ015 error");
+        } catch (SQLException e) {
+            // expect XJ015, system shutdown, on successful shutdown
+            assertSQLState("XJ015", e);
         }
     }
 
     protected void assertSystemShutdownFail(
             String expectedError, String dbName, String user, String password)
     throws SQLException {
-        if (usingEmbedded())
-        {
-            pds = J2EEDataSource.getConnectionPoolDataSource();
-            JDBCDataSource.clearStringBeanProperty(pds, "databaseName");
-            JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(pds, "user", user);
-            JDBCDataSource.setBeanProperty(pds, "password", password);
-            try {
-                pds.getPooledConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedError, e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientConnectionPoolDataSource pds = 
-                (ClientConnectionPoolDataSource)
-                J2EEDataSource.getConnectionPoolDataSource();
-            // current client/server code interprets shutdown with an
-            // empty databaseName string as a system shutdown
-            pds.setDatabaseName(dbName);
-            // Client does not support *ds*.setShutdown(), use set Conn Attrs 
-            pds.setConnectionAttributes(
-                    "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                pds.getPooledConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedError, e);
-            }
+        pds = J2EEDataSource.getConnectionPoolDataSource();
+        JDBCDataSource.clearStringBeanProperty(pds, "databaseName");
+        JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(pds, "user", user);
+        JDBCDataSource.setBeanProperty(pds, "password", password);
+        try {
+            pds.getPooledConnection();
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            assertSQLState(expectedError, e);
         }
     }
 
     public void assertConnectionFail(String dbName) throws SQLException {
-        // can't rely on junit framework automatic methods for they'll
-        // default the user / password which need to remain empty
+        pds = J2EEDataSource.getConnectionPoolDataSource();
+        // Reset to no user/password though client requires
+        // a valid name, so reset to the default
         if (usingDerbyNetClient())
-        {
-            ClientConnectionPoolDataSource pds = 
-                new ClientConnectionPoolDataSource();
-            pds.setDatabaseName(dbName);
-            try {
-                pds.getPooledConnection();
-                fail("expected connection to fail");
-            } catch (SQLException e) {
-                assertSQLState("08004", e);
-            }
-        }
-        else if (usingEmbedded()) 
-        {
-            EmbeddedConnectionPoolDataSource pds = 
-                new EmbeddedConnectionPoolDataSource();
-            pds.setDatabaseName(dbName);
-            try {
-                pds.getPooledConnection();
-                fail("expected connection to fail");
-            } catch (SQLException e) {
-                assertSQLState("08004", e);
-            }
+            JDBCDataSource.setBeanProperty(pds, "user", "APP");
+        else
+            JDBCDataSource.clearStringBeanProperty(pds, "user");
+        JDBCDataSource.clearStringBeanProperty(pds, "password");
+        JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
+        try {
+            pds.getPooledConnection();
+            fail("expected connection to fail");
+        } catch (SQLException e) {
+            assertSQLState("08004", e);
         }
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XADSAuthenticationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XADSAuthenticationTest.java?view=diff&rev=530863&r1=530862&r2=530863
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XADSAuthenticationTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XADSAuthenticationTest.java Fri Apr 20 10:32:34 2007
@@ -23,14 +23,12 @@
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
 import java.sql.SQLException;
-import java.util.Properties;
+
 import javax.sql.XADataSource;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.derby.jdbc.ClientXADataSource;
-import org.apache.derby.jdbc.EmbeddedXADataSource;
 import org.apache.derbyTesting.junit.J2EEDataSource;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.JDBCDataSource;
@@ -151,72 +149,50 @@
         }
     }
     
-    protected void assertShutdownOK(
-        String dbName, String user, String password)
-    throws SQLException {
-        if (usingEmbedded())
-        {
-            xads = J2EEDataSource.getXADataSource();
-            JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
-            JDBCDataSource.setBeanProperty(
-                xads, "shutdownDatabase", "shutdown");
-            try {
-                xads.getXAConnection(user, password);
-                fail ("expected a failed shutdown connection");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientXADataSource xads = 
-                (ClientXADataSource)J2EEDataSource.getXADataSource();
-            xads.setDatabaseName(dbName);
-            xads.setConnectionAttributes("shutdown=true");
-            try {
-                xads.getXAConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
+    protected void assertShutdownUsingSetShutdownOK(
+            String dbName, String user, String password) throws SQLException {
+        xads = J2EEDataSource.getXADataSource();
+        JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(
+            xads, "shutdownDatabase", "shutdown");
+        try {
+            xads.getXAConnection(user, password);
+            fail ("expected a failed shutdown connection");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
+        }
+    }
+
+    protected void assertShutdownUsingConnAttrsOK(
+        String dbName, String user, String password) throws SQLException {
+        xads = J2EEDataSource.getXADataSource();
+        JDBCDataSource.setBeanProperty(
+            xads, "connectionAttributes", "shutdown=true");
+        try {
+            xads.getXAConnection(user, password);
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
         }
     }
 
     protected void assertShutdownWOUPOK(
         String dbName, String user, String password)
     throws SQLException {
-        if (usingEmbedded())
-        {
-            xads = J2EEDataSource.getXADataSource();
-            JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
-            JDBCDataSource.setBeanProperty(
+        xads = J2EEDataSource.getXADataSource();
+        JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(
                 xads, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(xads, "user", user);
-            JDBCDataSource.setBeanProperty(xads, "password", password);
-            try {
-                xads.getXAConnection();
-                fail ("expected a failed shutdown connection");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientXADataSource xads = 
-                (ClientXADataSource)J2EEDataSource.getXADataSource();
-            xads.setDatabaseName(dbName);
-            xads.setConnectionAttributes(
-                "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                xads.getXAConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect 08006 on successful shutdown
-                assertSQLState("08006", e);
-            }
+        JDBCDataSource.setBeanProperty(xads, "user", user);
+        JDBCDataSource.setBeanProperty(xads, "password", password);
+        try {
+            xads.getXAConnection();
+            fail ("expected a failed shutdown connection");
+        } catch (SQLException e) {
+            // expect 08006 on successful shutdown
+            assertSQLState("08006", e);
         }
     }
 
@@ -224,30 +200,14 @@
         String expectedSqlState, String dbName, String user, String password) 
     throws SQLException
     {
-        if (usingEmbedded()) 
-        {
-            xads = J2EEDataSource.getXADataSource();
-            JDBCDataSource.setBeanProperty(xads, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
-            try {
-                xads.getXAConnection(user, password);
-                fail("expected failed shutdown");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientXADataSource xads = 
-                (ClientXADataSource)J2EEDataSource.getXADataSource();
-            xads.setDatabaseName(dbName);
-            xads.setConnectionAttributes("shutdown=true");
-            try {
-                xads.getXAConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
+        xads = J2EEDataSource.getXADataSource();
+        JDBCDataSource.setBeanProperty(xads, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
+        try {
+            xads.getXAConnection(user, password);
+            fail("expected failed shutdown");
+        } catch (SQLException e) {
+            assertSQLState(expectedSqlState, e);
         }
     }
             
@@ -255,136 +215,69 @@
         String expectedSqlState, String dbName, String user, String password) 
     throws SQLException
     {
-        if (usingEmbedded()) 
-        {
-            xads = J2EEDataSource.getXADataSource();
-            JDBCDataSource.setBeanProperty(xads, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
-            JDBCDataSource.setBeanProperty(xads, "user", user);
-            JDBCDataSource.setBeanProperty(xads, "password", password);
-            try {
-                xads.getXAConnection();
-                fail("expected failed shutdown");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientXADataSource xads = 
-                (ClientXADataSource)J2EEDataSource.getXADataSource();
-            xads.setDatabaseName(dbName);
-            xads.setConnectionAttributes(
-                "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                xads.getXAConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedSqlState, e);
-            }
+        xads = J2EEDataSource.getXADataSource();
+        JDBCDataSource.setBeanProperty(xads, "shutdownDatabase", "shutdown");
+        JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(xads, "user", user);
+        JDBCDataSource.setBeanProperty(xads, "password", password);
+        try {
+            xads.getXAConnection();
+            fail("expected failed shutdown");
+        } catch (SQLException e) {
+            assertSQLState(expectedSqlState, e);
         }
     }
 
     protected void assertSystemShutdownOK(
         String dbName, String user, String password)
     throws SQLException {
-        if (usingEmbedded())
-        {
-            xads = J2EEDataSource.getXADataSource();
-            JDBCDataSource.setBeanProperty(
+        xads = J2EEDataSource.getXADataSource();
+        JDBCDataSource.setBeanProperty(
                 xads, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
-            JDBCDataSource.setBeanProperty(xads, "user", user);
-            JDBCDataSource.setBeanProperty(xads, "password", password);
-            try {
-                xads.getXAConnection();
-                fail("expected system shutdown resulting in XJ015 error");
-            } catch (SQLException e) {
-                // expect XJ015, system shutdown, on successful shutdown
-                assertSQLState("XJ015", e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientXADataSource xads = 
-                (ClientXADataSource)J2EEDataSource.getXADataSource();
-            // current client/server code interprets shutdown with an
-            // empty databaseName string as a system shutdown
-            xads.setDatabaseName(dbName);
-            // Client does not support *ds*.setShutdown(), use set Conn Attrs 
-            xads.setConnectionAttributes(
-                "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                xads.getXAConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                // expect XJ015 on successful shutdown
-                assertSQLState("XJ015", e);
-            }
+        JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(xads, "user", user);
+        JDBCDataSource.setBeanProperty(xads, "password", password);
+        try {
+            xads.getXAConnection();
+            fail("expected system shutdown resulting in XJ015 error");
+        } catch (SQLException e) {
+            // expect XJ015, system shutdown, on successful shutdown
+            assertSQLState("XJ015", e);
         }
     }
 
     protected void assertSystemShutdownFail(
         String expectedError, String dbName, String user, String password)
     throws SQLException {
-        if (usingEmbedded())
-        {
-            xads = J2EEDataSource.getXADataSource();
-            JDBCDataSource.setBeanProperty(
+        xads = J2EEDataSource.getXADataSource();
+        JDBCDataSource.setBeanProperty(
                 xads, "shutdownDatabase", "shutdown");
-            JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
-            JDBCDataSource.setBeanProperty(xads, "user", user);
-            JDBCDataSource.setBeanProperty(xads, "password", password);
-            try {
-                xads.getXAConnection();
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedError, e);
-            }
-        }
-        else if (usingDerbyNetClient())
-        {
-            ClientXADataSource xads = 
-                (ClientXADataSource)J2EEDataSource.getXADataSource();
-            // current client/server code interprets shutdown with an
-            // empty databaseName string as a system shutdown
-            xads.setDatabaseName(dbName);
-            // Client does not support *ds*.setShutdown(), use set Conn Attrs 
-            xads.setConnectionAttributes(
-                "shutdown=true;user=" + user + ";password=" + password);
-            try {
-                xads.getXAConnection(user, password);
-                fail("expected shutdown to fail");
-            } catch (SQLException e) {
-                assertSQLState(expectedError, e);
-            }
+        JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
+        JDBCDataSource.setBeanProperty(xads, "user", user);
+        JDBCDataSource.setBeanProperty(xads, "password", password);
+        try {
+            xads.getXAConnection();
+            fail("expected shutdown to fail");
+        } catch (SQLException e) {
+            assertSQLState(expectedError, e);
         }
     }
 
     public void assertConnectionFail(String dbName) throws SQLException {
-        // can't rely on junit framework automatic methods for they'll
-        // default the user / password which need to remain empty
+        xads = J2EEDataSource.getXADataSource();
+        // Reset to no user/password though client requires
+        // a valid name, so reset to the default
         if (usingDerbyNetClient())
-        {
-            ClientXADataSource xads = new ClientXADataSource();
-            xads.setDatabaseName(dbName);
-            try {
-                xads.getXAConnection();
-                fail("expected connection to fail");
-            } catch (SQLException e) {
-                assertSQLState("08004", e);
-            }
-        }
-        else if (usingEmbedded()) 
-        {
-            EmbeddedXADataSource xads = new EmbeddedXADataSource();
-            xads.setDatabaseName(dbName);
-            try {
-                xads.getXAConnection();
-                fail("expected connection to fail");
-            } catch (SQLException e) {
-                assertSQLState("08004", e);
-            }
+            JDBCDataSource.setBeanProperty(xads, "user", "APP");
+        else
+            JDBCDataSource.clearStringBeanProperty(xads, "user");
+        JDBCDataSource.clearStringBeanProperty(xads, "password");
+        JDBCDataSource.setBeanProperty(xads, "databaseName", dbName);
+        try {
+            xads.getXAConnection();
+            fail("expected connection to fail");
+        } catch (SQLException e) {
+            assertSQLState("08004", e);
         }
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java?view=diff&rev=530863&r1=530862&r2=530863
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java Fri Apr 20 10:32:34 2007
@@ -221,20 +221,14 @@
      */
     public static void shutdownDatabase(javax.sql.DataSource ds)
     {
-        // commenting out until such time as setShutdownDatabase is
-        // supported by client
-        //setBeanProperty(ds, "shutdownDatabase", "shutdown");
-        setBeanProperty(ds, "connectionAttributes", "shutdown=true");
+        setBeanProperty(ds, "shutdownDatabase", "shutdown");
         try {
             ds.getConnection();
             Assert.fail("Database failed to shut down");
         } catch (SQLException e) {
              BaseJDBCTestCase.assertSQLState("Database shutdown", "08006", e);
         } finally {
-            // here too, commenting out until setShutdownDatabase is 
-            // supported by client
-            //clearStringBeanProperty(ds, "shutdownDatabase");
-            clearStringBeanProperty(ds, "connectionAttributes");
+            clearStringBeanProperty(ds, "shutdownDatabase");
         }
     }
 }



Mime
View raw message