db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1055872 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
Date Thu, 06 Jan 2011 13:43:14 GMT
Author: rhillegas
Date: Thu Jan  6 13:43:14 2011
New Revision: 1055872

URL: http://svn.apache.org/viewvc?rev=1055872&view=rev
Log:
DERBY-4869: Make new getObject() overloads return null for null values; also, rework the getObject()
methods to remove the SuppressWarnings annotation.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Test.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java?rev=1055872&r1=1055871&r2=1055872&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java Thu
Jan  6 13:43:14 2011
@@ -331,7 +331,6 @@ public class CallableStatement40 extends
     //
     ////////////////////////////////////////////////////////////////////
     
-    @SuppressWarnings("unchecked")
     public <T> T getObject( int parameterIndex, Class<T> type )
         throws SQLException
     {
@@ -344,25 +343,31 @@ public class CallableStatement40 extends
         }
 
         try {
-            if ( String.class.equals( type ) ) { return (T) getString( parameterIndex );
}
-            else if ( BigDecimal.class.equals( type ) ) { return (T) getBigDecimal( parameterIndex
); }
-            else if ( Boolean.class.equals( type ) ) { return (T) Boolean.valueOf( getBoolean(parameterIndex
) ); }
-            else if ( Byte.class.equals( type ) ) { return (T) Byte.valueOf( getByte( parameterIndex
) ); }
-            else if ( Short.class.equals( type ) ) { return (T) Short.valueOf( getShort(
parameterIndex ) ); }
-            else if ( Integer.class.equals( type ) ) { return (T) Integer.valueOf( getInt(
parameterIndex ) ); }
-            else if ( Long.class.equals( type ) ) { return (T) Long.valueOf( getLong( parameterIndex
) ); }
-            else if ( Float.class.equals( type ) ) { return (T) Float.valueOf( getFloat(
parameterIndex ) ); }
-            else if ( Double.class.equals( type ) ) { return (T) Double.valueOf( getDouble(
parameterIndex ) ); }
-            else if ( Date.class.equals( type ) ) { return (T) getDate( parameterIndex );
}
-            else if ( Time.class.equals( type ) ) { return (T) getTime( parameterIndex );
}
-            else if ( Timestamp.class.equals( type ) ) { return (T) getTimestamp( parameterIndex
); }
-            else if ( Blob.class.equals( type ) ) { return (T) getBlob( parameterIndex );
}
-            else if ( Clob.class.equals( type ) ) { return (T) getClob( parameterIndex );
}
-            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { return (T) getBytes( parameterIndex ); }
+            Object   retval;
+            
+            if ( String.class.equals( type ) ) { retval = getString( parameterIndex ); }
+            else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( parameterIndex
); }
+            else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(parameterIndex
) ); }
+            else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( parameterIndex
) ); }
+            else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( parameterIndex
) ); }
+            else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt(
parameterIndex ) ); }
+            else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( parameterIndex
) ); }
+            else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( parameterIndex
) ); }
+            else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble(
parameterIndex ) ); }
+            else if ( Date.class.equals( type ) ) { retval = getDate( parameterIndex ); }
+            else if ( Time.class.equals( type ) ) { retval = getTime( parameterIndex ); }
+            else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( parameterIndex
); }
+            else if ( Blob.class.equals( type ) ) { retval = getBlob( parameterIndex ); }
+            else if ( Clob.class.equals( type ) ) { retval = getClob( parameterIndex ); }
+            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { retval = getBytes( parameterIndex ); }
             else
             {
-                return type.cast( getObject( parameterIndex ) );
+                retval = type.cast( getObject( parameterIndex ) );
             }
+
+            if ( wasNull() ) { retval = null; }
+
+            return type.cast( retval );
         }
         catch (ClassCastException e) {}
         

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java?rev=1055872&r1=1055871&r2=1055872&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java Thu Jan
 6 13:43:14 2011
@@ -262,7 +262,6 @@ public class NetResultSet40 extends NetR
     /**
      * Retrieve the column as an object of the desired type.
      */
