public class ClobTest extends BaseJDBCTestCase
Modifier and Type | Field and Description |
---|---|
private java.sql.Clob |
clob
Default Clob object used by the tests.
|
private static ExemptClobMD[] |
emd |
private java.util.HashMap<java.lang.reflect.Method,ExemptClobMD> |
excludedMethodSet |
private static java.lang.String |
LOCK_TIMEOUT |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
ClobTest(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)
Enumerate the methods of the Clob interface and
get the list of methods present in the interface
|
(package private) boolean |
checkIfExempted(java.lang.reflect.Method m)
Checks if the method is to be exempted from testing or not.
|
(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.
|
private void |
getCharacterStreamLongLastChar(int id,
int length,
CharAlphabet alphabet)
Obtains streams from the Clob and makes sure we can always read the
last char in the Clob.
|
static char |
getLastCharInStream(java.io.Reader reader,
int expectedCount)
Drains the stream and returns the last char read from the stream.
|
(package private) java.lang.Object |
getNullValueForType(java.lang.Class type)
Returns the null value for the specific type
|
(package private) java.lang.Object[] |
getNullValues(java.lang.Class<?>[] params)
Return a array of objects containing the default values for
the objects passed in as parameters
|
private int |
initializeLongClob()
Insert a row with a large clob into the test table.
|
private void |
insertAndFetchTest(long length)
Inserts a Clob with the specified length, using a stream source, then
fetches it from the database and checks the length.
|
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
Clob interface.
|
void |
testGetAsciiStreamClobUpdates()
Tests that the data updated in a Clob
is always reflected in the InputStream
got.
|
void |
testGetAsciiStreamCreateClob()
Tests that the InputStream got from
a empty Clob reflects new data in the
underlying Clob.
|
void |
testGetCharacterStreamClobUpdates()
Tests that the data updated in a Clob
is always reflected in the Reader
got.
|
void |
testGetCharacterStreamCreateClob()
Tests that the Reader got from
a empty Clob reflects new data in the
underlying Clob.
|
void |
testGetCharacterStreamLong()
Tests the implementation of getCharacterStream(long pos, long length).
|
void |
testGetCharacterStreamLongExceptionConditions()
Tests the exceptions thrown by the getCharacterStream
(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 |
testGetCharacterStreamLongLastCharCJK()
Obtains streams from the Clob reading portions of the content, always
including the last character in the Clob.
|
void |
testGetCharacterStreamLongLastCharLatin()
Obtains streams from the Clob reading portions of the content, always
including the last character in the Clob.
|
void |
testGetCharacterStreamLongOnLargeClob()
Test that
Clob.getCharacterStream(long,long) works on CLOBs
that are streamed from store. |
void |
testInsertAndFetchLarge()
Inserts, fetches and checks the length of a Clob using a stream.
|
void |
testInsertAndFetchLarger()
Inserts, fetches and checks the length of a Clob using a stream.
|
void |
testInsertAndFetchMedium()
Inserts, fetches and checks the length of a Clob using a stream.
|
void |
testInsertAndFetchMediumPlus()
Inserts, fetches and checks the length of a Clob using a stream.
|
void |
testInsertAndFetchSmall()
Inserts, fetches and checks the length of a Clob using a stream.
|
void |
testInsertAndFetchVerySmall()
Inserts, fetches and checks the length of a Clob using a stream.
|
void |
testInsertAndFetchZeroLength()
Inserts, fetches and checks the length of a Clob using a stream.
|
void |
testLockingAfterFree()
Test that a lock held on the corresponding row is released when free() is
called on the Clob object.
|
void |
testLockingAfterFreeWithDirtyReads()
Test that a lock held on the corresponding row is released when
free() is called on the Clob 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 Clob object if the isolation level is
Repeatable Read
|
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.Clob clob
private static final ExemptClobMD[] emd
private java.util.HashMap<java.lang.reflect.Method,ExemptClobMD> excludedMethodSet
private static final java.lang.String LOCK_TIMEOUT
public ClobTest(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 testFreeAfterImplicitFree() throws java.sql.SQLException
java.sql.SQLException
- if an error occurs during freepublic void testFreeandMethodsAfterCallingFree() throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.sql.SQLException
java.sql.SQLException
- if an error occurs during releasing
the Clob resourcesjava.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
void buildMethodList(java.lang.Object LOB) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
LOB
- an instance of the Clob interface implementationjava.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
boolean checkIfExempted(java.lang.reflect.Method m)
m
- the method to check for exemptionfalse
if the method shall be tested,
true
if the method is exempted and shall not be tested.boolean checkIfMethodThrowsSQLException(java.lang.Object LOB, java.lang.reflect.Method method) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
LOB
- the Object that implements the Blob interfacemethod
- the method that needs to be tested to ensure
that it throws the correct exceptionjava.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.Object[] getNullValues(java.lang.Class<?>[] params)
params
- an array containing the types of the parames to the methodjava.lang.Object getNullValueForType(java.lang.Class type)
type
- the type of the parameter for which the null
value is requiredpublic void testGetCharacterStreamLong() throws java.lang.Exception
java.lang.Exception
public void testGetCharacterStreamLongLastCharLatin() throws java.io.IOException, java.sql.SQLException
This case fills the Clob with latin lowercase characters.
java.io.IOException
java.sql.SQLException
public void testGetCharacterStreamLongLastCharCJK() throws java.io.IOException, java.sql.SQLException
This case fills the Clob with Chinese/Japanese/Korean characters.
java.io.IOException
java.sql.SQLException
private void getCharacterStreamLongLastChar(int id, int length, CharAlphabet alphabet) throws java.io.IOException, java.sql.SQLException
See DERBY-4060.
id
- id of the Clob to uselength
- the length of the Clobalphabet
- the alphabet used to create the contentjava.io.IOException
- if reading from a stream failsjava.sql.SQLException
- if something goes wrongpublic void testGetCharacterStreamLongOnLargeClob() throws java.lang.Exception
Clob.getCharacterStream(long,long)
works on CLOBs
that are streamed from store. (DERBY-2891)java.lang.Exception
public void testGetCharacterStreamLongExceptionConditions() throws java.sql.SQLException
java.sql.SQLException
public void testGetAsciiStreamCreateClob() throws java.lang.Exception
java.lang.Exception
public void testGetCharacterStreamCreateClob() throws java.lang.Exception
java.lang.Exception
public void testGetAsciiStreamClobUpdates() throws java.lang.Exception
java.lang.Exception
public void testGetCharacterStreamClobUpdates() throws java.lang.Exception
java.lang.Exception
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 testInsertAndFetchZeroLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testInsertAndFetchVerySmall() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testInsertAndFetchSmall() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testInsertAndFetchMedium() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testInsertAndFetchMediumPlus() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testInsertAndFetchLarge() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testInsertAndFetchLarger() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
private void insertAndFetchTest(long length) throws java.io.IOException, java.sql.SQLException
length
- number of characters in the Clobjava.io.IOException
- if reading from the source failsjava.sql.SQLException
- if something goes wrongprivate int initializeLongClob() throws java.sql.SQLException
clob
.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 char getLastCharInStream(java.io.Reader reader, int expectedCount) throws java.io.IOException
reader
- stream to drainexpectedCount
- expected number of chars (remaining) in the streamjava.lang.AssertionError
- if there are too many/few chars 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.