org.apache.derbyTesting.functionTests.tests.jdbcapi
Class BLOBTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.derbyTesting.junit.BaseTestCase
              extended by org.apache.derbyTesting.junit.BaseJDBCTestCase
                  extended by org.apache.derbyTesting.functionTests.tests.jdbcapi.BLOBTest
All Implemented Interfaces:
junit.framework.Test

public final class BLOBTest
extends BaseJDBCTestCase

Tests reading and updating binary large objects (BLOBs).


Field Summary
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
BLOBTest(java.lang.String name)
          Constructor
 
Method Summary
 void setUp()
          The setup creates a Connection to the database.
static junit.framework.Test suite()
          The suite decorates the tests of this class with a setup which creates and populates the data model.
 void testBlobCastInValuesClause()
          Tests that a stream value in a values clause can be cast to a BLOB.
 void testUpdateBlobFromForwardOnlyResultSetUsingPositionedUpdates()
          Tests updating a Blob from a forward only resultset, using methods.
 void testUpdateBlobFromForwardOnlyResultSetUsingResultSetMethods()
          Tests updating a Blob from a forward only resultset, using result set update methods.
 void testUpdateBlobFromForwardOnlyResultSetWithProjectUsingPositionedUpdates()
          Tests updating a Blob from a forward only resultset, produced by a select query with projection.
 void testUpdateBlobFromForwardOnlyResultSetWithProjectUsingResultSetMethods()
          Tests updating a Blob from a forward only resultset, produced by a select query with projection.
 void testUpdateBlobFromScrollableResultSetUsingPositionedUpdates()
          Tests updating a Blob from a scollable resultset, using positioned updates.
 void testUpdateBlobFromScrollableResultSetUsingResultSetMethods()
          Tests updating a Blob from a scollable resultset, using result set update methods.
 void testUpdateBlobFromScrollableResultSetWithProjectUsingPositionedUpdates()
          Tests updating a Blob from a scollable resultset, produced by a select query with projection.
 void testUpdateBlobFromScrollableResultSetWithProjectUsingResultSetMethods()
          Tests updating a Blob from a scollable resultset produced by a select query with projection.
private  void testUpdateBlobWithPositionedUpdate(java.sql.ResultSet rs, int newVal, int newSize)
          Tests updating the Blob using positioned updates
private  void testUpdateBlobWithResultSetMethods(java.sql.ResultSet rs, int newVal, int newSize)
          Tests updating the Blob using result set update methods.
private  void verifyBlob(int expectedVal, int expectedSize, java.sql.Blob blob)
          Verifies that the blob is consistent
private  void verifyNewValueInTable(int newVal, int newSize)
          Verifies that the table has row with column val=newVal and that it its data and size columns are consistent.
 
Methods inherited from class org.apache.derbyTesting.junit.BaseJDBCTestCase
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertTableRowCount, assertUpdateCount, assertUpdateCount, checkAllConsistency, checkEstimatedRowCount, commit, createStatement, createStatement, createStatement, dropTable, dropTable, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
 
Methods inherited from class org.apache.derbyTesting.junit.BaseTestCase
alarm, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertSecurityManager, assertThrowableEquals, execJavaCmd, fail, getFailureFolder, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeSystemProperty, runBare, setSystemProperty, traceit
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BLOBTest

public BLOBTest(java.lang.String name)
Constructor

Parameters:
name - name of test case (method).
Method Detail

testUpdateBlobFromScrollableResultSetUsingResultSetMethods

public void testUpdateBlobFromScrollableResultSetUsingResultSetMethods()
                                                                throws java.sql.SQLException,
                                                                       java.io.IOException
Tests updating a Blob from a scollable resultset, using result set update methods.

Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobFromForwardOnlyResultSetUsingResultSetMethods

public void testUpdateBlobFromForwardOnlyResultSetUsingResultSetMethods()
                                                                 throws java.sql.SQLException,
                                                                        java.io.IOException
Tests updating a Blob from a forward only resultset, using result set update methods.

Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobFromScrollableResultSetUsingPositionedUpdates

public void testUpdateBlobFromScrollableResultSetUsingPositionedUpdates()
                                                                 throws java.sql.SQLException,
                                                                        java.io.IOException
