db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r385157 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/TestDbMetaData.out tests/jdbc4/TestDbMetaData.java
Date Sat, 11 Mar 2006 20:40:04 GMT
Author: kahatlen
Date: Sat Mar 11 12:40:02 2006
New Revision: 385157

URL: http://svn.apache.org/viewcvs?rev=385157&view=rev
Log:
DERBY-970 (partial): Add new metadata methods to network client driver

Attaching patch derby-970-part1-v1.diff. This patch makes the JDBC4
database metadata test (jdbc4/TestDbMetaData.java) also test the
client driver. Currently, none of the new metadata calls are
implemented on the client, some of them even throw
AbstractMethodError. The canon is updated accordingly.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out?rev=385157&r1=385156&r2=385157&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
Sat Mar 11 12:40:02 2006
@@ -44,3 +44,37 @@
 SYSSTAT,null
 TABLE_SCHEM,TABLE_CATALOG
 APP,null
+supportsStoredFunctionsUsingCallSyntax():
+FAIL -- unexpected exception
+SQLSTATE(0A000):java.sql.SQLException: 0A000.S : [0] supportsStoredFunctionsUsingCallSyntax
()
+Caused by: org.apache.derby.client.am.SqlException: 0A000.S : [0] supportsStoredFunctionsUsingCallSyntax
()
+	... 4 more
+autoCommitFailureClosesAllResultSets():
+FAIL -- unexpected exception
+SQLSTATE(0A000):java.sql.SQLException: 0A000.S : [0] autoCommitFailureClosesAllResultSets
()
+Caused by: org.apache.derby.client.am.SqlException: 0A000.S : [0] autoCommitFailureClosesAllResultSets
()
+	... 4 more
+providesQueryObjectGenerator():
+FAIL -- unexpected exception
+SQLSTATE(0A000):java.sql.SQLException: 0A000.S : [0] providesQueryObjectGenerator ()
+Caused by: org.apache.derby.client.am.SqlException: 0A000.S : [0] providesQueryObjectGenerator
()
+	... 4 more
+getRowIdLifetime():
+FAIL -- unexpected exception
+SQLSTATE(0A000):java.sql.SQLException: 0A000.S : [0] getRowIdLifetime ()
+Caused by: org.apache.derby.client.am.SqlException: 0A000.S : [0] getRowIdLifetime ()
+	... 4 more
+getClientInfoProperties():
+FAIL -- unexpected exception
+SQLSTATE(0A000):java.sql.SQLException: 0A000.S : [0] getClientInfoProperties ()
+Caused by: org.apache.derby.client.am.SqlException: 0A000.S : [0] getClientInfoProperties
()
+	... 4 more
+getFunctionParameters():
+java.lang.AbstractMethodError
+getClientInfoProperties():
+java.lang.AbstractMethodError
+getSchemas():
+FAIL -- unexpected exception
+SQLSTATE(0A000):java.sql.SQLException: 0A000.S : [0] getSchemas (String, String)
+Caused by: org.apache.derby.client.am.SqlException: 0A000.S : [0] getSchemas (String, String)
+	... 4 more

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java?rev=385157&r1=385156&r2=385157&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
Sat Mar 11 12:40:02 2006
@@ -31,71 +31,127 @@
 import org.apache.derby.tools.ij;
 
 /**
- * Test of database meta-data for new methods in jdbc 30. This program simply calls
- * each of the new meta-data methods in jdbc30, one by one, and prints the results.
- *
- * @author mamta
+ * Test of database metadata for new methods in JDBC 40.
  */
