db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r614745 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
Date Thu, 24 Jan 2008 00:12:46 GMT
Author: djd
Date: Wed Jan 23 16:12:41 2008
New Revision: 614745

URL: http://svn.apache.org/viewvc?rev=614745&view=rev
Log:
Add checks to the JUnit utility methods in JDBC that process ResultSets to ensure that if
a ResultSet column is returned as SQL NULL then the ResultSetMetaData for the column allows
NULLs

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java?rev=614745&r1=614744&r2=614745&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java Wed Jan 23 16:12:41
2008
@@ -610,6 +610,8 @@
 			{
 				String s = rs.getString(col);
 				Assert.assertEquals(s == null, rs.wasNull());
+                if (rs.wasNull())
+                    assertResultColumnNullable(rsmd, col);
 			}
 			rows++;
 		}
@@ -620,6 +622,22 @@
         
         return rows;
 	}
+    
+    /**
+     * Assert that a column is nullable in its ResultSetMetaData.
+     * Used when a utility method checking the contents of a
+     * ResultSet sees a NULL value. If the value is NULL then
+     * the column's definition in ResultSetMetaData must allow NULLs
+     * (or not disallow NULLS).
+     * @param rsmd Metadata of the ResultSet
+     * @param col Position of column just fetched that was NULL.
+     * @throws SQLException Error accessing meta data
+     */
+    private static void assertResultColumnNullable(ResultSetMetaData rsmd, int col)
+    throws SQLException
+    {
+        Assert.assertFalse(rsmd.isNullable(col) == ResultSetMetaData.columnNoNulls); 
+    }
 	
     /**
      * Takes a result set and an array of expected colum names (as
@@ -967,6 +985,10 @@
                     ":\n    Expected: >" + expected +
                     "<\n    Found:    >" + found + "<");
             }
+            
+            if (rs.wasNull())
+                assertResultColumnNullable(rsmd, i+1);
+
         }
     }
     
@@ -1086,6 +1108,8 @@
                 } else {
                     row.add(rs.getObject(i));
                 }
+                if (rs.wasNull())
+                    assertResultColumnNullable(rsmd, i);
             }
             actual.add(row);
         }



Mime
View raw message