db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r417548 [2/2] - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/loc/ shared/org/apache/derby/...
Date Tue, 27 Jun 2006 18:26:29 GMT
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=417548&r1=417547&r2=417548&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
Tue Jun 27 11:26:28 2006
@@ -20,10 +20,12 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbc4;
 
+import javax.xml.transform.Result;
 import junit.framework.*;
 
 import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
 
+import java.io.*;
 import java.sql.*;
 
 /**
@@ -51,14 +53,18 @@
     public void setUp()
         throws SQLException {
         con = getConnection();
-        stmt = con.createStatement();
+        stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+                ResultSet.CONCUR_UPDATABLE);
+
         rs = stmt.executeQuery("SELECT * FROM SYS.SYSTABLES");
+
         // Position on first result.
         rs.next();
     }
 
     public void tearDown()
         throws SQLException {
+
         if (rs != null) {
             rs.close();
         }
@@ -247,8 +253,910 @@
         }
     }
     
+    /**
+     * This methods tests the ResultSet interface method
+     * updateBinaryStream
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+
+    public void testUpdateBinaryStream()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol LONG VARCHAR FOR BIT DATA)");
+        //Initial set of bytes used to create the Binary Stream that has to
+        //be inserted
+        byte[] bytes = new byte[] {
+            0x65, 0x66, 0x67, 0x68, 0x69,
+            0x69, 0x68, 0x67, 0x66, 0x65
+        };
+
+        //Bytes that are used to create the BinaryStream that will be used in
+        //the updateAsciiStream method
+        byte[] bytes_for_update = new byte[] {
+            0x69, 0x68, 0x67, 0x66, 0x65,
+            0x65, 0x66, 0x67, 0x68, 0x69
+        };
+
+        //Byte array in which the returned bytes from
+        //the Database after the update are stored. This
+        //array is then checked to determine if it
+        //has the same elements of the Byte array used for
+        //the update operation
+
+        byte[] bytes_ret = new byte[10];
+
+        //Input Stream inserted initially
+        InputStream is = new java.io.ByteArrayInputStream(bytes);
+
+        //InputStream that is used for update
+        InputStream is_for_update = new
+                java.io.ByteArrayInputStream(bytes_for_update);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+        ps_sb.setInt(1,1);
+        ps_sb.setBinaryStream(2,is,bytes.length);
+        ps_sb.executeUpdate();
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        rs1.updateBinaryStream(2,is_for_update,(int)bytes_for_update.length);
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateBinaryStream method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+        InputStream is_ret = rs1.getBinaryStream(2);
+
+        try {
+            is_ret.read(bytes_ret);
+            is_ret.close();
+        } catch(IOException ioe) {
+            fail("Error in the InputStream");
+        }
+
+        for(int i=0;i<bytes_for_update.length;i++) {
+            assertEquals("Error in updateBinaryStream",bytes_for_update[i],bytes_ret[i]);
+        }
+        rs1.close();
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+    /**
+     * This methods tests the ResultSet interface method
+     * updateAsciiStream
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+
+    public void testUpdateAsciiStream()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol LONG VARCHAR)");
+        //Initial set of bytes used to create the Ascii Stream that has to
+        //be inserted
+        byte[] bytes = new byte[] {
+            0x65, 0x66, 0x67, 0x68, 0x69,
+            0x69, 0x68, 0x67, 0x66, 0x65
+        };
+
+        //Bytes that are used to create the AsciiStream that will be used in
+        //the updateAsciiStream method
+        byte[] bytes_for_update = new byte[] {
+            0x69, 0x68, 0x67, 0x66, 0x65,
+            0x65, 0x66, 0x67, 0x68, 0x69
+        };
+
+        //Byte array in which the returned bytes from
+        //the Database after the update are stored. This
+        //array is then checked to determine if it
+        //has the same elements of the Byte array used for
+        //the update operation
+
+        byte[] bytes_ret = new byte[10];
+
+        //Input Stream inserted initially
+        InputStream is = new java.io.ByteArrayInputStream(bytes);
+
+        //InputStream that is used for update
+        InputStream is_for_update = new
+                java.io.ByteArrayInputStream(bytes_for_update);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+        ps_sb.setInt(1,1);
+        ps_sb.setAsciiStream(2,is,bytes.length);
+        ps_sb.executeUpdate();
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        rs1.updateAsciiStream(2,is_for_update,(int)bytes_for_update.length);
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateAsciiStream method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+        InputStream is_ret = rs1.getAsciiStream(2);
+
+        try {
+            is_ret.read(bytes_ret);
+            is_ret.close();
+        } catch(IOException ioe) {
+            fail("Error in the InputStream");
+        }
+
+        for(int i=0;i<bytes_for_update.length;i++) {
+            assertEquals("Error in updateAsciiStream",bytes_for_update[i],bytes_ret[i]);
+        }
+        rs1.close();
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+     /**
+     * This methods tests the ResultSet interface method
+     * updateCharacterStream
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+
+    public void testUpdateCharacterStream()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol LONG VARCHAR)");
+
+        String str = "Test data";
+        String str_for_update = "Test data used for update";
+
+        StringReader r = new StringReader(str);
+        StringReader r_for_update = new StringReader
+                (str_for_update);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+        ps_sb.setInt(1,1);
+        ps_sb.setCharacterStream(2,r,str.length());
+        ps_sb.executeUpdate();
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        rs1.updateCharacterStream(2,r_for_update,str_for_update.length());
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateAsciiStream method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+
+        StringReader r_ret = (StringReader)rs1.getCharacterStream(2);
+
+        char [] c_ret = new char[str_for_update.length()];
+
+        try {
+            r_ret.read(c_ret);
+        }
+        catch(IOException ioe) {
+            fail("Error in reading the InputStream");
+        }
+
+        String str_ret = new String(c_ret);
+
+        assertEquals("Error in updateCharacterStream" +
+            str_ret,str_for_update,str_ret);
+
+
+        rs1.close();
+
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+    /**
+     * This methods tests the ResultSet interface method
+     * updateBinaryStream
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+
+    public void testUpdateBinaryStreamStringParameterName()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol LONG VARCHAR FOR BIT DATA)");
+        //Initial set of bytes used to create the Binary Stream that has to
+        //be inserted
+        byte[] bytes = new byte[] {
+            0x65, 0x66, 0x67, 0x68, 0x69,
+            0x69, 0x68, 0x67, 0x66, 0x65
+        };
+
+        //Bytes that are used to create the BinaryStream that will be used in
+        //the updateAsciiStream method
+        byte[] bytes_for_update = new byte[] {
+            0x69, 0x68, 0x67, 0x66, 0x65,
+            0x65, 0x66, 0x67, 0x68, 0x69
+        };
+
+        //Byte array in which the returned bytes from
+        //the Database after the update are stored. This
+        //array is then checked to determine if it
+        //has the same elements of the Byte array used for
+        //the update operation
+
+        byte[] bytes_ret = new byte[10];
+
+        //Input Stream inserted initially
+        InputStream is = new java.io.ByteArrayInputStream(bytes);
+
+        //InputStream that is used for update
+        InputStream is_for_update = new
+                java.io.ByteArrayInputStream(bytes_for_update);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+        ps_sb.setInt(1,1);
+        ps_sb.setBinaryStream(2,is,bytes.length);
+        ps_sb.executeUpdate();
+        ps_sb.close();
+
+        //Update operation
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        rs1.updateBinaryStream("datacol",is_for_update,(int)bytes_for_update.length);
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateBinaryStream method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+        InputStream is_ret = rs1.getBinaryStream(2);
+
+        try {
+            is_ret.read(bytes_ret);
+            is_ret.close();
+        } catch(IOException ioe) {
+            fail("Error in the InputStream");
+        }
+
+        for(int i=0;i<bytes_for_update.length;i++) {
+            assertEquals("Error in updateBinaryStream",bytes_for_update[i],bytes_ret[i]);
+        }
+        rs1.close();
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+    /**
+     * This methods tests the ResultSet interface method
+     * updateAsciiStream
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+
+    public void testUpdateAsciiStreamStringParameterName()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol LONG VARCHAR)");
+        //Initial set of bytes used to create the Ascii Stream that has to
+        //be inserted
+        byte[] bytes = new byte[] {
+            0x65, 0x66, 0x67, 0x68, 0x69,
+            0x69, 0x68, 0x67, 0x66, 0x65
+        };
+
+        //Bytes that are used to create the AsciiStream that will be used in
+        //the updateAsciiStream method
+        byte[] bytes_for_update = new byte[] {
+            0x69, 0x68, 0x67, 0x66, 0x65,
+            0x65, 0x66, 0x67, 0x68, 0x69
+        };
+
+        //Byte array in which the returned bytes from
+        //the Database after the update are stored. This
+        //array is then checked to determine if it
+        //has the same elements of the Byte array used for
+        //the update operation
+
+        byte[] bytes_ret = new byte[10];
+
+        //Input Stream inserted initially
+        InputStream is = new java.io.ByteArrayInputStream(bytes);
+
+        //InputStream that is used for update
+        InputStream is_for_update = new
+                java.io.ByteArrayInputStream(bytes_for_update);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+        ps_sb.setInt(1,1);
+        ps_sb.setAsciiStream(2,is,bytes.length);
+        ps_sb.executeUpdate();
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        rs1.updateAsciiStream("datacol",is_for_update,(int)bytes_for_update.length);
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateAsciiStream method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+        InputStream is_ret = rs1.getAsciiStream(2);
+
+        try {
+            is_ret.read(bytes_ret);
+            is_ret.close();
+        } catch(IOException ioe) {
+            fail("Error in the InputStream");
+        }
+
+        for(int i=0;i<bytes_for_update.length;i++) {
+            assertEquals("Error in updateAsciiStream",bytes_for_update[i],bytes_ret[i]);
+        }
+        rs1.close();
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+     /**
+     * This methods tests the ResultSet interface method
+     * updateCharacterStream
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+
+    public void testUpdateCharacterStreamStringParameterName()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol LONG VARCHAR)");
+
+        String str = "Test data";
+        String str_for_update = "Test data used for update";
+
+        StringReader r = new StringReader(str);
+        StringReader r_for_update = new StringReader
+                (str_for_update);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+        ps_sb.setInt(1,1);
+        ps_sb.setCharacterStream(2,r,str.length());
+        ps_sb.executeUpdate();
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        rs1.updateCharacterStream("datacol",r_for_update,str_for_update.length());
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateAsciiStream method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+
+        StringReader r_ret = (StringReader)rs1.getCharacterStream(2);
+
+        char [] c_ret = new char[str_for_update.length()];
+
+        try {
+            r_ret.read(c_ret);
+        }
+        catch(IOException ioe) {
+            fail("Error in reading the InputStream");
+        }
+
+        String str_ret = new String(c_ret);
+
+        assertEquals("Error in updateCharacterStream" + str_ret,str_for_update,
+            str_ret);
+
+        rs1.close();
+
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+    /**
+     * This methods tests the ResultSet interface method
+     * updateClob
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+    public void embeddedUpdateClob()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol Clob)");
+        //Initial set of bytes used to create the Ascii Stream for the Clob
+        //that has to be inserted
+        byte[] bytes1 = new byte[] {
+            0x65, 0x66, 0x67, 0x68, 0x69,
+            0x69, 0x68, 0x67, 0x66, 0x65
+        };
+
+        //Bytes that are used to create the AsciiStream for the Clob
+        //that will be used in the updateClob method
+        byte[] bytes2 = new byte[] {
+            0x69, 0x68, 0x67, 0x66, 0x65,
+            0x65, 0x66, 0x67, 0x68, 0x69
+        };
+
+        //Byte array in which the returned bytes from
+        //the Database after the update are stored. This
+        //array is then checked to determine if it
+        //has the same elements of the Byte array used for
+        //the update operation
+
+        byte[] bytes_ret = new byte[10];
+
+        //1 Input Stream for insertion
+        InputStream is1 = new java.io.ByteArrayInputStream(bytes1);
+
+        //2 Input Stream for insertion
+        InputStream is2 = new java.io.ByteArrayInputStream(bytes2);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+
+        //first insert
+        ps_sb.setInt(1,1);
+        ps_sb.setAsciiStream(2,is1,bytes1.length);
+        ps_sb.executeUpdate();
+
+        //second insert
+        ps_sb.setInt(1,2);
+        ps_sb.setAsciiStream(2,is2,bytes2.length);
+        ps_sb.executeUpdate();
+
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+        //we do not have set methods on Clob and Blob implemented
+        //So query the first Clob from the database
+        //update the second result set with this
+        //Clob value
+
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        Clob clob = rs1.getClob(2);
+
+        rs1.next();
+        rs1.updateClob(2,clob);
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateClob method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+        rs1.next();
+        InputStream is_ret = rs1.getAsciiStream(2);
+
+        try {
+            is_ret.read(bytes_ret);
+            is_ret.close();
+        } catch(IOException ioe) {
+            fail("Error in the InputStream");
+        }
+
+        for(int i=0;i<bytes1.length;i++) {
+            assertEquals("Error in updateAsciiStream",bytes1[i],bytes_ret[i]);
+        }
+        rs1.close();
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+     /**
+     * This methods tests the ResultSet interface method
+     * updateBlob
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+    public void embeddedUpdateBlob()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol Blob)");
+        //Initial set of bytes used to create the Binary Stream that has to
+        //be inserted
+        byte[] bytes1 = new byte[] {
+            0x65, 0x66, 0x67, 0x68, 0x69,
+            0x69, 0x68, 0x67, 0x66, 0x65
+        };
+
+        //Bytes that are used to create the BinaryStream for the Blob
+        //that will be used in the updateBlob method
+        byte[] bytes2 = new byte[] {
+            0x69, 0x68, 0x67, 0x66, 0x65,
+            0x65, 0x66, 0x67, 0x68, 0x69
+        };
+
+        //Byte array in which the returned bytes from
+        //the Database after the update are stored. This
+        //array is then checked to determine if it
+        //has the same elements of the Byte array used for
+        //the update operation
+
+        byte[] bytes_ret = new byte[10];
+
+        //1 Input Stream for insertion
+        InputStream is1 = new java.io.ByteArrayInputStream(bytes1);
+
+        //2 Input Stream for insertion
+        InputStream is2 = new java.io.ByteArrayInputStream(bytes2);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+
+        //first insert
+        ps_sb.setInt(1,1);
+        ps_sb.setBinaryStream(2,is1,bytes1.length);
+        ps_sb.executeUpdate();
+
+        //second insert
+        ps_sb.setInt(1,2);
+        ps_sb.setBinaryStream(2,is2,bytes2.length);
+        ps_sb.executeUpdate();
+
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+        //we do not have set methods on Clob and Blob implemented
+        //So query the first Clob from the database
+        //update the second result set with this
+        //Clob value
+
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        Blob blob = rs1.getBlob(2);
+
+        rs1.next();
+        rs1.updateBlob(2,blob);
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateBlob method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+        rs1.next();
+        InputStream is_ret = rs1.getBinaryStream(2);
+
+        try {
+            is_ret.read(bytes_ret);
+            is_ret.close();
+        } catch(IOException ioe) {
+            fail("Error in the InputStream");
+        }
+
+        for(int i=0;i<bytes1.length;i++) {
+            assertEquals("Error in updateBlob",bytes1[i],bytes_ret[i]);
+        }
+        rs1.close();
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+    /**
+     * This methods tests the ResultSet interface method
+     * updateClob
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+    public void embeddedUpdateClobStringParameterName()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol Clob)");
+        //Initial set of bytes used to create the Ascii Stream for the Clob
+        //that has to be inserted
+        byte[] bytes1 = new byte[] {
+            0x65, 0x66, 0x67, 0x68, 0x69,
+            0x69, 0x68, 0x67, 0x66, 0x65
+        };
+
+        //Bytes that are used to create the AsciiStream for the Clob
+        //that will be used in the updateClob method
+        byte[] bytes2 = new byte[] {
+            0x69, 0x68, 0x67, 0x66, 0x65,
+            0x65, 0x66, 0x67, 0x68, 0x69
+        };
+
+        //Byte array in which the returned bytes from
+        //the Database after the update are stored. This
+        //array is then checked to determine if it
+        //has the same elements of the Byte array used for
+        //the update operation
+
+        byte[] bytes_ret = new byte[10];
+
+        //1 Input Stream for insertion
+        InputStream is1 = new java.io.ByteArrayInputStream(bytes1);
+
+        //2 Input Stream for insertion
+        InputStream is2 = new java.io.ByteArrayInputStream(bytes2);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+
+        //first insert
+        ps_sb.setInt(1,1);
+        ps_sb.setAsciiStream(2,is1,bytes1.length);
+        ps_sb.executeUpdate();
+
+        //second insert
+        ps_sb.setInt(1,2);
+        ps_sb.setAsciiStream(2,is2,bytes2.length);
+        ps_sb.executeUpdate();
+
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+        //we do not have set methods on Clob and Blob implemented
+        //So query the first Clob from the database
+        //update the second result set with this
+        //Clob value
+
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        Clob clob = rs1.getClob(2);
+
+        rs1.next();
+        rs1.updateClob("datacol",clob);
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateClob method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+        rs1.next();
+        InputStream is_ret = rs1.getAsciiStream(2);
+
+        try {
+            is_ret.read(bytes_ret);
+            is_ret.close();
+        } catch(IOException ioe) {
+            fail("Error in the InputStream");
+        }
+
+        for(int i=0;i<bytes1.length;i++) {
+            assertEquals("Error in updateAsciiStream",bytes1[i],bytes_ret[i]);
+        }
+        rs1.close();
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+     /**
+     * This methods tests the ResultSet interface method
+     * updateBlob
+     *
+     * @throws SQLException if some error occurs while calling the method
+     */
+    public void embeddedUpdateBlobStringParameterName()
+    throws SQLException {
+        //create the table
+        stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
+                "datacol Blob)");
+        //Initial set of bytes used to create the Binary Stream that has to
+        //be inserted
+        byte[] bytes1 = new byte[] {
+            0x65, 0x66, 0x67, 0x68, 0x69,
+            0x69, 0x68, 0x67, 0x66, 0x65
+        };
+
+        //Bytes that are used to create the BinaryStream for the Blob
+        //that will be used in the updateBlob method
+        byte[] bytes2 = new byte[] {
+            0x69, 0x68, 0x67, 0x66, 0x65,
+            0x65, 0x66, 0x67, 0x68, 0x69
+        };
+
+        //Byte array in which the returned bytes from
+        //the Database after the update are stored. This
+        //array is then checked to determine if it
+        //has the same elements of the Byte array used for
+        //the update operation
+
+        byte[] bytes_ret = new byte[10];
+
+        //1 Input Stream for insertion
+        InputStream is1 = new java.io.ByteArrayInputStream(bytes1);
+
+        //2 Input Stream for insertion
+        InputStream is2 = new java.io.ByteArrayInputStream(bytes2);
+
+        //Prepared Statement used to insert the data
+        PreparedStatement ps_sb = con.prepareStatement
+                ("insert into UpdateTestTable_ResultSet values(?,?)");
+
+        //first insert
+        ps_sb.setInt(1,1);
+        ps_sb.setBinaryStream(2,is1,bytes1.length);
+        ps_sb.executeUpdate();
+
+        //second insert
+        ps_sb.setInt(1,2);
+        ps_sb.setBinaryStream(2,is2,bytes2.length);
+        ps_sb.executeUpdate();
+
+        ps_sb.close();
+
+        //Update operation
+        //use a different ResultSet variable so that the
+        //other tests can go on unimpacted
+        //we do not have set methods on Clob and Blob implemented
+        //So query the first Clob from the database
+        //update the second result set with this
+        //Clob value
+
+        ResultSet rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet for update");
+        rs1.next();
+        Blob blob = rs1.getBlob(2);
+
+        rs1.next();
+        rs1.updateBlob("datacol",blob);
+        rs1.updateRow();
+        rs1.close();
+
+        //Query to see whether the data that has been updated
+        //using the updateBlob method is the same
+        //data that we expected
+
+        rs1 = stmt.executeQuery
+                ("select * from UpdateTestTable_ResultSet");
+        rs1.next();
+        rs1.next();
+        InputStream is_ret = rs1.getBinaryStream(2);
+
+        try {
+            is_ret.read(bytes_ret);
+            is_ret.close();
+        } catch(IOException ioe) {
+            fail("Error in the InputStream");
+        }
+
+        for(int i=0;i<bytes1.length;i++) {
+            assertEquals("Error in updateBlob",bytes1[i],bytes_ret[i]);
+        }
+        rs1.close();
+        //delete the table
+        stmt .execute("drop table UpdateTestTable_ResultSet");
+    }
+
+    /**
+     * Create suite containing client-only tests.
+     */
+    private static TestSuite clientSuite(String name) {
+        TestSuite clientSuite = new TestSuite(name);
+        return clientSuite;
+    }
+
+    /**
+     * Create suite containing embedded-only tests.
+     */
+    private static TestSuite embeddedSuite(String name) {
+        TestSuite embeddedSuite = new TestSuite(name);
+        embeddedSuite.addTest(new ResultSetTest(
+                    "embeddedUpdateBlob"));
+        embeddedSuite.addTest(new ResultSetTest(
+                    "embeddedUpdateClob"));
+        embeddedSuite.addTest(new ResultSetTest(
+                    "embeddedUpdateBlobStringParameterName"));
+        embeddedSuite.addTest(new ResultSetTest(
+                    "embeddedUpdateClobStringParameterName"));
+        return embeddedSuite;
+    }
+
     public static Test suite() {
-        return new TestSuite(ResultSetTest.class,
-                             "ResultSetTest suite");
+        TestSuite rsSuite =
+            new TestSuite(ResultSetTest.class, "ResultSetTest suite");
+        // Add client only tests
+        // NOTE: JCC is excluded
+        if (usingDerbyNetClient()) {
+            rsSuite.addTest(
+                    clientSuite("ResultSetTest client-only suite"));
+        }
+        // Add embedded only tests
+        if (usingEmbedded()) {
+            rsSuite.addTest(
+                    embeddedSuite("ResultSetTest embedded-only suite"));
+        }
+        return rsSuite;
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java?rev=417548&r1=417547&r2=417548&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
Tue Jun 27 11:26:28 2006
@@ -172,14 +172,17 @@
 						new MD( "registerOutParameter", new Class[] { int.class, int.class, String.class }
),
 						new MD( "setArray", new Class[] { int.class, java.sql.Array.class } ),
 						new MD( "setAsciiStream", new Class[] { String.class, java.io.InputStream.class, int.class
} ),
+                                                new MD( "setAsciiStream", new Class[] { String.class,
java.io.InputStream.class, long.class } ),
 						new MD( "setBigDecimal", new Class[] { String.class, java.math.BigDecimal.class } ),
 						new MD( "setBinaryStream", new Class[] { String.class, java.io.InputStream.class, int.class
} ),
+                                                new MD( "setBinaryStream", new Class[] {
String.class, java.io.InputStream.class, long.class } ),
 						new MD( "setBlob", new Class[] { String.class, java.io.InputStream.class, long.class
} ),
 						new MD( "setBlob", new Class[] { String.class, Blob.class } ),
 						new MD( "setBoolean", new Class[] { String.class, boolean.class } ),
 						new MD( "setByte", new Class[] { String.class, byte.class } ),
 						new MD( "setBytes", new Class[] { String.class, byte[].class } ),
 						new MD( "setCharacterStream", new Class[] { String.class, java.io.Reader.class, int.class
} ),
+                                                new MD( "setCharacterStream", new Class[]
{ String.class, java.io.Reader.class, long.class } ),
 						new MD( "setClob", new Class[] { String.class, java.io.Reader.class, long.class } ),
 						new MD( "setClob", new Class[] { String.class, Clob.class } ),
 						new MD( "setDate", new Class[] { String.class, java.sql.Date.class } ),
@@ -228,8 +231,14 @@
 					//
 					new FD( "updateBlob", new Class[] { int.class, Blob.class } ),
 					new FD( "updateBlob", new Class[] { String.class, Blob.class } ),
+                                        new FD( "updateBlob", new Class[] { int.class, InputStream.class
,long.class } ),
+                                        new FD( "updateBlob", new Class[] { String.class,
InputStream.class ,long.class } ),
 					new FD( "updateClob", new Class[] { int.class, Clob.class } ),
 					new FD( "updateClob", new Class[] { String.class, Clob.class } ),
+                                        new FD( "updateClob", new Class[] { int.class, Reader.class
,long.class } ),
+                                        new FD( "updateClob", new Class[] { String.class,
Reader.class ,long.class } ),
+                                        new FD( "updateNClob",new Class[] { int.class,Reader.class,long.class}),
+                                        new FD( "updateNClob",new Class[] { String.class,Reader.class,long.class}),
 					
 
 					//



Mime
View raw message