Tests updating a Blob from a scollable resultset, using positioned updates.

Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobFromForwardOnlyResultSetUsingPositionedUpdates

public void testUpdateBlobFromForwardOnlyResultSetUsingPositionedUpdates()
                                                                  throws java.sql.SQLException,
                                                                         java.io.IOException
Tests updating a Blob from a forward only resultset, using methods.

Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobFromScrollableResultSetWithProjectUsingResultSetMethods

public void testUpdateBlobFromScrollableResultSetWithProjectUsingResultSetMethods()
                                                                           throws java.sql.SQLException,
                                                                                  java.io.IOException
Tests updating a Blob from a scollable resultset produced by a select query with projection. Updates are made using result set update methods.

Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobFromForwardOnlyResultSetWithProjectUsingResultSetMethods

public void testUpdateBlobFromForwardOnlyResultSetWithProjectUsingResultSetMethods()
                                                                            throws java.sql.SQLException,
                                                                                   java.io.IOException
Tests updating a Blob from a forward only resultset, produced by a select query with projection. Updates are made using result set update methods.

Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobFromScrollableResultSetWithProjectUsingPositionedUpdates

public void testUpdateBlobFromScrollableResultSetWithProjectUsingPositionedUpdates()
                                                                            throws java.sql.SQLException,
                                                                                   java.io.IOException
Tests updating a Blob from a scollable resultset, produced by a select query with projection. Updates are made using positioned updates

Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobFromForwardOnlyResultSetWithProjectUsingPositionedUpdates

public void testUpdateBlobFromForwardOnlyResultSetWithProjectUsingPositionedUpdates()
                                                                             throws java.sql.SQLException,
                                                                                    java.io.IOException
Tests updating a Blob from a forward only resultset, produced by a select query with projection. Updates are made using positioned updates.

Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobWithResultSetMethods

private void testUpdateBlobWithResultSetMethods(java.sql.ResultSet rs,
                                                int newVal,
                                                int newSize)
                                         throws java.sql.SQLException,
                                                java.io.IOException
Tests updating the Blob using result set update methods.

Parameters:
rs - result set, currently positioned on row to be updated
newVal - new value in val column and blob data
newSize - new size of Blob
Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testUpdateBlobWithPositionedUpdate

private void testUpdateBlobWithPositionedUpdate(java.sql.ResultSet rs,
                                                int newVal,
                                                int newSize)
                                         throws java.sql.SQLException,
                                                java.io.IOException
Tests updating the Blob using positioned updates

Parameters:
rs - result set, currently positioned on row to be updated
newVal - new value in val column and blob data
newSize - new size of Blob
Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

testBlobCastInValuesClause

public void testBlobCastInValuesClause()
                                throws java.io.IOException,
                                       java.sql.SQLException
Tests that a stream value in a values clause can be cast to a BLOB.

See DERBY-4102 (test case resulted in a ClassCastException earlier).

Throws:
java.io.IOException - if something goes wrong
java.sql.SQLException - if something goes wrong

verifyNewValueInTable

private void verifyNewValueInTable(int newVal,
                                   int newSize)
                            throws java.io.IOException,
                                   java.sql.SQLException
Verifies that the table has row with column val=newVal and that it its data and size columns are consistent.

Parameters:
newVal - value expected to be found in the val column of a row
newSize - expected size of size column and size of blob
Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

verifyBlob

private void verifyBlob(int expectedVal,
                        int expectedSize,
                        java.sql.Blob blob)
                 throws java.io.IOException,
                        java.sql.SQLException
Verifies that the blob is consistent

Parameters:
expectedVal - the InputStream for the Blob should return this value for every byte
expectedSize - the BLOB should have this size
blob - the BLOB to check
Throws:
java.sql.SQLException - causes test to fail with error
java.io.IOException - causes test to fail with error

suite

public static junit.framework.Test suite()
The suite decorates the tests of this class with a setup which creates and populates the data model.


setUp

public final void setUp()
                 throws java.lang.Exception
The setup creates a Connection to the database.

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception - any exception will cause test to fail with error.

Built on Wed 2009-11-25 18:43:31-0800, from revision 884373

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.