-    @SuppressWarnings("unchecked")
     public  <T> T getObject( int columnIndex, Class<T> type )
             throws SQLException
     {
@@ -279,25 +278,31 @@ public class NetResultSet40 extends NetR
         }
 
         try {
-            if ( String.class.equals( type ) ) { return (T) getString( columnIndex ); }
-            else if ( BigDecimal.class.equals( type ) ) { return (T) getBigDecimal( columnIndex
); }
-            else if ( Boolean.class.equals( type ) ) { return (T) Boolean.valueOf( getBoolean(columnIndex
) ); }
-            else if ( Byte.class.equals( type ) ) { return (T) Byte.valueOf( getByte( columnIndex
) ); }
-            else if ( Short.class.equals( type ) ) { return (T) Short.valueOf( getShort(
columnIndex ) ); }
-            else if ( Integer.class.equals( type ) ) { return (T) Integer.valueOf( getInt(
columnIndex ) ); }
-            else if ( Long.class.equals( type ) ) { return (T) Long.valueOf( getLong( columnIndex
) ); }
-            else if ( Float.class.equals( type ) ) { return (T) Float.valueOf( getFloat(
columnIndex ) ); }
-            else if ( Double.class.equals( type ) ) { return (T) Double.valueOf( getDouble(
columnIndex ) ); }
-            else if ( Date.class.equals( type ) ) { return (T) getDate( columnIndex ); }
-            else if ( Time.class.equals( type ) ) { return (T) getTime( columnIndex ); }
-            else if ( Timestamp.class.equals( type ) ) { return (T) getTimestamp( columnIndex
); }
-            else if ( Blob.class.equals( type ) ) { return (T) getBlob( columnIndex ); }
-            else if ( Clob.class.equals( type ) ) { return (T) getClob( columnIndex ); }
-            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { return (T) getBytes( columnIndex ); }
+            Object   retval;
+            
+            if ( String.class.equals( type ) ) { retval = getString( columnIndex ); }
+            else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( columnIndex
); }
+            else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(columnIndex
) ); }
+            else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( columnIndex
) ); }
+            else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( columnIndex
) ); }
+            else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt(
columnIndex ) ); }
+            else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( columnIndex
) ); }
+            else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( columnIndex
) ); }
+            else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble(
columnIndex ) ); }
+            else if ( Date.class.equals( type ) ) { retval = getDate( columnIndex ); }
+            else if ( Time.class.equals( type ) ) { retval = getTime( columnIndex ); }
+            else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( columnIndex
); }
+            else if ( Blob.class.equals( type ) ) { retval = getBlob( columnIndex ); }
+            else if ( Clob.class.equals( type ) ) { retval = getClob( columnIndex ); }
+            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { retval = getBytes( columnIndex ); }
             else
             {
-                return type.cast( getObject( columnIndex ) );
+                retval = type.cast( getObject( columnIndex ) );
             }
+
+            if ( wasNull() ) { retval = null; }
+
+            return type.cast( retval );
         }
         catch (ClassCastException e) {}
         

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java?rev=1055872&r1=1055871&r2=1055872&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
Thu Jan  6 13:43:14 2011
@@ -334,7 +334,6 @@ public class EmbedCallableStatement40 ex
     //
     ////////////////////////////////////////////////////////////////////
     
