|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.derbyTesting.junit.BaseTestCase
org.apache.derbyTesting.junit.BaseJDBCTestCase
org.apache.derbyTesting.functionTests.tests.jdbcapi.ClobTest
public class ClobTest
Test the methods defined by the Clob interface.
Only methods defined by JDBC 3 or earlier are tested here, and the focus of the test is the interface methods. Less attention is given to inserting Clobs and fetching Clobs from the database.
| Nested Class Summary | |
|---|---|
private static class |
ClobTest.ClobTestSetup
Decorator creating the neccessary test data. |
| Field Summary | |
|---|---|
private java.sql.Clob |
clob
The Clob used for testing. |
private static int |
nextUniqueId
Next unique id for a Clob. |
private static java.lang.String |
NORWEGIAN_LETTERS
Test data, 18 characters long, containing only Norwegian letters. |
private static int |
SET_ASCII_STREAM
Constant for Clob.setAsciiStream method. |
private static int |
SET_CHARACTER_STREAM
Constant for Clob.setCharacterStream method. |
private static int |
SET_STRING
Constant for Clob.setString method. |
private static int |
TRANSFER_BUFFER_SIZE
Buffer size to use when transferring data between streams. |
| Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase |
|---|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE |
| Constructor Summary | |
|---|---|
ClobTest(java.lang.String testName)
|
|
| Method Summary | |
|---|---|
private void |
executeTestPositionWithStringToken(java.lang.String token,
long prefixLength)
Insert text into a Clob using Clob.setAsciiStream(long) and
then search for the specified token. |
private void |
insertDataWithToken(java.lang.String token,
long pre,
long post,
int mode)
Inserts data into the test Clob, referenced by this.clob. |
protected void |
setUp()
Obtain a Clob containing the empty string. |
static junit.framework.Test |
suite()
|
protected void |
tearDown()
Nullify reference to Clob. |
private void |
testCloningThroughAddBatch(boolean sourceAsStream,
boolean autoCommit)
Adds a series of Clobs into the test table using a batch, then deletes the Clobs inserted. |
void |
testCloningThroughAddBatchWithStream()
Tests that cloning an SQLClob object works when a stream has been set as the source of the Clob. |
void |
testCloningThroughAddBatchWithString()
Tests that cloning an SQLClob object works when a string has been set as the source of the Clob. |
void |
testGetLengthAfterTruncate()
Tests that the length of a Clob isn't cached in such a way that the length isn't updated after truncation. |
void |
testGetSubString_BiggerThanInternalBuffer()
Tests if big strings can be handled. |
void |
testGetSubString_PosNegative()
|
void |
testGetSubString_PosOneTooBig()
|
void |
testGetSubString_PosTooBig()
|
void |
testGetSubString_RequestZeroLength_PosTooBig()
|
void |
testGetSubString_RequestZeroLength_PosValid()
|
void |
testInsertCharacter_ReadOnlyToTemporary()
Tests that Derby specific end-of-stream markers aren't passed over to the temporary Clob, which doesn't use such markers. |
void |
testInsertStringInMiddle_Multibyte()
|
void |
testInsertStringOnEmptyClob_Multibyte()
|
void |
testInsertStringOnEmptyClob_Singlebyte()
|
void |
testLengthAfterInsertOnEmpty()
Tests that the length is updated correctly when inserting data. |
void |
testLengthAfterInsertOnLarge()
Tests that the length is updated correctly when inserting data. |
void |
testLengthOnEmptyClob()
|
void |
testPositionWithString_ASCII_SimplePartialRecurringPattern()
|
void |
testPositionWithString_CJK()
|
void |
testPositionWithString_IOS88591()
|
void |
testPositionWithString_USASCII()
|
void |
testReplaceMultibyteWithSingleByteBackwards()
|
void |
testReplaceMultibyteWithSingleByteForwards()
|
void |
testSetStringOnWrongOffset()
Test setString() refuses wrong offset. |
void |
testSetStringWithBigPos()
Test setString() refuses pos bigger than clob.length() + 1. |
void |
testSetStringWithEmptyString()
Test setString() accepts a empty String, and just return 0. |
void |
testSetStringWithNull()
Test setStrinng() refuses a Null String. |
void |
testSetStringWithWrongLen()
Test setString() refuses wrong len. |
void |
testTruncateExactInMemory()
Truncating a Clob to the current length should work. |
void |
testTruncateExactOnDisk()
Truncating a Clob to the current length should work. |
void |
testTruncateTooLongInMemory()
Specify a position that is larger then the Clob length. |
void |
testTruncateTooLongOnDisk()
Specify a position that is larger then the Clob length. |
void |
testTruncateZeroInMemory()
Truncating a Clob to the empty string. |
void |
testTruncateZeroOnDisk()
Truncating a Clob to the empty string. |
private int |
transferData(java.io.InputStream source,
java.io.OutputStream dest,
int tz)
Transfer data from an input stream to an output stream. |
private int |
transferData(java.io.Reader source,
int tz)
|
private int |
transferData(java.io.Reader source,
java.io.Writer dest,
int tz)
Transfer data from a source Reader to a destination Writer. |
private void |
truncateToZero(long initSize)
Truncates the default Clob to zero length and checks some basic operations on the empty Clob. |
| 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 |
| Field Detail |
|---|
private static final int TRANSFER_BUFFER_SIZE
private static final int SET_STRING
private static final int SET_ASCII_STREAM
private static final int SET_CHARACTER_STREAM
private static int nextUniqueId
private static final java.lang.String NORWEGIAN_LETTERS
private java.sql.Clob clob
| Constructor Detail |
|---|
public ClobTest(java.lang.String testName)
| Method Detail |
|---|
public void testGetSubString_PosOneTooBig()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testGetSubString_PosTooBig()
public void testGetSubString_PosNegative()
throws java.sql.SQLException
java.sql.SQLException
public void testGetSubString_RequestZeroLength_PosValid()
throws java.sql.SQLException
java.sql.SQLException
public void testGetSubString_RequestZeroLength_PosTooBig()
throws java.sql.SQLException
java.sql.SQLException
public void testGetSubString_BiggerThanInternalBuffer()
throws java.io.IOException,
java.sql.SQLException
The motivation for the test is to make sure big buffers are filled with the call to read inside a loop. Big in this sense means bigger than some internal buffer. This is typically around 8 KB or so, but we try something considerably bigger. If a char/byte array is attempted filled with a single call to read, the resulting string wil typically contain at positions after the size of the internal buffer.
java.io.IOException
java.sql.SQLException
public void testLengthOnEmptyClob()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertStringOnEmptyClob_Singlebyte()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertStringOnEmptyClob_Multibyte()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertStringInMiddle_Multibyte()
throws java.sql.SQLException
java.sql.SQLException
public void testLengthAfterInsertOnEmpty()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testLengthAfterInsertOnLarge()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testReplaceMultibyteWithSingleByteForwards()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testReplaceMultibyteWithSingleByteBackwards()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testInsertCharacter_ReadOnlyToTemporary()
throws java.io.IOException,
java.sql.SQLException
Passing the marker over will normally result in a UTF encoding exception.
ID USAGE: reads id 2, writes id 10002
java.io.IOException
java.sql.SQLException
public void testPositionWithString_ASCII_SimplePartialRecurringPattern()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testPositionWithString_USASCII()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testPositionWithString_IOS88591()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testPositionWithString_CJK()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetStringOnWrongOffset()
throws java.sql.SQLException
java.sql.SQLException
public void testSetStringWithWrongLen()
throws java.sql.SQLException
java.sql.SQLException
public void testSetStringWithBigPos()
throws java.sql.SQLException
java.sql.SQLException
public void testSetStringWithNull()
throws java.sql.SQLException
java.sql.SQLException
public void testSetStringWithEmptyString()
throws java.sql.SQLException
java.sql.SQLException
public void testTruncateZeroOnDisk()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testTruncateZeroInMemory()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
private void truncateToZero(long initSize)
throws java.io.IOException,
java.sql.SQLException
initSize - the expected size of the Clob to truncate
java.io.IOException
java.sql.SQLException
public void testTruncateExactOnDisk()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testTruncateExactInMemory()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testTruncateTooLongOnDisk()
throws java.io.IOException,
java.sql.SQLException
This operation should fail and raise an exception.
java.io.IOException
java.sql.SQLException
public void testTruncateTooLongInMemory()
throws java.io.IOException,
java.sql.SQLException
This operation should fail and raise an exception.
java.io.IOException
java.sql.SQLException
public void testGetLengthAfterTruncate()
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testCloningThroughAddBatchWithStream()
throws java.sql.SQLException
See DERBY-4278
java.sql.SQLException - if something goes wrong
public void testCloningThroughAddBatchWithString()
throws java.sql.SQLException
java.sql.SQLException - if something goes wrong
private void testCloningThroughAddBatch(boolean sourceAsStream,
boolean autoCommit)
throws java.sql.SQLException
sourceAsStream - whether the source shall be specified as a stream
or a stringautoCommit - auto commit mode to run with
java.sql.SQLException - if something goes wrong
private void executeTestPositionWithStringToken(java.lang.String token,
long prefixLength)
throws java.io.IOException,
java.sql.SQLException
Clob.setAsciiStream(long) and
then search for the specified token.
Some data is inserted before and after the token, and the specified token is converted to bytes by using the ISO-8859-1 encoding. Note that ascii in JDBC is equivalent to ISO-8859-1, not US-ASCII.
java.io.IOException
java.sql.SQLException
protected void setUp()
throws java.lang.Exception
setUp in class junit.framework.TestCasejava.lang.Exception
protected void tearDown()
throws java.lang.Exception
tearDown in class BaseJDBCTestCasejava.lang.Exceptionpublic static junit.framework.Test suite()
private int transferData(java.io.InputStream source,
java.io.OutputStream dest,
int tz)
throws java.io.IOException
source - source datadest - destination to write totz - buffer size in number of bytes. Must be 1 or greater.
java.io.IOException
private int transferData(java.io.Reader source,
java.io.Writer dest,
int tz)
throws java.io.IOException
source - source datadest - destination to write totz - buffer size in number of characters. Must be 1 or greater.
java.io.IOException
private int transferData(java.io.Reader source,
int tz)
throws java.io.IOException,
java.sql.SQLException
java.io.IOException
java.sql.SQLException
private void insertDataWithToken(java.lang.String token,
long pre,
long post,
int mode)
throws java.io.IOException,
java.sql.SQLException
this.clob.
token - a token to insert into the Clob, cannot be null but
the empty string is acceptedpre - number of characters to insert before the token, using the
repeating alphabet stream (latin lower-case)post - number of characters to insert after the token, using the
repeating alphabet stream (latin lower-case)mode - insertion mode; SET_STRING, SET_ASCII_STREAM or
SET_CHARACTER_STREAM
java.io.IOException - if inserting data fails for some reason
java.sql.SQLException - if inserting data fails for some reason
|
Built on Thu 2009-11-26 18:42:53-0800, from revision 884739 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||