-
 public class TestDbMetaData { 
 
 	public static void main(String[] args) {
-		DatabaseMetaData met;
-		Connection con;
-		Statement  s;
-    
 		try
 		{
-            // Using this for now instead of ij because ij.startJBMS()
-            // returns null for classes built against JDK 1.6
-            con = new TestConnection().createEmbeddedConnection();
-
-			con.setAutoCommit(true); // make sure it is true
-
-			s = con.createStatement();
-            
-			met = con.getMetaData();
-
-            if ( ! met.supportsStoredFunctionsUsingCallSyntax() ) {
-                throw new Exception("FAIL: supportsStoredFunctionsUsingCallSyntax() " +
-                    "should return true");
+            // Using TestConnection for now instead of ij because
+            // ij.startJBMS() returns null for classes built against
+            // JDK 1.6
+            runTests(new TestConnection().createEmbeddedConnection());
+            runTests(new TestConnection().createClientConnection());
+        }
+        catch (SQLException e) {
+            dumpSQLExceptions(e);
+        }
+        catch (Throwable e) {
+            System.out.println("FAIL -- unexpected exception:");
+            e.printStackTrace(System.out);
+        }
+    }
+
+    // Run all the tests.
+    private static void runTests(Connection con) throws Exception {
+        testDatabaseMetaDataMethods(con);
+    }
+
+    // Simply call each new metadata method and print the result.
+    private static void testDatabaseMetaDataMethods(Connection con)
+        throws Exception
+    {
+        con.setAutoCommit(true); // make sure it is true
+        Statement s = con.createStatement();
+        DatabaseMetaData met = con.getMetaData();
+
+        try {
+            if (!met.supportsStoredFunctionsUsingCallSyntax()) {
+                System.out.println
+                    ("FAIL: supportsStoredFunctionsUsingCallSyntax() " +
+                     "should return true");
             }
-            
-            if ( met.autoCommitFailureClosesAllResultSets() ) {
-                throw new Exception("FAIL: autoCommitFailureClosesAllResultSets() " +
-                    "should return false");
+        } catch (SQLException e) {
+            // TODO: remove try/catch once method is implemented!
+            System.out.println("supportsStoredFunctionsUsingCallSyntax():");
+            dumpSQLExceptions(e);
+        }
+
+        try {
+            if (met.autoCommitFailureClosesAllResultSets()) {
+                System.out.println
+                    ("FAIL: autoCommitFailureClosesAllResultSets() " +
+                     "should return false");
             }
-            
-            if ( met.providesQueryObjectGenerator() ) {
-                throw new Exception("FAIL: providesQueryObjectGenerator() should " +
-                    "return false");
+        } catch (SQLException e) {
+            // TODO: remove try/catch once method is implemented!
+            System.out.println("autoCommitFailureClosesAllResultSets():");
+            dumpSQLExceptions(e);
+        }
+
+        try {
+            if (met.providesQueryObjectGenerator()) {
+                System.out.println
+                    ("FAIL: providesQueryObjectGenerator() should " +
+                     "return false");
             }
-            
+        } catch (SQLException e) {
+            // TODO: remove try/catch once method is implemented!
+            System.out.println("providesQueryObjectGenerator():");
+            dumpSQLExceptions(e);
+        }
+
+        try {
             RowIdLifetime lifetime = met.getRowIdLifetime();
-            if ( lifetime != RowIdLifetime.ROWID_UNSUPPORTED ) {
-                throw new Exception("FAIL: getRowIdLifetime() should return " +
-                    "ROWID_UNSUPPORTED, but got " + lifetime );
+            if (lifetime != RowIdLifetime.ROWID_UNSUPPORTED) {
+                System.out.println("FAIL: getRowIdLifetime() should return " +
+                                   "ROWID_UNSUPPORTED, but got " + lifetime);
             }
+        } catch (SQLException e) {
+            // TODO: remove try/catch once method is implemented!
+            System.out.println("getRowIdLifetime():");
+            dumpSQLExceptions(e);
+        }
 
+        try {
 			checkEmptyRS(met.getClientInfoProperties());
+        } catch (SQLException e) {
+            // TODO: remove try/catch once method is implemented!
+            System.out.println("getClientInfoProperties():");
+            dumpSQLExceptions(e);
+        }
+
+        // Create some functions in the default schema (app) to make
+        // the output from getFunctions() and getFunctionParameters
+        // more interesting
+        s.execute("CREATE FUNCTION DUMMY1 ( X SMALLINT ) RETURNS SMALLINT "+
+                  "PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL "+
+                  "NAME 'java.some.func'");
+        s.execute("CREATE FUNCTION DUMMY2 ( X INTEGER, Y SMALLINT ) RETURNS"+
+                  " INTEGER PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA "+
+                  "EXTERNAL NAME 'java.some.func'");
+        s.execute("CREATE FUNCTION DUMMY3 ( X VARCHAR(16), Y INTEGER ) "+
+                  "RETURNS VARCHAR(16) PARAMETER STYLE JAVA NO SQL LANGUAGE"+
+                  " JAVA EXTERNAL NAME 'java.some.func'");
+        s.execute("CREATE FUNCTION DUMMY4 ( X VARCHAR(128), Y INTEGER ) "+
+                  "RETURNS INTEGER PARAMETER STYLE JAVA NO SQL LANGUAGE "+
+                  "JAVA EXTERNAL NAME 'java.some.func'");
 
-			// Create some functions in the default schema (app) to make the output
-			// from getFunctions() and getFunctionParameters more interesting
-			s.execute("CREATE FUNCTION DUMMY1 ( X SMALLINT ) RETURNS SMALLINT "+
-					  "PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL "+
-					  "NAME 'java.some.func'");
-			s.execute("CREATE FUNCTION DUMMY2 ( X INTEGER, Y SMALLINT ) RETURNS"+
-					  " INTEGER PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA "+
-					  "EXTERNAL NAME 'java.some.func'");
-			s.execute("CREATE FUNCTION DUMMY3 ( X VARCHAR(16), Y INTEGER ) "+
-					  "RETURNS VARCHAR(16) PARAMETER STYLE JAVA NO SQL LANGUAGE"+
-					  " JAVA EXTERNAL NAME 'java.some.func'");
-			s.execute("CREATE FUNCTION DUMMY4 ( X VARCHAR(128), Y INTEGER ) "+
-					  "RETURNS INTEGER PARAMETER STYLE JAVA NO SQL LANGUAGE "+
-					  "JAVA EXTERNAL NAME 'java.some.func'");
-
+        try {
 			checkEmptyRS(met.getFunctionParameters(null,null,null,null));
+        } catch (SQLException e) {
+            // TODO: remove try/catch once method is implemented!
+            System.out.println("getFunctionParameters():");
+            dumpSQLExceptions(e);
+        } catch (AbstractMethodError ame) {
+            // TODO: No implementation on client yet, so catch
+            // AbstractMethodError for now. Remove when implemented.
+            System.out.println("getFunctionParameters():");
+            ame.printStackTrace(System.out);
+        }
 
+        try {
 			// Any function in any schema in any catalog
 			dumpRS(met.getFunctions(null, null, null));
 			// Any function in any schema in "Dummy
@@ -111,6 +167,18 @@
 			// NO catalog (none)
 			checkEmptyRS(met.getFunctions("", "", null));
             
+        } catch (SQLException e) {
+            // TODO: remove try/catch once method is implemented!
+            System.out.println("getFunctions():");
+            dumpSQLExceptions(e);
+        } catch (AbstractMethodError ame) {
+            // TODO: No implementation on client yet, so catch
+            // AbstractMethodError for now. Remove when implemented.
+            System.out.println("getClientInfoProperties():");
+            ame.printStackTrace(System.out);
+        }
+
+        try {
             // 
             // Test the new getSchemas() with no schema qualifiers
             //
@@ -131,19 +199,16 @@
             // set when a schema is passed with no match
             //
             checkEmptyRS(met.getSchemas(null, "BLAH"));
-        
-			s.close();
+        } catch (SQLException e) {
+            // TODO: remove try/catch once method is implemented!
+            System.out.println("getSchemas():");
+            dumpSQLExceptions(e);
+        }
+
+        s.close();
 
-			con.close();
+        con.close();
 
-		}
-		catch (SQLException e) {
-			dumpSQLExceptions(e);
-		}
-		catch (Throwable e) {
-			System.out.println("FAIL -- unexpected exception:");
-			e.printStackTrace(System.out);
-		}
     }
 
 	static private void dumpSQLExceptions (SQLException se) {



Mime
View raw message