-    @SuppressWarnings("unchecked")
     public <T> T getObject( int parameterIndex, Class<T> type )
         throws SQLException
     {
@@ -346,25 +345,31 @@ public class EmbedCallableStatement40 ex
         }
 
         try {
-            if ( String.class.equals( type ) ) { return (T) getString( parameterIndex );
}
-            else if ( BigDecimal.class.equals( type ) ) { return (T) getBigDecimal( parameterIndex
); }
-            else if ( Boolean.class.equals( type ) ) { return (T) Boolean.valueOf( getBoolean(parameterIndex
) ); }
-            else if ( Byte.class.equals( type ) ) { return (T) Byte.valueOf( getByte( parameterIndex
) ); }
-            else if ( Short.class.equals( type ) ) { return (T) Short.valueOf( getShort(
parameterIndex ) ); }
-            else if ( Integer.class.equals( type ) ) { return (T) Integer.valueOf( getInt(
parameterIndex ) ); }
-            else if ( Long.class.equals( type ) ) { return (T) Long.valueOf( getLong( parameterIndex
) ); }
-            else if ( Float.class.equals( type ) ) { return (T) Float.valueOf( getFloat(
parameterIndex ) ); }
-            else if ( Double.class.equals( type ) ) { return (T) Double.valueOf( getDouble(
parameterIndex ) ); }
-            else if ( Date.class.equals( type ) ) { return (T) getDate( parameterIndex );
}
-            else if ( Time.class.equals( type ) ) { return (T) getTime( parameterIndex );
}
-            else if ( Timestamp.class.equals( type ) ) { return (T) getTimestamp( parameterIndex
); }
-            else if ( Blob.class.equals( type ) ) { return (T) getBlob( parameterIndex );
}
-            else if ( Clob.class.equals( type ) ) { return (T) getClob( parameterIndex );
}
-            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { return (T) getBytes( parameterIndex ); }
+            Object   retval;
+            
+            if ( String.class.equals( type ) ) { retval = getString( parameterIndex ); }
+            else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( parameterIndex
); }
+            else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(parameterIndex
) ); }
+            else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( parameterIndex
) ); }
+            else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( parameterIndex
) ); }
+            else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt(
parameterIndex ) ); }
+            else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( parameterIndex
) ); }
+            else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( parameterIndex
) ); }
+            else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble(
parameterIndex ) ); }
+            else if ( Date.class.equals( type ) ) { retval = getDate( parameterIndex ); }
+            else if ( Time.class.equals( type ) ) { retval = getTime( parameterIndex ); }
+            else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( parameterIndex
); }
+            else if ( Blob.class.equals( type ) ) { retval = getBlob( parameterIndex ); }
+            else if ( Clob.class.equals( type ) ) { retval = getClob( parameterIndex ); }
+            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { retval = getBytes( parameterIndex ); }
             else
             {
-                return type.cast( getObject( parameterIndex ) );
+                retval = type.cast( getObject( parameterIndex ) );
             }
+
+            if ( wasNull() ) { retval = null; }
+
+            return type.cast( retval );
         }
         catch (ClassCastException e) {}
         

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java?rev=1055872&r1=1055871&r2=1055872&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java Thu Jan
 6 13:43:14 2011
@@ -250,7 +250,6 @@ public class EmbedResultSet40 extends or
     /**
      * Retrieve the column as an object of the desired type.
      */
-    @SuppressWarnings("unchecked")
     public  <T> T getObject( int columnIndex, Class<T> type )
             throws SQLException
     {
@@ -262,25 +261,31 @@ public class EmbedResultSet40 extends or
         }
 
         try {
-            if ( String.class.equals( type ) ) { return (T) getString( columnIndex ); }
-            else if ( BigDecimal.class.equals( type ) ) { return (T) getBigDecimal( columnIndex
); }
-            else if ( Boolean.class.equals( type ) ) { return (T) Boolean.valueOf( getBoolean(columnIndex
) ); }
-            else if ( Byte.class.equals( type ) ) { return (T) Byte.valueOf( getByte( columnIndex
) ); }
-            else if ( Short.class.equals( type ) ) { return (T) Short.valueOf( getShort(
columnIndex ) ); }
-            else if ( Integer.class.equals( type ) ) { return (T) Integer.valueOf( getInt(
columnIndex ) ); }
-            else if ( Long.class.equals( type ) ) { return (T) Long.valueOf( getLong( columnIndex
) ); }
-            else if ( Float.class.equals( type ) ) { return (T) Float.valueOf( getFloat(
columnIndex ) ); }
-            else if ( Double.class.equals( type ) ) { return (T) Double.valueOf( getDouble(
columnIndex ) ); }
-            else if ( Date.class.equals( type ) ) { return (T) getDate( columnIndex ); }
-            else if ( Time.class.equals( type ) ) { return (T) getTime( columnIndex ); }
-            else if ( Timestamp.class.equals( type ) ) { return (T) getTimestamp( columnIndex
); }
-            else if ( Blob.class.equals( type ) ) { return (T) getBlob( columnIndex ); }
-            else if ( Clob.class.equals( type ) ) { return (T) getClob( columnIndex ); }
-            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { return (T) getBytes( columnIndex ); }
+            Object   retval;
+            
+            if ( String.class.equals( type ) ) { retval = getString( columnIndex ); }
+            else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( columnIndex
); }
+            else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(columnIndex
) ); }
+            else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( columnIndex
) ); }
+            else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( columnIndex
) ); }
+            else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt(
columnIndex ) ); }
+            else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( columnIndex
) ); }
+            else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( columnIndex
) ); }
+            else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble(
columnIndex ) ); }
+            else if ( Date.class.equals( type ) ) { retval = getDate( columnIndex ); }
+            else if ( Time.class.equals( type ) ) { retval = getTime( columnIndex ); }
+            else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( columnIndex
); }
+            else if ( Blob.class.equals( type ) ) { retval = getBlob( columnIndex ); }
+            else if ( Clob.class.equals( type ) ) { retval = getClob( columnIndex ); }
+            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { retval = getBytes( columnIndex ); }
             else
             {
-                return type.cast( getObject( columnIndex ) );
+                retval = type.cast( getObject( columnIndex ) );
             }
