db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r542473 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/io/ engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
Date Tue, 29 May 2007 09:41:26 GMT
Author: kahatlen
Date: Tue May 29 02:41:25 2007
New Revision: 542473

URL: http://svn.apache.org/viewvc?view=rev&rev=542473
Log:
DERBY-2247: provide set methods for blob in embeded driver

Addressing follow-up comments. Contributed by Anurag Shekhar.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobSetMethodsTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/LobStreamTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java?view=diff&rev=542473&r1=542472&r2=542473
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java Tue May
29 02:41:25 2007
@@ -45,7 +45,6 @@
     protected String uniqueName;
     protected String canonicalName;
     private static final String TEMP_DIR_PREFIX = "derbytmp_";
-    private int counter = 0;
 
     /**
      * Most of the initialization is done in the init method.
@@ -278,27 +277,14 @@
 
     /**
      * Create and returns a temporary file in temporary file system of database.
-     * @param prefix String to prefix the random name generator. It can be null
-     * @param suffix String to suffix the random name generator. ".tmp" will be
-     *               used if null.
+     * @param prefix String to prefix the random name generator.
+     * @param suffix String to suffix the random name generator.
      * @return StorageFile
      */
     public StorageFile createTemporaryFile (String prefix, String suffix)
                                                             throws IOException {
-        StorageFile tmpDir = getTempDir();
-        if (prefix == null)
-            prefix = "tmp";
-        if (suffix == null)
-            suffix = ".tmp";
-        StorageFile tmpFile = null;
-        synchronized (tmpDir) {
-            do {
-                String fileName = prefix + Integer.toString (counter++)
-                            + suffix;
-                tmpFile = newStorageFile (tmpDir, fileName);
-            } while (tmpFile.exists());
-            tmpFile.createNewFile();
-        }
-        return tmpFile;
+        File tmpFile = File.createTempFile (prefix, suffix,
+                new File (getTempDir().getPath()));
+        return newStorageFile (getTempDir(), tmpFile.getName());
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java?view=diff&rev=542473&r1=542472&r2=542473
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java Tue May 29 02:41:25
2007
@@ -360,6 +360,8 @@
             if (materialized) {
                  result = new byte [length];
                  int sz = control.read (result, 0, result.length, startPos - 1);
+                 if (sz == -1)
+                     return new byte [0];
                  if (sz < length) {
                      byte [] tmparray = new byte [sz];
                      System.arraycopy (result, 0, tmparray, 0, sz);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java?view=diff&rev=542473&r1=542472&r2=542473
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java Tue May
29 02:41:25 2007
@@ -39,7 +39,7 @@
 public class LOBInputStream extends InputStream {
 
     private boolean closed;
-    private LOBStreamControl control;
+    private final LOBStreamControl control;
     private long pos;
     private long updateCount;
 
@@ -118,7 +118,7 @@
                    MessageService.getTextMessage(SQLState.LANG_STREAM_CLOSED));
         try {
             int ret = control.read(b, off, len, pos);
-            if (ret > 0) {
+            if (ret != -1) {
                 pos += ret;
                 return ret;
             }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java?view=diff&rev=542473&r1=542472&r2=542473
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java Tue May
29 02:41:25 2007
@@ -38,7 +38,7 @@
 
 public class LOBOutputStream extends OutputStream {
     private boolean closed;
-    private LOBStreamControl control;
+    private final LOBStreamControl control;
     private long pos;
 
     LOBOutputStream(LOBStreamControl control, long position) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java?view=diff&rev=542473&r1=542472&r2=542473
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java Tue May
29 02:41:25 2007
@@ -99,6 +99,9 @@
                 throw (IOException) e;
             if (e instanceof RuntimeException)
                 throw (RuntimeException) e;
+            IOException ioe = new IOException (e.getMessage());
+            ioe.initCause (e);
+            throw ioe;
         }
         isBytes = false;
         //now this call will write into the file
@@ -183,7 +186,7 @@
         isValidPostion(pos);
         updateCount++;
         if (isBytes) {
-            if (pos + 1 < MAX_BUF_SIZE) {
+            if (pos < MAX_BUF_SIZE) {
                 byte [] bytes = {(byte) b};
                 updateData(bytes, 0, 1, pos);
                 return pos + 1;
@@ -216,10 +219,11 @@
                     ExceptionUtil.getSQLStateFromIdentifier(
                                   SQLState.BLOB_INVALID_OFFSET)))
                     throw new ArrayIndexOutOfBoundsException (e.getMessage());
+            throw e;
         }
         updateCount++;
         if (isBytes) {
-            if (pos + b.length < MAX_BUF_SIZE)
+            if (pos + len <= MAX_BUF_SIZE)
                 return updateData(b, off, len, pos);
             else {
                 init(dataBytes, pos);
@@ -255,6 +259,8 @@
     }
 
     private int readBytes(byte [] b, int off, int len, long pos) {
+        if (pos >= dataBytes.length)
+            return -1;
         int lengthFromPos = dataBytes.length - (int) pos;
         int actualLength = len > lengthFromPos ? lengthFromPos : len;
         byte [] result = new byte[actualLength];
@@ -325,7 +331,7 @@
             System.arraycopy(dataBytes, 0, tmpByte, 0, (int) size);
             dataBytes = tmpByte;
         } else {
-            if (size < Integer.MAX_VALUE && size < MAX_BUF_SIZE) {
+            if (size < MAX_BUF_SIZE) {
                 dataBytes = new byte [(int) size];
                 read(dataBytes, 0, dataBytes.length, 0);
                 isBytes = true;
@@ -387,6 +393,9 @@
                     throw (IOException) e;
                 if (e instanceof RuntimeException)
                     throw (RuntimeException) e;
+                IOException ioe = new IOException (e.getMessage());
+                ioe.initCause (e);
+                throw ioe;
             }
         }
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobSetMethodsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobSetMethodsTest.java?view=diff&rev=542473&r1=542472&r2=542473
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobSetMethodsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/BlobSetMethodsTest.java
Tue May 29 02:41:25 2007
@@ -29,10 +29,6 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.apache.derbyTesting.functionTests.harness.RunSuite;
-import org.apache.derbyTesting.functionTests.harness.RunTest;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
@@ -59,117 +55,139 @@
      * Create test suite.
      */
     public static Test suite() {
-        return TestConfiguration.embeddedSuite(BlobSetMethodsTest.class);
+        return TestConfiguration.defaultSuite (BlobSetMethodsTest.class);
     }
 
     /**
-     * tests set bytes method of blob.
+     * Tests large blob (more than 4k) to ensure LOBStreamControl uses file.
      */
-    public void testSetBytes () throws SQLException {
+    public void testSetBytesLargeBlob () throws SQLException {
         Connection con = getConnection();
-        try {
-            con.setAutoCommit (false);
-            PreparedStatement pstmt = con.prepareStatement("insert into " +
-                    "blobtest (id, data) values (?,?)");
-            pstmt.setInt (1,1);
-            Blob blob = con.createBlob();
-            //add 1024 bytes
-            byte [] data = new byte [BUFFER_SIZE];
-            for (int i = 0; i < BUFFER_SIZE; i++) {
-                data [i] = (byte) (i % 255);
-            }
-            blob.setBytes (1, data);
-            assertEquals (BUFFER_SIZE, blob.length());
-            pstmt.setBlob (2, blob);
-            pstmt.executeUpdate();
-            Statement stmt = con.createStatement();
-            ResultSet rs = stmt.executeQuery(
-                    "select data from blobtest where id = 1");
-            assertEquals(true, rs.next());
-            blob = rs.getBlob (1);
-            assertEquals (BUFFER_SIZE, blob.length());
-            //update blob in the middle
-            byte [] data1 = new byte [UPDATE_SIZE];
-            for (int i = 0; i < UPDATE_SIZE; i++)
-                data1 [i] = 120;//just any value
-            blob.setBytes (UPDATE_SIZE, data1);
-            byte [] data2 = blob.getBytes (100, UPDATE_SIZE);
-            for (int i = 0; i < UPDATE_SIZE; i++)
-                assertEquals (data1 [i], data2 [i]);
-            //update it at the end
-            blob.setBytes (BUFFER_SIZE + 1, data1);
-            assertEquals (BUFFER_SIZE + UPDATE_SIZE, blob.length());
-            data2 = blob.getBytes (BUFFER_SIZE + 1, UPDATE_SIZE);
-            for (int i = 0; i < UPDATE_SIZE; i++)
-                assertEquals (data1 [i], data2 [i]);
-            //insert the blob and test again
-            pstmt.setInt (1, 2);
-            pstmt.setBlob (2, blob);
-            pstmt.executeUpdate();
-            rs = stmt.executeQuery("select data from blobtest where " +
-                    "id = 2");
-            assertEquals(true, rs.next());
-            blob = rs.getBlob (1);
-            assertEquals (BUFFER_SIZE + UPDATE_SIZE, blob.length());
-            data2 = blob.getBytes (100, UPDATE_SIZE);
-            for (int i = 0; i < UPDATE_SIZE; i++)
-                assertEquals (data1 [i], data2 [i]);
-            data2 = blob.getBytes (BUFFER_SIZE + 1, UPDATE_SIZE);
-            for (int i = 0; i < UPDATE_SIZE; i++)
-                assertEquals (data1 [i], data2 [i]);
-
-            //now add more than 4k so file get in use
-            for (int i = 0; i < 5; i++)
-                blob.setBytes (i * BUFFER_SIZE + 1, data);
-            assertEquals (BUFFER_SIZE * 5 , blob.length());
-            blob.setBytes (BUFFER_SIZE + 1, data1);
-            blob.setBytes (BUFFER_SIZE * 5 + 1, data1);
-            assertEquals (5 * BUFFER_SIZE + UPDATE_SIZE, blob.length());
-            //insert it into table
-            pstmt.setInt (1, 3);
-            pstmt.setBlob (2, blob);
-            pstmt.executeUpdate ();
-            rs = stmt.executeQuery("select data from blobtest where " +
-                                    "id = 3");
-            assertEquals(true, rs.next());
-            blob = rs.getBlob (1);
-            data2 = blob.getBytes (BUFFER_SIZE + 1, UPDATE_SIZE);
-            assertEquals (5 * BUFFER_SIZE + UPDATE_SIZE, blob.length());
-            for (int i = 0; i < UPDATE_SIZE; i++)
-                assertEquals (data1 [i], data2 [i]);
-            data2 = blob.getBytes (5 * BUFFER_SIZE + 1, UPDATE_SIZE);
-            for (int i = 0; i < UPDATE_SIZE; i++)
-                assertEquals (data1 [i], data2 [i]);
-            //test truncate
-            blob.truncate (BUFFER_SIZE);
-            assertEquals (BUFFER_SIZE, blob.length());
-            //test truncate on small size blob
-            blob = con.createBlob();
-            data = new byte [100];
-            for (int i = 0; i < 100; i++) {
-                data [i] = (byte) i;
-            }
-            blob.setBytes (1, data);
-            assertEquals (blob.length(), 100);
-            blob.truncate (50);
-            assertEquals (blob.length(), 50);
-            con.commit();
-            stmt.close();
-            pstmt.close();
+        con.setAutoCommit (false);
+        PreparedStatement pstmt = con.prepareStatement("insert into " +
+                "blobtest (id, data) values (?,?)");
+        Blob blob = con.createBlob();
+        byte [] data = new byte [BUFFER_SIZE];
+        for (int i = 0; i < BUFFER_SIZE; i++) {
+            data [i] = (byte) (i % 255);
         }
-        finally {
-            if (con != null) {
-                con.commit();
-                con.close();
-            }
+     //now add more than 4k so file get in use
+        for (int i = 0; i < 5; i++)
+            blob.setBytes (i * BUFFER_SIZE + 1, data);
+        assertEquals (BUFFER_SIZE * 5 , blob.length());
+                    //update blob in the middle
+        byte [] data1 = new byte [UPDATE_SIZE];
+        for (int i = 0; i < UPDATE_SIZE; i++)
+            data1 [i] = 120;//just any value
+        blob.setBytes (BUFFER_SIZE + 1, data1);
+        blob.setBytes (BUFFER_SIZE * 5 + 1, data1);
+        assertEquals (5 * BUFFER_SIZE + UPDATE_SIZE, blob.length());
+        //insert it into table
+        pstmt.setInt (1, 3);
+        pstmt.setBlob (2, blob);
+        pstmt.executeUpdate ();
+        Statement stmt = con.createStatement();
+        ResultSet rs = stmt.executeQuery("select data from blobtest where " +
+                                "id = 3");
+        assertEquals(true, rs.next());
+        blob = rs.getBlob (1);
+        byte [] data2 = blob.getBytes (BUFFER_SIZE + 1, UPDATE_SIZE);
+        assertEquals (5 * BUFFER_SIZE + UPDATE_SIZE, blob.length());
+        for (int i = 0; i < UPDATE_SIZE; i++)
+            assertEquals (data1 [i], data2 [i]);
+        data2 = blob.getBytes (5 * BUFFER_SIZE + 1, UPDATE_SIZE);
+        for (int i = 0; i < UPDATE_SIZE; i++)
+            assertEquals (data1 [i], data2 [i]);
+        //test truncate
+        blob.truncate (BUFFER_SIZE);
+        assertEquals ("truncate failed", BUFFER_SIZE, blob.length());
+        rs.close();
+        con.commit();
+        stmt.close();
+        pstmt.close();
+    }
+
+    /**
+     * tests set bytes method of blob in memory only mode (less than 4k)
+     */
+    public void testSetBytesSmallBlob () throws SQLException {
+        Connection con = getConnection();
+        con.setAutoCommit (false);
+        PreparedStatement pstmt = con.prepareStatement("insert into " +
+                "blobtest (id, data) values (?,?)");
+        pstmt.setInt (1,1);
+        Blob blob = con.createBlob();
+        //add 1024 bytes
+        byte [] data = new byte [BUFFER_SIZE];
+        for (int i = 0; i < BUFFER_SIZE; i++) {
+            data [i] = (byte) (i % 255);
+        }
+        blob.setBytes (1, data);
+        assertEquals (BUFFER_SIZE, blob.length());
+        pstmt.setBlob (2, blob);
+        pstmt.executeUpdate();
+        Statement stmt = con.createStatement();
+        ResultSet rs = stmt.executeQuery(
+                "select data from blobtest where id = 1");
+        assertEquals(true, rs.next());
+        blob = rs.getBlob (1);
+        assertEquals (BUFFER_SIZE, blob.length());
+        //update blob in the middle
+        byte [] data1 = new byte [UPDATE_SIZE];
+        for (int i = 0; i < UPDATE_SIZE; i++)
+            data1 [i] = 120;//just any value
+        blob.setBytes (UPDATE_SIZE, data1);
+        byte [] data2 = blob.getBytes (100, UPDATE_SIZE);
+        for (int i = 0; i < UPDATE_SIZE; i++)
+            assertEquals (data1 [i], data2 [i]);
+        //update it at the end
+        blob.setBytes (BUFFER_SIZE + 1, data1);
+        assertEquals (BUFFER_SIZE + UPDATE_SIZE, blob.length());
+        data2 = blob.getBytes (BUFFER_SIZE + 1, UPDATE_SIZE);
+        for (int i = 0; i < UPDATE_SIZE; i++)
+            assertEquals (data1 [i], data2 [i]);
+        //insert the blob and test again
+        pstmt.setInt (1, 2);
+        pstmt.setBlob (2, blob);
+        pstmt.executeUpdate();
+        rs = stmt.executeQuery("select data from blobtest where " +
+                "id = 2");
+        assertEquals(true, rs.next());
+        blob = rs.getBlob (1);
+        assertEquals (BUFFER_SIZE + UPDATE_SIZE, blob.length());
+        data2 = blob.getBytes (100, UPDATE_SIZE);
+        for (int i = 0; i < UPDATE_SIZE; i++)
+            assertEquals (data1 [i], data2 [i]);
+        data2 = blob.getBytes (BUFFER_SIZE + 1, UPDATE_SIZE);
+        for (int i = 0; i < UPDATE_SIZE; i++)
+            assertEquals (data1 [i], data2 [i]);
+
+        //test truncate on small size blob
+        blob = con.createBlob();
+        data = new byte [100];
+        for (int i = 0; i < 100; i++) {
+            data [i] = (byte) i;
         }
+        blob.setBytes (1, data);
+        assertEquals (blob.length(), 100);
+        blob.truncate (50);
+        assertEquals (blob.length(), 50);
+        blob.setBytes (1, data);
+        assertEquals ("set failed", blob.length(), 100);
+        blob.truncate (50);
+        assertEquals ("truncation failed", blob.length(), 50);
+        rs.close();
+        con.commit();
+        stmt.close();
+        pstmt.close();
     }
 
-    protected void tearDown() throws SQLException {
+    protected void tearDown() throws Exception {
         Connection con = getConnection();
+        con.setAutoCommit (true);
         Statement stmt = con.createStatement();
         stmt.execute ("drop table blobtest");
         stmt.close();
-        con.close();
+        super.tearDown();
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/LobStreamTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/LobStreamTest.java?view=diff&rev=542473&r1=542472&r2=542473
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/LobStreamTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/LobStreamTest.java
Tue May 29 02:41:25 2007
@@ -38,11 +38,6 @@
 
 public class LobStreamTest extends BaseJDBCTestCase {
 
-    private static final String dbName = "LobStreamTest";
-    private static final boolean useLOBStreamControl = true;
-
-    private Connection conn = null;
-    File f = null;
     private InputStream in = null;
     private OutputStream out = null;
     private Blob blob;
@@ -52,7 +47,7 @@
     }
 
     protected void setUp() throws Exception {
-        conn = getConnection();
+        Connection conn = getConnection();
         blob = conn.createBlob();
         in = blob.getBinaryStream();
         out = blob.setBinaryStream (1);
@@ -60,8 +55,8 @@
 
     protected void tearDown() throws Exception {
         blob.free();
-        conn.rollback();
-        conn.close();
+        blob = null;
+        super.tearDown();
     }
 
     /**
@@ -69,7 +64,7 @@
      */
 
     /**
-     * Test read and write methods with one parameter.
+     * Test read and write methods with no parameter.
      */
     public void testReadWriteNoParameters() throws IOException {
 
@@ -79,7 +74,7 @@
 
         for (int i=0; i<8000; i++) {
             int value = in.read();
-            assertEquals("Read value is equal to i", i%255, value);
+            assertEquals("Output does not match input", i%255, value);
         }
 
         in.close();
@@ -102,7 +97,7 @@
 
         for (int i=0; i<8000; i++) {
             int value = in.read();
-            assertEquals("Read value is equal to i", i%255, value);
+            assertEquals("Output does not match input", i%255, value);
         }
 
         in.close();
@@ -128,7 +123,7 @@
             int count = in.read(b);
             for (int j=0; j<count; j++) {
                 int value = b[j] & 0xFF;
-                assertEquals("Read value is equal to i",
+                assertEquals("Output does not match input",
                                         (((i * 100) + j) % 255), value);
             }
         }
@@ -159,7 +154,7 @@
             int count = in.read(b, offset, 100);
             for (int j=0; j<count; j++) {
                 int value = b[j + offset] & 0xFF;
-                assertEquals("Read value is equal to i",
+                assertEquals("Output does not match input",
                                         (((i * 100) + j) % 255), value);
             }
             offset += 1;
@@ -260,7 +255,7 @@
         while (i < 8000) {
             if ((i%255) < 100) {
                 int value = in.read();
-                assertEquals("Read value is equal to i", i%255, value);
+                assertEquals("Output does not match input", i%255, value);
                 i++;
             } else {
                 long count = in.skip(155);
@@ -287,7 +282,7 @@
         byte[] b = null;
         try {
             out.write(b, 100, 20);
-            assertTrue("byte[] = null should cause exception", false);
+            fail("byte[] = null should cause exception");
         } catch (Exception e) {
             assertTrue("Expected NullPointerException",
                     e instanceof NullPointerException);
@@ -296,7 +291,7 @@
         b = new byte[100];
         try {
             out.write(b, 0, 200);
-            assertTrue("length > b.length should cause exception", false);
+            fail("length > b.length should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                     e instanceof IndexOutOfBoundsException);
@@ -305,7 +300,7 @@
         // offset > b.length
         try {
             out.write(b, 150, 0);
-            assertTrue("offset > b.length should cause exception", false);
+            fail("offset > b.length should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                     e instanceof IndexOutOfBoundsException);
@@ -314,8 +309,7 @@
         // offset + length > b.length
         try {
             out.write(b, 50, 100);
-            assertTrue("length + offset > b.length should cause exception",
-                    false);
+            fail("length + offset > b.length should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                     e instanceof IndexOutOfBoundsException);
@@ -324,7 +318,7 @@
         // offset is negative
         try {
             out.write(b, -50, 100);
-            assertTrue("negative offset should cause exception", false);
+            fail("negative offset should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                         e instanceof IndexOutOfBoundsException);
@@ -333,7 +327,7 @@
         //length is negative
         try {
             out.write(b, 0, -100);
-            assertTrue("negative length should cause exception", false);
+            fail("negative length should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                 e instanceof IndexOutOfBoundsException);
@@ -343,7 +337,7 @@
         out.close();
         try {
             out.write(b, 0, 100);
-            assertTrue("Stream should be closed", false);
+            fail("Stream should be closed");
         } catch (Exception e) {
             assertTrue("Expected IOException", e instanceof IOException);
         }
@@ -369,7 +363,7 @@
         byte[] b = null;
         try {
             in.read(b, 100, 20);
-            assertTrue("byte[] = null should cause exception", false);
+            fail("byte[] = null should cause exception");
         } catch (Exception e) {
             assertTrue("Expected NullPointerException",
                                         e instanceof NullPointerException);
@@ -379,7 +373,7 @@
         b = new byte[100];
         try {
             int count = in.read(b, 0, 200);
-            assertTrue("length > b.length should cause exception", false);
+            fail("length > b.length should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                     e instanceof IndexOutOfBoundsException);
@@ -388,7 +382,7 @@
         // offset > b.length
         try {
             in.read(b, 150, 0);
-            assertTrue("offset > b.length should cause exception", false);
+            fail("offset > b.length should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                         e instanceof IndexOutOfBoundsException);
@@ -397,8 +391,7 @@
         // offset + length > b.length
         try {
             int count = in.read(b, 50, 100);
-            assertTrue("offset + length > b.length should cause exception",
-                                                                        false);
+            fail("offset + length > b.length should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                     e instanceof IndexOutOfBoundsException);
@@ -407,7 +400,7 @@
         // offset is negative
         try {
             in.read(b, -50, 100);
-            assertTrue("negative offset should cause exception", false);
+            fail("negative offset should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                         e instanceof IndexOutOfBoundsException);
@@ -416,7 +409,7 @@
         //length is negative
         try {
             in.read(b, 0, -100);
-            assertTrue("negative length should cause exception", false);
+            fail("negative length should cause exception");
         } catch (Exception e) {
             assertTrue("Expected IndexOutOfBoundException",
                                     e instanceof IndexOutOfBoundsException);
@@ -426,7 +419,7 @@
         in.close();
         try {
             in.read(b, 0, 100);
-            assertTrue("Stream should be closed", false);
+            fail("Stream should be closed");
         } catch (Exception e) {
             assertTrue("Expected IOException", e instanceof IOException);
         }
@@ -438,6 +431,8 @@
      * Suite method automatically generated by JUnit module.
      */
     public static Test suite() {
+        //testing only embedded driver generic test suite testing both
+        //client and ebedded is present in jdbcapi/LobStreamsTest
         TestSuite ts  = new TestSuite ("LobStreamTest");
         ts.addTest(TestConfiguration.embeddedSuite(LobStreamTest.class));
         TestSuite encSuite = new TestSuite ("LobStreamsTest:encrypted");



Mime
View raw message