db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r378797 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/checkDataSource.out master/checkDataSource30.out tests/jdbcapi/checkDataSource.java tests/jdbcapi/checkDataSource30.java
Date Sat, 18 Feb 2006 23:53:29 GMT
Author: djd
Date: Sat Feb 18 15:53:27 2006
New Revision: 378797

URL: http://svn.apache.org/viewcvs?rev=378797&view=rev
Log:
DERBY-434 DERBY-1009 DERBY-435
 Remove static check methods with duplicated code in instance methods,
 have the Java procedure call the instance method for the connection checks
 on the nested connection.
 Have the checkDataSource30 procedure nested connection checks use checkDataSource30 as
 the object for the instance method, adds the holdability and savepoint tests for checkDataSource30.
 Add test of the return of ResultSet.getStatement to expose DERBY-1009.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out?rev=378797&r1=378796&r2=378797&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
Sat Feb 18 15:53:27 2006
@@ -2,6 +2,13 @@
   isolation level 2
   auto commit     false
   read only       false
+setTypeMap(EMPTY_MAP) - ok
+setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
+setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
+method calls on a closed connection
+Nested <closedconn>.close() no error
+Nested <closedconn>.createStatement() 08003 - No current connection.
+Nested <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Running connection checks on DriverManager 
   isolation level 2
   auto commit     true
@@ -77,6 +84,8 @@
   auto commit     true
   read only       false
   has warnings    false
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -97,6 +106,13 @@
   isolation level 2
   auto commit     false
   read only       false
+setTypeMap(EMPTY_MAP) - ok
+setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
+setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
+method calls on a closed connection
+Nested <closedconn>.close() no error
+Nested <closedconn>.createStatement() 08003 - No current connection.
+Nested <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Running connection checks on DriverManager 
   isolation level 2
   auto commit     true
@@ -163,6 +179,8 @@
   auto commit     true
   read only       false
   has warnings    false
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -176,6 +194,8 @@
   auto commit     true
   read only       false
   has warnings    false
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -189,6 +209,8 @@
   isolation level 2
   auto commit     false
   read only       false
+Global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -201,6 +223,8 @@
   isolation level 2
   auto commit     false
   read only       false
+Global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -214,6 +238,8 @@
   auto commit     true
   read only       false
   has warnings    false
+Switch to local XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Switch to local XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -227,6 +253,8 @@
   auto commit     true
   read only       false
   has warnings    false
+Switch to local XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Switch to local XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -240,6 +268,8 @@
   auto commit     false
   read only       false
   has warnings    false
+Switch to global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Switch to global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -253,6 +283,8 @@
   auto commit     false
   read only       false
   has warnings    false
+Switch to global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Switch to global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out?rev=378797&r1=378796&r2=378797&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
Sat Feb 18 15:53:27 2006
@@ -1,7 +1,17 @@
+Running JDBC 3.0 connection checks on Nested
+  holdability     true
+JDBC 3.0 savepoint OK
 Running connection checks on Nested
   isolation level 2
   auto commit     false
   read only       false
+setTypeMap(EMPTY_MAP) - ok
+setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
+setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
+method calls on a closed connection
+Nested <closedconn>.close() no error
+Nested <closedconn>.createStatement() 08003 - No current connection.
+Nested <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Running JDBC 3.0 connection checks on DriverManager 
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
@@ -95,6 +105,8 @@
   auto commit     true
   read only       false
   has warnings    false
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -111,10 +123,20 @@
 IDENTITY_VAL_LOCAL=3
 End testPoolReset XADataSource
 ERROR XJ015: Derby system shutdown.
+Running JDBC 3.0 connection checks on Nested
+  holdability     true
+JDBC 3.0 savepoint OK
 Running connection checks on Nested
   isolation level 2
   auto commit     false
   read only       false
+setTypeMap(EMPTY_MAP) - ok
+setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
+setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
+method calls on a closed connection
+Nested <closedconn>.close() no error
+Nested <closedconn>.createStatement() 08003 - No current connection.
+Nested <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Running JDBC 3.0 connection checks on DriverManager 
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
@@ -199,6 +221,8 @@
   auto commit     true
   read only       false
   has warnings    false
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -215,6 +239,8 @@
   auto commit     true
   read only       false
   has warnings    false
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -231,6 +257,8 @@
   isolation level 2
   auto commit     false
   read only       false