+
+            if ( wasNull() ) { retval = null; }
+
+            return type.cast( retval );
         }
         catch (ClassCastException e) {}
         

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java?rev=1055872&r1=1055871&r2=1055872&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
Thu Jan  6 13:43:14 2011
@@ -40,6 +40,8 @@ public class CallableStatementTest  exte
 {
     /** Default callable statement used by the tests. */
     private CallableStatement cStmt = null;
+
+    private static  boolean _nullOutArgs;
     
     /**
      * Create a test with the given name.
@@ -646,8 +648,15 @@ public class CallableStatementTest  exte
         cs.registerOutParameter( param++, Types.TIMESTAMP );
         cs.registerOutParameter( param++, Types.VARCHAR );
         cs.registerOutParameter( param++, Types.VARBINARY );
+
+        _nullOutArgs = false;
+        cs.execute();
+        examineJDBC4_1extensions( new Wrapper41( cs ), _nullOutArgs );
+        
+        _nullOutArgs = true;
         cs.execute();
-        examineJDBC4_1extensions( new Wrapper41( cs ) );
+        examineJDBC4_1extensions( new Wrapper41( cs ), _nullOutArgs );
+        
         cs.close();
 
         ps = prepareStatement( conn, "drop procedure allTypesProc" );
@@ -743,21 +752,21 @@ public class CallableStatementTest  exte
      */
     public  static  void    allTypesProc
         (
-         long[] bigintarg,
+         Long[] bigintarg,
          Blob[] blobarg,
-         boolean[] booleanarg,
+         Boolean[] booleanarg,
          String[] chararg,
          byte[][] charforbitdataarg,
          Clob[] clobarg,
          Date[] datearg,
-         double[] doublearg,
-         double[] floatarg,
-         int[] intarg,
+         Double[] doublearg,
+         Double[] floatarg,
+         Integer[] intarg,
          String[] longvarchararg,
          byte[][] longvarcharforbitdataarg,
          BigDecimal[] numericarg,
-         float[] realarg,
-         short[] smallintarg,
+         Float[] realarg,
+         Integer[] smallintarg,
          Time[] timearg,
          Timestamp[] timestamparg,
          String[] varchararg,
@@ -769,26 +778,26 @@ public class CallableStatementTest  exte
         byte    intValue = (byte) 1;
         float   floatValue = 1.0F;
         String lobValue = "abc";
-        
-        bigintarg[0] = intValue;
-        blobarg[0] = new HarmonySerialBlob( BINARY_VALUE );
-        booleanarg[0] = true;
-        chararg[0] = stringValue;
-        charforbitdataarg[0] = BINARY_VALUE;
-        clobarg[0] = new HarmonySerialClob( lobValue );
-        datearg[0]= new Date( 761990400000L );
-        doublearg[0] = floatValue;
-        floatarg[0] = floatValue;
-        intarg[0] = intValue;
-        longvarchararg[0] = stringValue;
-        longvarcharforbitdataarg[0] =  BINARY_VALUE;
-        numericarg[0] = new BigDecimal( "1.0" );
-        realarg[0] = floatValue;
-        smallintarg[0] = intValue;
-        timearg[0] = new Time(TIME_VALUE);
-        timestamparg[0] = new Timestamp(TIMESTAMP_VALUE);
-        varchararg[0] = stringValue;
-        varcharforbitdataarg[0] = BINARY_VALUE;
+
+        bigintarg[0] = _nullOutArgs ? null : new Long( intValue );
+        blobarg[0] = _nullOutArgs ? null : new HarmonySerialBlob( BINARY_VALUE );
+        booleanarg[0] = _nullOutArgs ? null : Boolean.TRUE;
+        chararg[0] = _nullOutArgs ? null : stringValue;
+        charforbitdataarg[0] = _nullOutArgs ? null : BINARY_VALUE;
+        clobarg[0] = _nullOutArgs ? null : new HarmonySerialClob( lobValue );
+        datearg[0]= _nullOutArgs ? null : new Date( 761990400000L );
+        doublearg[0] = _nullOutArgs ? null : new  Double( floatValue );
+        floatarg[0] = _nullOutArgs ? null : new Double( floatValue );
+        intarg[0] = _nullOutArgs ? null : new Integer( intValue );
+        longvarchararg[0] = _nullOutArgs ? null : stringValue;
+        longvarcharforbitdataarg[0] =  _nullOutArgs ? null : BINARY_VALUE;
+        numericarg[0] = _nullOutArgs ? null : new BigDecimal( "1.0" );
+        realarg[0] = _nullOutArgs ? null : new Float( floatValue );
+        smallintarg[0] = _nullOutArgs ? null : new Integer( intValue );
+        timearg[0] = _nullOutArgs ? null : new Time(TIME_VALUE);
+        timestamparg[0] = _nullOutArgs ? null : new Timestamp(TIMESTAMP_VALUE);
+        varchararg[0] = _nullOutArgs ? null : stringValue;
+        varcharforbitdataarg[0] = _nullOutArgs ? null : BINARY_VALUE;
     }
 
     public  static  void    blobProc

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetTest.java?rev=1055872&r1=1055871&r2=1055872&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetTest.java
Thu Jan  6 13:43:14 2011
@@ -2069,10 +2069,21 @@ public class ResultSetTest  extends Wrap
         ps.executeUpdate();
         ps.close();
 
-        ps = prepareStatement( conn, "select * from allTypes" );
+        ps = prepareStatement
+            (
+             conn,
+             "insert into allTypes values " +
+             "( null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null )"
+             );
+        ps.executeUpdate();
+        ps.close();
+
+        ps = prepareStatement( conn, "select * from allTypes order by bigintCol" );
         ResultSet   rs = ps.executeQuery();
         rs.next();
-        examineJDBC4_1extensions( new Wrapper41( rs ) );
+        examineJDBC4_1extensions( new Wrapper41( rs ), false );
+        rs.next();
+        examineJDBC4_1extensions( new Wrapper41( rs ), true );
         rs.close();
         ps.close();
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Test.java?rev=1055872&r1=1055871&r2=1055872&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Test.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Test.java
Thu Jan  6 13:43:14 2011
@@ -66,7 +66,8 @@ public  class   Wrapper41Test   extends 
     //
     ///////////////////////////////////////////////////////////////////////
 
-    private Class   byteArrayClass;
+    private Class       _byteArrayClass;
+    private boolean _rowOfNulls;
 
     ///////////////////////////////////////////////////////////////////////
     //
@@ -79,7 +80,7 @@ public  class   Wrapper41Test   extends 
      *
      * @param name name of the test.
      */
-    public Wrapper41Test(String name) { super(name); }
+    public Wrapper41Test( String name ) { super( name ); }
 
     ///////////////////////////////////////////////////////////////////////
     //
@@ -87,11 +88,12 @@ public  class   Wrapper41Test   extends 
     //
     ///////////////////////////////////////////////////////////////////////
 
-    protected void examineJDBC4_1extensions( Wrapper41 wrapper ) throws Exception
+    protected void examineJDBC4_1extensions( Wrapper41 wrapper, boolean rowOfNulls ) throws
Exception
     {
-        println( "Vetting a " + wrapper.getWrappedObject().getClass().getName() );
+        println( "Vetting a " + wrapper.getWrappedObject().getClass().getName() + ". rowOfNulls
= " + rowOfNulls );
 
-        byteArrayClass = Class.forName( "[B" );
+        _byteArrayClass = Class.forName( "[B" );
+        _rowOfNulls = rowOfNulls;
 
         vetWrappedNull( wrapper );
         vetWrappedInteger( wrapper, 1, "BIGINTCOL" );
@@ -145,7 +147,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "1",
+             _rowOfNulls ? null : "1",
              new Class[] { String.class, BigDecimal.class, Byte.class, Short.class, Integer.class,
Long.class, Number.class, Object.class }
              );
         vetWrapperOK
@@ -153,7 +155,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "1.0",
+             _rowOfNulls ? null : "1.0",
              new Class[] { Float.class, Double.class }
              );
         vetWrapperOK
@@ -161,7 +163,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "true",
+             _rowOfNulls ? null : "true",
              new Class[] { Boolean.class }
              );
         
