public class StreamTruncationTest extends BaseJDBCTestCase
Tests that truncation does indeed happen for CHAR, VARCHAR and CLOB. Truncation is not allowed for LONG VARCHAR columns.
There are two aspects to consider; specified length vs unspecified length
(lengthless override), and small vs large. In this regard, small is when the
stream content fits into the internal buffer of the conversion reader
(ReaderToUTF8Stream
). In this test, the buffer is assumed to be
approximately 32KB.
Modifier and Type | Field and Description |
---|---|
static int |
CHAR |
static int |
CHAR_SIZE |
static int |
CLOB |
static int |
CONV_BUFFER_SIZE
Assumed conversion buffer size.
|
private static java.util.concurrent.atomic.AtomicInteger |
ID
Id/counter to use for the inserted rows.
|
static int |
LARGE_SIZE
Large size (larger than the conversion buffer).
|
static int |
LARGE_VARCHAR_SIZE |
static int |
LONGVARCHAR |
static int |
SMALL_SIZE
Small size (smaller than the conversion buffer).
|
static java.lang.String |
TABLE_LARGE
Name of table with the "large" columns.
|
static java.lang.String |
TABLE_SMALL
Name of table with the "small" columns.
|
static int |
VARCHAR |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
StreamTruncationTest(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
private void |
charSmall(boolean lengthless)
Executes a set of insertions into the CHAR column.
|
private void |
generalTypeLarge(int colIndex,
boolean lengthless)
Executes a set of insertions into the larger of the columns.
|
private void |
generalTypeSmall(int colIndex,
boolean lengthless)
Executes a set of insertions into the smaller of the columns.
|
private int |
getStreamLength(java.lang.String table,
int colIndex,
int id)
Obtains the length of the data value stored in the specified table,
column index and id (primary key).
|
private int |
insertLarge(int colIndex,
boolean lengthless,
int totalLength,
int blanks)
Inserts a large (largerer than internal conversion buffer) string value.
|
private int |
insertSmall(int colIndex,
boolean lengthless,
int totalLength,
int blanks)
Inserts a small (smaller than internal conversion buffer) string value.
|
void |
setUp() |
static junit.framework.Test |
suite()
Returns the suite of tests.
|
void |
testCharWithLength() |
void |
testCharWithoutLength() |
void |
testLargeClobWithLength() |
void |
testLargeClobWithoutLength() |
void |
testLargeVarcharWithLength() |
void |
testLargeVarcharWithoutLength() |
void |
testLongVarcharWithLength() |
void |
testLongVarcharWithoutLength() |
void |
testSmallClobWithLength() |
void |
testSmallClobWithoutLength() |
void |
testSmallVarcharWithLength() |
void |
testSmallVarcharWithoutLength() |
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, tearDown, 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
public static final int CONV_BUFFER_SIZE
ReaderToUTF8Stream
,
Constant Field Valuespublic static final int CLOB
public static final int VARCHAR
public static final int LONGVARCHAR
public static final int CHAR
public static final java.lang.String TABLE_SMALL
public static final java.lang.String TABLE_LARGE
public static final int SMALL_SIZE
public static final int LARGE_SIZE
public static final int LARGE_VARCHAR_SIZE
public static final int CHAR_SIZE
private static java.util.concurrent.atomic.AtomicInteger ID
public void setUp() throws java.sql.SQLException
setUp
in class junit.framework.TestCase
java.sql.SQLException
public void testCharWithLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testCharWithoutLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSmallVarcharWithLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSmallVarcharWithoutLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testLargeVarcharWithLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testLargeVarcharWithoutLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testLongVarcharWithLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testLongVarcharWithoutLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSmallClobWithLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSmallClobWithoutLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testLargeClobWithLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testLargeClobWithoutLength() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
private void generalTypeLarge(int colIndex, boolean lengthless) throws java.io.IOException, java.sql.SQLException
colIndex
- column index to insert into, which also determines the
type to testlengthless
- true
if a lengthless override should be used,
false
if the length of the stream shall be specified when
insertedjava.io.IOException
- if reading from the source stream failsjava.sql.SQLException
- if something goes wrongprivate void generalTypeSmall(int colIndex, boolean lengthless) throws java.io.IOException, java.sql.SQLException
colIndex
- column index to insert into, which also determines the
type to testlengthless
- true
if a lengthless override should be used,
false
if the length of the stream shall be specified when
insertedjava.io.IOException
- if reading from the source stream failsjava.sql.SQLException
- if something goes wrongprivate void charSmall(boolean lengthless) throws java.io.IOException, java.sql.SQLException
lengthless
- true
if a lengthless override should be used,
false
if the length of the stream shall be specified when
insertedjava.io.IOException
- if reading from the source stream failsjava.sql.SQLException
- if something goes wrongprivate int insertSmall(int colIndex, boolean lengthless, int totalLength, int blanks) throws java.io.IOException, java.sql.SQLException
colIndex
- column to insert into (see constants)lengthless
- whether the length of the stream should be specified
or not on insertiontotalLength
- the total character length of the stream to insertblanks
- number of trailing blanks in the streamjava.io.IOException
- if reading from the source stream failsjava.sql.SQLException
- if something goes wrong, or the test failsprivate int insertLarge(int colIndex, boolean lengthless, int totalLength, int blanks) throws java.io.IOException, java.sql.SQLException
colIndex
- column to insert into (see constants)lengthless
- whether the length of the stream should be specified
or not on insertiontotalLength
- the total character length of the stream to insertblanks
- number of trailing blanks in the streamjava.io.IOException
- if reading from the source stream failsjava.sql.SQLException
- if something goes wrong, or the test failsprivate int getStreamLength(java.lang.String table, int colIndex, int id) throws java.io.IOException, java.sql.SQLException
table
- table namecolIndex
- column indexid
- id of the row to fetchjava.io.IOException
- if reading the stream failsjava.sql.SQLException
- if something goes wrongpublic static junit.framework.Test suite()
Two tables are created for the test.
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.