db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From banda...@apache.org
Subject svn commit: r219980 - in /incubator/derby/code/branches/10.1/java: client/org/apache/derby/client/am/ client/org/apache/derby/jdbc/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/ testing/org/apache/derbyTesting/functionTests/tests...
Date Thu, 21 Jul 2005 01:52:50 GMT
Author: bandaram
Date: Wed Jul 20 18:52:49 2005
New Revision: 219980

URL: http://svn.apache.org/viewcvs?rev=219980&view=rev
Log:
Merge trunk change 209498 to 10.1 branch.

DERBY-406 - Sets the username to start with the default value ("APP")
DERBY-410 - Sets the server name to start with the default value ("localhost")
DERBY-409 - Adds a semi-colon in the connection class to avoid databasenames like myDBcreate=true
resulting from no dividing semi-colon.

Submitted by Satheesh Bandaram (satheesh@sourcery.org)

Modified:
    incubator/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
    incubator/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
    incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dataSourcePermissions_net.out
    incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java

Modified: incubator/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java?rev=219980&r1=219979&r2=219980&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
(original)
+++ incubator/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
Wed Jul 20 18:52:49 2005
@@ -155,7 +155,8 @@
         user_ = user;
 
         // Extract common properties.
-        databaseName_ = dataSource.getDatabaseName() + dataSource.getConnectionAttributes();
+        // Derby-409 fix
+        databaseName_ = dataSource.getDatabaseName() + ";" + dataSource.getConnectionAttributes();
         retrieveMessageText_ = dataSource.getRetrieveMessageText();
 
         loginTimeout_ = dataSource.getLoginTimeout();

Modified: incubator/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?rev=219980&r1=219979&r2=219980&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
(original)
+++ incubator/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
Wed Jul 20 18:52:49 2005
@@ -136,8 +136,9 @@
 
     // ---------------------------- serverName -----------------------------------
     //
-    //
-    protected String serverName = null;
+    // Derby-410 fix.
+    protected String serverName = propertyDefault_serverName;
+    public final static String propertyDefault_serverName = "localhost";
     public final static String propertyKey_serverName = "serverName";
 
     // serverName is not permitted in a properties object
@@ -153,7 +154,8 @@
     // Each data source implementation subclass will maintain it's own <code>password</code>
property.
     // This password property may or may not be declared transient, and therefore may be
serialized
     // to a file in clear-text, care must taken by the user to prevent security breaches.
-    protected String user = null;
+    // Derby-406 fix
+    protected String user = propertyDefault_user;
     public final static String propertyKey_user = "user";
     public final static String propertyDefault_user = "APP";
 

Modified: incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dataSourcePermissions_net.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dataSourcePermissions_net.out?rev=219980&r1=219979&r2=219980&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dataSourcePermissions_net.out
(original)
+++ incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dataSourcePermissions_net.out
Wed Jul 20 18:52:49 2005
@@ -7,7 +7,7 @@
 Checking connections with DataSource
 EXPECTED SHUTDOWN DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'wombat'
shutdown.
 data source with no default user
-EXPECTED CONNFAIL null userid not supported
+EXPECTED CONNFAIL Connection authorization failure occurred.  Reason: userid invalid.
 EXPECTED CONNFAIL Connection authorization failure occurred.  Reason: userid invalid.
 DS connected as EDWARD
 DS connected as FRANCES
@@ -22,7 +22,7 @@
 EXPECTED SHUTDOWN DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'wombat'
shutdown.
 Checking connections with ConnectionPoolDataSource
 ConnectionPoolDataSource with no default user
-EXPECTED CONNFAIL null userid not supported
+EXPECTED CONNFAIL Connection authorization failure occurred.  Reason: userid invalid.
 EXPECTED CONNFAIL Connection authorization failure occurred.  Reason: userid invalid.
 CP connected as EDWARD
 CP connected as FRANCES
@@ -39,4 +39,23 @@
 PASS: Message text not retrieved
 ** checkMessageText() with retrieveMessageText= true
 PASS: Message Text retrieved properly
+Begin connection attribute tests
+One attribute test: PASS.
+Another different attribute: PASS.
+Two Attributes: PASS.
+End connection attribute tests
+Begin username and password tests
+Normal test: PASS.
+No username or password, only attributes test: PASS.
+Bogus username and password, good attributes test: PASS.
+Username, password attribute test: PASS.
+Password, username attribute test: PASS.
+Turning off authentication
+EXPECTED SHUTDOWN DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'wombat'
shutdown.
+Username, no password test: PASS.
+No username, password test: PASS.
+No username, no password test: PASS.
+Turning on authentication
+EXPECTED SHUTDOWN DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'wombat'
shutdown.
+End username and password tests
 Completed dataSourcePermissions_net

Modified: incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java?rev=219980&r1=219979&r2=219980&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java
(original)
+++ incubator/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java
Wed Jul 20 18:52:49 2005
@@ -185,9 +185,14 @@
 		if (TestUtil.isJCCFramework())
 		{
 			attrs.setProperty("driverType","4");
+            /**
+             * As per the fix of derby-410
+             * servername should now default to localhost 
+             */
+            attrs.setProperty("serverName","localhost");
 		}
 