@@ -170,7 +172,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             new Class[] { Date.class, Time.class, Timestamp.class, Blob.class, Clob.class,
byteArrayClass, getClass() }
+             new Class[] { Date.class, Time.class, Timestamp.class, Blob.class, Clob.class,
_byteArrayClass, getClass() }
              );
     }
     private void    vetWrappedBlob( Wrapper41 wrapper ) throws Exception
@@ -180,8 +182,8 @@ public  class   Wrapper41Test   extends 
              wrapper,
              2,
              "BLOBCOL",
-             BINARY_VALUE,
-             new Class[] { Blob.class, Object.class, byteArrayClass, String.class,  }
+             _rowOfNulls ? null : BINARY_VALUE,
+             new Class[] { Blob.class, Object.class, _byteArrayClass, String.class,  }
              );
         
         vetNoWrapper
@@ -210,7 +212,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              3,
              "BOOLEANCOL",
-             "true",
+             _rowOfNulls ? null : "true",
              new Class[] { String.class, Boolean.class, Object.class }
              );
         vetWrapperOK
@@ -218,7 +220,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              3,
              "BOOLEANCOL",
-             "1",
+             _rowOfNulls ? null : "1",
              new Class[] { BigDecimal.class, Byte.class, Short.class, Integer.class, Long.class
}
              );
         vetWrapperOK
