/** * Tests that the data updated in a Clob is always reflected in the InputStream got. Here the * updates into the Clob are done using both an OutputStream obtained from this Clob as well as * using Clob.setString. * * @throws Exception */ public void testGetAsciiStreamClobUpdates() throws Exception { // The String that will be used // to do the inserts into the // Clob. String str1 = "Hi I am the insert string"; // Stores the byte array representation of // the insert string. byte[] str1_bytes = str1.getBytes(); // The String that will be used in the // second series of updates String str2 = "Hi I am the update string"; // create the empty Clob. Clob clob = getConnection().createClob(); // Get the InputStream from this // Clob before any writes happen. InputStream is_BeforeWrite = clob.getAsciiStream(); // Get an OutputStream from this Clob // into which the data can be written OutputStream os = clob.setAsciiStream(1); os.write(str1_bytes); // Doing a setString now on the Clob // should reflect the same extension // in the InputStream also. clob.setString((str1_bytes.length) + 1, str2); // Get the input stream from the // Clob after the update InputStream is_AfterWrite = clob.getAsciiStream(); // Now check if the two InputStreams // match assertEquals(is_BeforeWrite, is_AfterWrite); }
private void testConvertClobPrepare() throws SQLException, MjdbcException { // when(conn.createClob()).thenReturn(clob); when(MappingUtils.invokeFunction(conn, "createClob", new Class[] {}, new Object[] {})) .thenReturn(clob); when(clob.setAsciiStream(1)).thenReturn(output); }