public class BlobTest extends BaseJDBCTestCase
Modifier and Type | Field and Description |
---|---|
private java.sql.Blob |
blob
Default Blob object used by the tests.
|
private static ExemptBlobMD[] |
emd |
private java.util.HashMap<java.lang.reflect.Method,ExemptBlobMD> |
excludedMethodSet |
private static java.lang.String |
LOCK_TIMEOUT |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
BlobTest(java.lang.String name)
Create the test with the given name.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
buildHashSet()
Builds the HashSet which will be used to test whether the given methods
can be exempted or not
|
(package private) void |
buildMethodList(java.lang.Object LOB) |
(package private) boolean |
checkIfExempted(java.lang.reflect.Method m)
Checks if the method throws a SQLFeatureNotSupportedException
|
(package private) boolean |
checkIfMethodThrowsSQLException(java.lang.Object LOB,
java.lang.reflect.Method method)
Checks if the invocation of the method throws a SQLExceptio
as expected.
|
private void |
executeParallelUpdate(int id,
boolean timeoutExpected)
Try to update the row with the given error.
|
static int |
getLastByteInStream(java.io.InputStream is,
int expectedCount)
Drains the stream and returns the last byte read from the stream.
|
(package private) java.lang.Object |
getNullValueForType(java.lang.Class type) |
(package private) java.lang.Object[] |
getNullValues(java.lang.Class<?>[] params) |
private int |
initializeLongBlob()
Insert a row with a large blob into the test table.
|
void |
setUp() |
static junit.framework.Test |
suite()
Create test suite for this test.
|
protected void |
tearDown()
Tear down this fixture, sub-classes should call
super.tearDown().
|
void |
testFreeAfterImplicitFree()
Tests free() after implicit free
|
void |
testFreeandMethodsAfterCallingFree()
Tests the implementation for the free() method in the
Blob interface.
|
void |
testGetBinaryStreamBlobUpdates()
Tests that the data updated in a Blob
is always reflected in the InputStream
got.
|
void |
testGetBinaryStreamCreateBlob()
Tests that the InputStream got from
a empty Blob reflects new data in the
underlying Blob.
|
void |
testGetBinaryStreamLong()
Tests the implementation of the method
getBinaryStream(long pos, long length).
|
void |
testGetBinaryStreamLongDrain()
Tests that draining a "sub-stream" from the Blob works.
|
void |
testGetBinaryStreamLongExceptionConditions()
Tests the exceptions thrown by the getBinaryStream
(long pos, long length) for the following conditions
a) pos <= 0
b) pos > (length of LOB)
c) length < 0
d) pos + length > (length of LOB).
|
void |
testGetBinaryStreamLongLastByte()
Obtains a binary stream and tries to drain it to read the last byte in
the Blob.
|
void |
testLockingAfterFree()
Test that a lock held on the corresponding row is released when free() is
called on the Blob object.
|
void |
testLockingAfterFreeWithDirtyReads()
Test that a lock held on the corresponding row is released when
free() is called on the Blob object if the isolation level is
Read Uncommitted
|
void |
testLockingAfterFreeWithRR()
Test that a lock held on the corresponding row is NOT released when
free() is called on the Blob object if the isolation level is
Repeatable Read
|
void |
testSetBytesReturnValueLarge()
Tests the return count on insertion when the Blob is represented as a
temporary file on disk.
|
void |
testSetBytesReturnValueLargeStateChange()
Tests the return count on insertion when the Blob is fetched from the
database and then modified.
|
void |
testSetBytesReturnValueSmall()
Tests the return count on insertion when the Blob is represented as a
byte array in memory.
|
static void |
transferAlphabetData(java.io.OutputStream writer,
long length)
Transfers the specified number of bytes generated from the modern latin
alphabet (lowercase) to the destination stream.
|
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, toString
private java.sql.Blob blob
private static final ExemptBlobMD[] emd
private java.util.HashMap<java.lang.reflect.Method,ExemptBlobMD> excludedMethodSet
private static final java.lang.String LOCK_TIMEOUT
public BlobTest(java.lang.String name)
name
- name of the test.public void setUp() throws java.sql.SQLException
setUp
in class junit.framework.TestCase
java.sql.SQLException
protected void tearDown() throws java.lang.Exception
BaseJDBCTestCase
tearDown
in class BaseJDBCTestCase
java.lang.Exception
void buildHashSet()
public void testFreeandMethodsAfterCallingFree() throws java.sql.SQLException
java.sql.SQLException
- if an error occurs during releasing
the Blob resourcesvoid buildMethodList(java.lang.Object LOB)
boolean checkIfExempted(java.lang.reflect.Method m)
m
- The method object that needs to be verified to see if it
is exemptedboolean checkIfMethodThrowsSQLException(java.lang.Object LOB, java.lang.reflect.Method method)
LOB
- the Object that implements the Blob interfacemethod
- the method that needs to be tested to ensure
that it throws the correct exceptionjava.lang.Object[] getNullValues(java.lang.Class<?>[] params)
java.lang.Object getNullValueForType(java.lang.Class type)
public void testGetBinaryStreamLong() throws java.lang.Exception
java.lang.Exception
public void testGetBinaryStreamLongLastByte() throws java.io.IOException, java.sql.SQLException
See DERBY-4060.
java.io.IOException
- if reading from a stream failsjava.sql.SQLException
- if something goes wrongpublic void testGetBinaryStreamLongExceptionConditions() throws java.sql.SQLException
SQLException.
java.sql.SQLException
public void testGetBinaryStreamLongDrain() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testGetBinaryStreamCreateBlob() throws java.lang.Exception
java.lang.Exception
public void testGetBinaryStreamBlobUpdates() throws java.lang.Exception
java.lang.Exception
public void testSetBytesReturnValueSmall() throws java.sql.SQLException
java.sql.SQLException
public void testSetBytesReturnValueLarge() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetBytesReturnValueLargeStateChange() throws java.io.IOException, java.sql.SQLException
The main point for this test is to provoke the transition from a
read-only internal representation to a writable representation.
For a Blob of "considerable" size, this involved going from a store
stream representation to a LOBStreamControl
representation using
a temporary file.
java.io.IOException
java.sql.SQLException
public void testLockingAfterFree() throws java.sql.SQLException
java.sql.SQLException
public void testLockingAfterFreeWithRR() throws java.sql.SQLException
java.sql.SQLException
public void testLockingAfterFreeWithDirtyReads() throws java.sql.SQLException
java.sql.SQLException
public void testFreeAfterImplicitFree() throws java.sql.SQLException
java.sql.SQLException
- if an error occurs during freeprivate int initializeLongBlob() throws java.sql.SQLException
blob
.java.sql.SQLException
private void executeParallelUpdate(int id, boolean timeoutExpected) throws java.sql.SQLException
id
- The id of the row to be updatedtimeoutExpected
- true if it is expected that the update times outjava.sql.SQLException
public static void transferAlphabetData(java.io.OutputStream writer, long length) throws java.io.IOException
writer
- the destinationlength
- number of bytes to writejava.io.IOException
- if writing to the destination stream failspublic static int getLastByteInStream(java.io.InputStream is, int expectedCount) throws java.io.IOException
is
- stream to drainexpectedCount
- expected number of bytes (remaining) in the streamjava.lang.AssertionError
- if there are too many/few bytes in the streamjava.io.IOException
- if reading from the stream failspublic static junit.framework.Test suite()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.