@@ -226,7 +228,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              3,
              "BOOLEANCOL",
-             "1.0",
+             _rowOfNulls ? null : "1.0",
              new Class[] { Float.class, Double.class }
              );
         
@@ -235,7 +237,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              3,
              "BOOLEANCOL",
-             new Class[] { Date.class, Time.class, Timestamp.class, Blob.class, Clob.class,
byteArrayClass, getClass() }
+             new Class[] { Date.class, Time.class, Timestamp.class, Blob.class, Clob.class,
_byteArrayClass, getClass() }
              );
     }
     private void    vetWrappedString( Wrapper41 wrapper, int colID, String colName ) throws
Exception
@@ -245,7 +247,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "a",
+             _rowOfNulls ? null : "a",
              new Class[] { String.class, Object.class }
              );
 
@@ -254,7 +256,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "true",
+             _rowOfNulls ? null : "true",
              new Class[] { Boolean.class }
              );
 
@@ -290,7 +292,7 @@ public  class   Wrapper41Test   extends 
              colName,
              new Class[]
              {
-                 Blob.class, Clob.class, byteArrayClass, getClass()
+                 Blob.class, Clob.class, _byteArrayClass, getClass()
              }
              );
     }
@@ -301,7 +303,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "de",
+             _rowOfNulls ? null : "de",
              new Class[] { String.class }
              );
         vetWrapperOK
@@ -309,8 +311,8 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             BINARY_VALUE,
-             new Class[] { byteArrayClass, Object.class }
+             _rowOfNulls ? null : BINARY_VALUE,
+             new Class[] { _byteArrayClass, Object.class }
              );
         
         vetNoWrapper
@@ -333,7 +335,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              6,
              "CLOBCOL",
-             "abc",
+             _rowOfNulls ? null : "abc",
              new Class[] { String.class, Clob.class, Object.class }
              );
 
@@ -348,7 +350,7 @@ public  class   Wrapper41Test   extends 
                  BigDecimal.class, Byte.class, Short.class, Integer.class, Long.class,
                  Float.class, Double.class,
                  Date.class, Time.class, Timestamp.class,
-                 byteArrayClass
+                 _byteArrayClass
              }
              );
 
@@ -365,7 +367,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              7,
              "DATECOL",
-             "1994-02-23",
+             _rowOfNulls ? null : "1994-02-23",
              new Class[] { String.class, Date.class, Object.class }
              );
         vetWrapperOK
@@ -373,7 +375,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              7,
              "DATECOL",
-             "1994-02-23 00:00:00.0",
+             _rowOfNulls ? null : "1994-02-23 00:00:00.0",
              new Class[] { Timestamp.class }
              );
         
@@ -388,7 +390,7 @@ public  class   Wrapper41Test   extends 
                  BigDecimal.class, Byte.class, Short.class, Integer.class, Long.class,
                  Float.class, Double.class,
                  Time.class,