-		attrs.setProperty("serverName","localhost");
+
 		attrs.setProperty("portNumber","20000");
 		//attrs.setProperty("retrieveMessagesFromServerOnGetMessage","true");
 		return attrs;
@@ -246,6 +251,12 @@
 	{
 		testRetrieveMessageText();
 		testDescription();
+        
+        //Added for Derby-409
+        testConnectionAttributes();
+        
+        //Added for Derby-406
+        allUsernameAndPasswordTests();
 	}
 
 	/**
@@ -361,7 +372,129 @@
 
 		}
 	}
-
+       
+    /**
+     * Added for Derby-409
+     * 
+     * Designed to test combinations of attributes to insure that 
+     * no exceptions are thrown. 
+     */
+    public void testConnectionAttributes() {
+        try {
+            System.out.println("Begin connection attribute tests");
+            testDataSourceConnection("One attribute test: ", 
+                    "EDWARD", "noodle", "create=true");
+            testDataSourceConnection("Another different attribute: ", 
+                    "EDWARD", "noodle", "tracefile=trace.out"); 
+            testDataSourceConnection("Two Attributes: ", 
+                    "EDWARD", "noodle", "create=true;tracefile=trace.out");
+            System.out.println("End connection attribute tests");
+        }
+        catch (Exception e)
+        {
+            System.out.println("FAIL: testSetConnectionAttributes() Unexpected Exception
" + e.getMessage());
+            e.printStackTrace(System.out);
+        }
+    }
+    
+    /**
+     * Added for Derby-406
+     * 
+     * Tests DataSource with a number of different username/password
+     * input combinations.
+     */
+    public void allUsernameAndPasswordTests() {
+        
+        try {
+            System.out.println("Begin username and password tests");
+            
+            testDataSourceConnection("Normal test: ", "EDWARD", "noodle", null);
+            
+            testDataSourceConnection("No username or password, only attributes test: ", 
+                    null, null, "user=EDWARD;password=noodle");
+            
+            testDataSourceConnection("Bogus username and password, good attributes test:
", 
+                    "Whatis", "theMatrix?", "user=EDWARD;password=noodle");
+            
+            testDataSourceConnection("Username, password attribute test: ", 
+                    "EDWARD", null, "password=noodle");
+            
+            testDataSourceConnection("Password, username attribute test: ", 
+                    null, "noodle", "user=EDWARD");
+            
+            System.out.println("Turning off authentication");
+            DataSource ds = getDS("wombat", "EDWARD", "noodle");
+            Connection conn = ds.getConnection();
+            CallableStatement cs = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?,
?)");
+            cs.setString(1, "derby.connection.requireAuthentication");
+            cs.setString(2, "false");
+            cs.execute();
+            cs.close();
+            cs = null;
+            conn.close();
+            //We have to shut down before the changes will take effect.
+            shutdown();
+            start();
+            
+            testDataSourceConnection("Username, no password test: ", 
+                    "EDWARD", null, null);
+            
+            testDataSourceConnection("No username, password test: ", 
+                    null, "noodle", null);
+            
+            testDataSourceConnection("No username, no password test: ", 
+                    null, null, null);
+            
+            System.out.println("Turning on authentication");
+            ds = getDS("wombat", "EDWARD", "noodle");
+            conn = ds.getConnection();
+            cs = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)");
+            cs.setString(1, "derby.connection.requireAuthentication");
+            cs.setString(2, "true");
+            cs.execute();
+            cs.close();
+            cs = null;
+            conn.close();
+            shutdown();
+            start();
+            
+            System.out.println("End username and password tests");
+        }
+        catch (Exception e)
+        {
+            System.out.println("FAIL: allUsernameAndPasswordTests. Unexpected Exception "
+ e.getMessage());
+            e.printStackTrace(System.out);
+        }
+    }
+    
+    /**
+     * A method that attempts to retrieve the connection via a datasource
+     * with the given user, password and connection attributes.
+     * 
+     * @param testType A string description of the type of test
+     * @param username The user
+     * @param password The Password
+     * @param attributes A string to be added to a properties object. A
+     * null string means null Property object.
+     * @throws SQLException
+     */
+    public void testDataSourceConnection(String testType, String username, String password,
String attributes) throws SQLException {
+        try {
+            System.out.print(testType);
+            Properties props = null;
+            if (attributes != null) {
+                props = new Properties();
+                props.put("ConnectionAttributes", attributes);
+            }
+            DataSource ds = getDS("wombat", username, password, props);
+            Connection conn = ds.getConnection();
+            conn.close();
+            System.out.println("PASS.");
+        } catch (SQLException e) {
+            System.out.println("FAIL. Unexpected Exception: ");
+            e.printStackTrace(System.out);
+        }
+    }
 }
 
 



Mime
View raw message