+Global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -246,6 +274,8 @@
   isolation level 2
   auto commit     false
   read only       false
+Global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -262,6 +292,8 @@
   auto commit     true
   read only       false
   has warnings    false
+Switch to local XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Switch to local XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -278,6 +310,8 @@
   auto commit     true
   read only       false
   has warnings    false
+Switch to local XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Switch to local XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -294,6 +328,8 @@
   auto commit     false
   read only       false
   has warnings    false
+Switch to global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Switch to global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
@@ -310,6 +346,8 @@
   auto commit     false
   read only       false
   has warnings    false
+Switch to global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
+Switch to global XADataSource FAIL incorrect Statement object returned for ResultSet.getStatement
 setTypeMap(EMPTY_MAP) - ok
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?rev=378797&r1=378796&r2=378797&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
Sat Feb 18 15:53:27 2006
@@ -137,7 +137,7 @@
 
 	}
 
-	public checkDataSource() throws Exception {
+	public checkDataSource() {
 	}
 
 	protected void runTest(String[] args) throws Exception {
@@ -148,7 +148,12 @@
 
 		dmc.createStatement().executeUpdate("create table y(i int)");
 
-		dmc.createStatement().executeUpdate("create procedure checkConn2(in dsname varchar(20))
parameter style java language java modifies SQL Data external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.checkDataSource.checkNesConn'");
+		dmc.createStatement().executeUpdate(
+                "create procedure checkConn2(in dsname varchar(20)) " +
+                "parameter style java language java modifies SQL DATA " +
+                "external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi." +
+                this.getNestedMethodName() +
+                "'");
 		CallableStatement cs = dmc.prepareCall("call checkConn2(?)");
 		cs.setString(1,"Nested");
 		cs.execute();
@@ -785,6 +790,16 @@
 	protected CallableStatement internalCreateFloatCallForStateChecking(Connection conn, String
sql) throws SQLException {
 		return conn.prepareCall(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
 	}
+    
+    /**
+     * Return the Java class and method for the procedure
+     * for the nested connection test.
+     * checkDataSource 30 will override.
+     */
+    protected String getNestedMethodName()
+    {
+        return "checkDataSource.checkNesConn";
+    }
 
 	static String rsType(int type) {
 		switch (type) {
@@ -878,36 +893,9 @@
 
 	//calling checkConnection - for use in a procedure to get a nested connection.
 	public static void checkNesConn (String dsName) throws SQLException {
-		checkConnectionS(dsName, DriverManager.getConnection("jdbc:default:connection"));
-			
-	}
-
-	public static void checkConnectionS(String dsName, Connection conn) throws SQLException
{
-
-		System.out.println("Running connection checks on " + dsName);
-		
-		SecurityCheck.inspect(conn, "java.sql.Connection");
-		SecurityCheck.inspect(conn.getMetaData(), "java.sql.DatabaseMetaData");
-
-		//System.out.println("  url             " + conn.getMetaData().getURL());
-		System.out.println("  isolation level " + conn.getTransactionIsolation());
-		System.out.println("  auto commit     " + conn.getAutoCommit());
-		System.out.println("  read only       " + conn.isReadOnly());
-
-		// when 4729 is fixed, remove the startsWith() clause
-		if (dsName.endsWith("DataSource") && !dsName.startsWith("Global"))
-			System.out.println("  has warnings    " + (conn.getWarnings() != null));
-
-		checkStatementS(conn, conn.createStatement());
-		checkStatementS(conn, conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY));
-
-		Connection c1 = conn.getMetaData().getConnection();
-		if (c1 != conn)
-			System.out.println("FAIL incorrect connection object returned for DatabaseMetaData.getConnection()");
-
-		checkConnectionPreCloseS(dsName, conn);
-		conn.close();
-	}
+        Connection conn = DriverManager.getConnection("jdbc:default:connection");
+        new checkDataSource().checkConnection(dsName, conn);			
+    }
 
 	public void checkConnection(String dsName, Connection conn) throws SQLException {
 
@@ -926,8 +914,8 @@
 			System.out.println("  has warnings    " + (conn.getWarnings() != null));
 
 		Statement s1 = conn.createStatement();
-		checkStatement(conn, s1);
-		checkStatement(conn, conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY));
+		checkStatement(dsName, conn, s1);
+		checkStatement(dsName, conn, conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY));
 
 		Connection c1 = conn.getMetaData().getConnection();
 		if (c1 != conn)
@@ -1201,20 +1189,6 @@
         }
         xaConns.clear();
     }
-    
-	protected static void checkConnectionPreCloseS(String dsName, Connection conn) throws SQLException
{
-		if (dsName.endsWith("DataSource")) {
-
-			// see if setting the state is carried over to any future connection from the
-			// data source object.
-			try {
-				conn.setReadOnly(true);
-			} catch (SQLException sqle) {
-				// cannot set read-only in an active transaction, & sometimes
-				// connections are active at this point.
-			}
-		}
-	}
 
 	protected void checkConnectionPreClose(String dsName, Connection conn) throws SQLException
{
 		if (dsName.endsWith("DataSource")) {
@@ -1230,26 +1204,10 @@
 		}
 	}
 
-	protected static void checkStatementS(Connection conn, Statement s) throws SQLException
{
+	protected void checkStatement(String dsName, Connection conn, Statement s) throws SQLException
{
 
-		SecurityCheck.inspect(s, "java.sql.Statement");
-		
-		Connection c1 = s.getConnection();
-		if (c1 != conn)
-			System.out.println("FAIL incorrect connection object returned for Statement.getConnection()");
-
-		s.addBatch("insert into y values 1");
-		s.addBatch("insert into y values 2,3");
-		int[] states = s.executeBatch();
-		if (states[0] != 1)
-			System.out.println("FAIL invalid update count for first batch statement");
-		if (states[1] != 2)
-			System.out.println("FAIL invalid update count for second batch statement");
+        SecurityCheck.inspect(s, "java.sql.Statement");
 
-		s.close();
-	}
-	protected void checkStatement(Connection conn, Statement s) throws SQLException {
-		
 		Connection c1 = s.getConnection();
 		if (c1 != conn)
 			System.out.println("FAIL incorrect connection object returned for Statement.getConnection()");
@@ -1262,6 +1220,10 @@
 		if (states[1] != 2)
 			System.out.println("FAIL invalid update count for second batch statement");
 
+        ResultSet rs = s.executeQuery("VALUES 1");
+        if (rs.getStatement() != s)
+            System.out.println(dsName + " FAIL incorrect Statement object returned for ResultSet.getStatement");
+        rs.close();
 		s.close();
 	}
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java?rev=378797&r1=378796&r2=378797&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
Sat Feb 18 15:53:27 2006
@@ -22,6 +22,7 @@
 
 import java.sql.CallableStatement;
 import java.sql.Connection;
+import java.sql.DriverManager;
 import java.sql.ParameterMetaData;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -68,7 +69,7 @@
 	}
 
 
-	public checkDataSource30() throws Exception {
+	public checkDataSource30() {
 	}
 
 	public void checkConnection(String dsName, Connection conn) throws SQLException {
@@ -413,4 +414,23 @@
 		}
 		System.out.flush();
 	}
+    
+    /**
+     * Perform connection checks on the default connection
+     * using checkDataSourc30.
+     */
+    public static void checkNesConn30(String dsName) throws SQLException {
+        Connection conn = DriverManager.getConnection("jdbc:default:connection");
+        new checkDataSource30().checkConnection(dsName, conn);            
+    }
+
+    
+    /**
+     * USe checkNesConn30 for the procedure, will
+     * cause the 30 checks to be invoked as well. 
+     */
+    protected String getNestedMethodName()
+    {
+        return "checkDataSource30.checkNesConn30";
+    }
 }



Mime
View raw message