-                 Blob.class, Clob.class, byteArrayClass, getClass()
+                 Blob.class, Clob.class, _byteArrayClass, getClass()
              }
              );
     }
@@ -399,7 +401,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "1.0",
+             _rowOfNulls ? null : "1.0",
              new Class[] { String.class, Float.class, Double.class, BigDecimal.class, Number.class,
Object.class }
              );
         vetWrapperOK
@@ -407,7 +409,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "1",
+             _rowOfNulls ? null : "1",
              new Class[] { Byte.class, Short.class, Integer.class, Long.class }
              );
         vetWrapperOK
@@ -415,7 +417,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             "true",
+             _rowOfNulls ? null : "true",
              new Class[] { Boolean.class }
              );
         
@@ -424,7 +426,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              colID,
              colName,
-             new Class[] { Date.class, Time.class, Timestamp.class, Blob.class, Clob.class,
byteArrayClass, getClass() }
+             new Class[] { Date.class, Time.class, Timestamp.class, Blob.class, Clob.class,
_byteArrayClass, getClass() }
              );
     }
     private void    vetWrappedTime( Wrapper41 wrapper ) throws Exception
@@ -436,7 +438,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              16,
              "TIMECOL",
-             expectedTime.toString(),
+             _rowOfNulls ? null : expectedTime.toString(),
              new Class[] { String.class, Time.class, Object.class }
              );
         vetWrapperOK
@@ -444,7 +446,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              16,
              "TIMECOL",
-             timeToTimestamp(expectedTime).toString(),
+             _rowOfNulls ? null : timeToTimestamp(expectedTime).toString(),
              new Class[] { Timestamp.class }
              );
         
@@ -459,7 +461,7 @@ public  class   Wrapper41Test   extends 
                  BigDecimal.class, Byte.class, Short.class, Integer.class, Long.class,
                  Float.class, Double.class,
                  Date.class,
-                 Blob.class, Clob.class, byteArrayClass, getClass()
+                 Blob.class, Clob.class, _byteArrayClass, getClass()
              }
              );
     }
@@ -471,7 +473,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              17,
              "TIMESTAMPCOL",
-             expectedTimestamp,
+             _rowOfNulls ? null : expectedTimestamp,
              new Class[] { String.class, Timestamp.class, Object.class }
              );
 
@@ -481,7 +483,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              17,
              "TIMESTAMPCOL",
-             expectedTime,
+             _rowOfNulls ? null : expectedTime,
              new Class[] { Time.class }
              );
 
@@ -491,7 +493,7 @@ public  class   Wrapper41Test   extends 
              wrapper,
              17,
              "TIMESTAMPCOL",
-             expectedDate,
+             _rowOfNulls ? null : expectedDate,
              new Class[] { Date.class }
              );
         
@@ -505,7 +507,7 @@ public  class   Wrapper41Test   extends 
                  Boolean.class,
                  BigDecimal.class, Byte.class, Short.class, Integer.class, Long.class,
                  Float.class, Double.class,
-                 Blob.class, Clob.class, byteArrayClass, getClass()
+                 Blob.class, Clob.class, _byteArrayClass, getClass()
              }
              );
     }
@@ -533,7 +535,13 @@ public  class   Wrapper41Test   extends 
     private void    vetCandidate( Class candidate, Object expectedValue, Object actualValue
)
         throws Exception
     {
-        assertTrue( candidate.getName(), candidate.isAssignableFrom( actualValue.getClass(
) ) );
+        if ( actualValue != null ) { assertTrue( candidate.getName(), candidate.isAssignableFrom(
actualValue.getClass( ) ) ); }
+
+        if ( expectedValue == null )
+        {
+            assertNull( actualValue );
+            return;
+        }
 
         if ( VARIABLE_STRING.equals( expectedValue ) ) { return; }
 
@@ -579,6 +587,9 @@ public  class   Wrapper41Test   extends 
         ( Wrapper41 wrapper, int colID, String colName, Class[] unsupportedCoercions, String
expectedSQLState )
         throws Exception
     {
+        // null can be coerced to anything
+        if ( _rowOfNulls ) { return; }
+        
         int coercionCount = unsupportedCoercions.length;
         for ( int i = 0; i < coercionCount; i++ )
         {



Mime
View raw message