public class CollationTest2 extends BaseJDBCTestCase
NOTE: The prefix "ci_test" is used for tests that require a case insensitive collation order.
Modifier and Type | Field and Description |
---|---|
private static int[] |
DEFAULT_LIKE_RESULT |
private static int[] |
DEFAULT_NAME_ORDER |
private static java.lang.String[] |
derby2670_pattern |
private static java.lang.String[][][] |
derby2670_pattern_result |
private static int[] |
ENGLISH_LIKE_RESULT |
private static int[] |
ENGLISH_NAME_ORDER |
private static int[][] |
EXPECTED_LIKE_RESULTS |
private static int[][] |
EXPECTED_NAME_ORDER |
private static java.lang.String[] |
LIKE_CHAR_TEST_CASES |
private static java.lang.String[] |
LIKE_NAMES
set up LIKE test cases, configured for all languages by
the TEST_* constants.
|
private static java.lang.String[] |
LIKE_TEST_CASES |
private static java.lang.String[] |
NAMES |
private static int[] |
NORWAY_LIKE_RESULT |
private static int[] |
NORWAY_NAME_ORDER |
private static int[] |
POLISH_LIKE_RESULT |
private static int[] |
POLISH_NAME_ORDER |
private static int |
TEST_DEFAULT |
private static int |
TEST_ENGLISH |
private static int |
TEST_NORWAY |
private static int |
TEST_POLISH |
private static boolean |
verbose_debug
Set to get output if something in the test is failing and you want
more information about what was going on.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
CollationTest2(java.lang.String name)
Constructors for This class:
|
Modifier and Type | Method and Description |
---|---|
private void |
addSomeMoreCustomers(int counter) |
private void |
addSomeMoreCustomers(int counter,
boolean useD1,
boolean useD2) |
private static junit.framework.Test |
caseInsensitiveCollationSuite()
Returns a suite of tests running with a collation strength resulting
in case insensitivity.
|
private void |
checkLangBasedQuery(java.lang.String query,
java.lang.String[][] expectedResult,
boolean ordered) |
private void |
checkParamQuery(java.lang.String query,
java.lang.String[] param,
int paramNumber,
java.lang.String[][] expectedResult,
boolean ordered) |
private void |
checkSimpleCompare(int[] expected_order)
Check simple boolean compare of string constant to column value.
|
private void |
checkTwoPersistentCompare(int[] expected_order)
Check simple boolean compare of string constant to column value.
|
void |
ci_testDerby5367()
Tests that DERBY-5367 is fixed, a bug where updating the index in a
database with a case insensitive collation resulted in data corruption.
|
private static junit.framework.Test |
collatedTest(java.lang.String locale,
java.lang.String fixture) |
protected void |
doExportTable(java.lang.String schemaName,
java.lang.String tableName,
java.lang.String fileName,
java.lang.String colDel,
java.lang.String charDel,
java.lang.String codeset)
Perform export using SYSCS_UTIL.SYSCS_EXPORT_TABLE procedure.
|
protected void |
doImportTable(java.lang.String schemaName,
java.lang.String tableName,
java.lang.String fileName,
java.lang.String colDel,
java.lang.String charDel,
java.lang.String codeset,
int replace)
Perform import using SYSCS_UTIL.SYSCS_IMPORT_TABLE procedure.
|
private void |
dropExtraCustomers(int counter) |
private void |
dropTable() |
private void |
formatLikeResults(java.sql.Connection conn,
java.lang.String query)
RESOLVE - unfinished LIKE test with dataset of all unicode characters
|
private static java.lang.String |
formatString(java.lang.String str,
boolean all)
RESOLVE - unfinished LIKE test with dataset of all unicode characters
|
private java.lang.String[][] |
full_row_set(int[] expected_order,
int start_offset,
int stop_offset,
boolean ascending_order)
Produce an expect row set given the order and asc/desc info.
|
private java.lang.String[][] |
full_row_single_value(int expected_row,
java.lang.String[] ret_list)
Produce an expect row set given list and offset of row in list.
|
protected void |
initializeConnection(java.sql.Connection conn)
Private/Protected setup/utility methods of This class:
|
private boolean |
isDatabaseBasicCollation() |
private void |
printLikeResults(java.sql.Connection conn)
RESOLVE - unfinished LIKE test with dataset of all unicode characters
|
private static void |
printRuleBasedCollator()
RESOLVE - unfinished LIKE test with dataset of all unicode characters
|
private void |
runAlterTableAddColumn(int db_index)
Add column test.
|
private void |
runAlterTableCompress(int db_index)
test paths through alter table compress
Tests:
T10: alter table compress with indexes
|
private void |
runAlterTableDropColumn(int db_index)
Drop column test.
|
private void |
runBulkInsert(int db_index)
Bulk insert test.
|
private void |
runDERBY_2703(int db_index)
Test simple call to DatabaseMetaData.getColumns()
This test is the same form of the getColumns() call that
the IMPORT and EXPORT system procedures depend on.
|
private void |
runDerby2670()
Test case for DERBY-2670 - problem with like in no like processing.
|
private void |
runDerby5367TestCode(java.lang.String table)
Runs the core code for the DERBY-5367 test.
|
private void |
runDerby5530TruncateIndex()
Tests that truncating a table with indexes leaves us with a valid set
of conglomerates.
|
private void |
runDerby5530TruncateNoIndex()
Tests that truncating a table without indexes leaves us with a valid
conglomerate.
|
private void |
runLikeTests(int db_index)
Test various like expressions against all string datatypes.
|
private void |
runQueries(int db_index,
java.lang.String create_idx_qry,
java.lang.String idx_name) |
private void |
runTestIter(int db_index)
Shared code to run all test cases against a single collation.
|
private void |
setUpALLVALS(java.sql.Connection conn)
RESOLVE - unfinished LIKE test with dataset of all unicode characters
|
private void |
setUpLikeTable() |
private void |
setUpTable()
Set up and clean up routines.
|
static junit.framework.Test |
suite() |
void |
testDefaultCollation()
Public Methods of This class:
|
void |
testDefaultJVMTerritoryCollation()
Test creating a TERRITORY_BASED collated database by only setting
the collation attribute.
|
void |
testEnglishCollation() |
void |
testNorwayCollation() |
void |
testPolishCollation() |
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, 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, setUp, toString
private static final boolean verbose_debug
private static final int TEST_DEFAULT
private static final int TEST_ENGLISH
private static final int TEST_POLISH
private static final int TEST_NORWAY
private static final java.lang.String[] NAMES
private static final int[] DEFAULT_NAME_ORDER
private static final int[] ENGLISH_NAME_ORDER
private static final int[] POLISH_NAME_ORDER
private static final int[] NORWAY_NAME_ORDER
private static final int[][] EXPECTED_NAME_ORDER
private static final java.lang.String[] LIKE_NAMES
Insert all data to tested against into LIKE_NAMES. A customer table will be filled with this data.
Insert test cases for like string into the LIKE_TEST_CASES, results are expected only to return a single row.
Insert actual string expected back for each language, for each test case in the {LANG}_LIKE_RESULT array. Insert null if no match is expected.
Current test tries all 4 datatypes, CHAR will blank pad making the results different than the other datatypes if data is shorter than type, thus a different set of LIKE clauses needs to be entered in the LIKE_CHAR_TEST_CASES which should match the same results in a CHAR field as does the corresponding LIKE_TEST_CASES test.
private static final java.lang.String[] LIKE_TEST_CASES
private static final java.lang.String[] LIKE_CHAR_TEST_CASES
private static final int[] DEFAULT_LIKE_RESULT
private static final int[] ENGLISH_LIKE_RESULT
private static final int[] POLISH_LIKE_RESULT
private static final int[] NORWAY_LIKE_RESULT
private static final int[][] EXPECTED_LIKE_RESULTS
private static final java.lang.String[] derby2670_pattern
private static final java.lang.String[][][] derby2670_pattern_result
public CollationTest2(java.lang.String name)
protected void initializeConnection(java.sql.Connection conn) throws java.sql.SQLException
initializeConnection
in class BaseJDBCTestCase
conn
- Connection to be intializedjava.sql.SQLException
- Error setting the initial state.private static final void printRuleBasedCollator()
private static final java.lang.String formatString(java.lang.String str, boolean all)
private final void formatLikeResults(java.sql.Connection conn, java.lang.String query) throws java.sql.SQLException
java.sql.SQLException
private final void printLikeResults(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
private void checkLangBasedQuery(java.lang.String query, java.lang.String[][] expectedResult, boolean ordered) throws java.sql.SQLException
java.sql.SQLException
private void checkParamQuery(java.lang.String query, java.lang.String[] param, int paramNumber, java.lang.String[][] expectedResult, boolean ordered) throws java.sql.SQLException
java.sql.SQLException
protected void doExportTable(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String colDel, java.lang.String charDel, java.lang.String codeset) throws java.sql.SQLException
java.sql.SQLException
protected void doImportTable(java.lang.String schemaName, java.lang.String tableName, java.lang.String fileName, java.lang.String colDel, java.lang.String charDel, java.lang.String codeset, int replace) throws java.sql.SQLException
java.sql.SQLException
private java.lang.String[][] full_row_set(int[] expected_order, int start_offset, int stop_offset, boolean ascending_order)
Given the expected order of rows, the offset of first and last row to return, and whether rows will be ascending or descending produce a 2d expected row set. Each row in the row set represents a row with 2 columns (ID, NAME) from the CUSTOMER table used throughout this test.
expected_order
- Expected order of rows in this language.start_offset
- expect rows starting at
expected_order[start_offset] up to and including
expected_order[stop_offset].stop_offset
- expect rows starting at
expected_order[start_offset] up to and including
expected_order[stop_offset].ascending_order
- true if rows are in order, else rows are in
reverse order.private java.lang.String[][] full_row_single_value(int expected_row, java.lang.String[] ret_list)
Given the list of rows and offset of the expected row in the list produce a 2d expected row set. If expected_row is -1 then no row set is returned. Each row in the row set represents a row with 2 columns (ID, NAME) from the CUSTOMER table used throughout this test.
expected_row
- -1 if no expected row, else
ret_list[expected_row] is single value expected.ret_list
- list of strings in data set.private boolean isDatabaseBasicCollation() throws java.sql.SQLException
java.sql.SQLException
private void setUpTable() throws java.sql.SQLException
java.sql.SQLException
private void addSomeMoreCustomers(int counter) throws java.sql.SQLException
java.sql.SQLException
private void addSomeMoreCustomers(int counter, boolean useD1, boolean useD2) throws java.sql.SQLException
java.sql.SQLException
private void dropExtraCustomers(int counter) throws java.sql.SQLException
java.sql.SQLException
private void setUpLikeTable() throws java.sql.SQLException
java.sql.SQLException
private void setUpALLVALS(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
private void runDERBY_2703(int db_index) throws java.sql.SQLException
This test is the same form of the getColumns() call that the IMPORT and EXPORT system procedures depend on. Currently on ibm and sun 1.4.2 jvm's this test fails.
java.sql.SQLException
public void ci_testDerby5367() throws java.sql.SQLException
The bug tested is where a deleted row with an incorrect key value in the index is undeleted as an optimized insert. In this case it was caused by the a case insensitive collation order, but other collation rules could cause this to happen as well.
java.sql.SQLException
private void runDerby5367TestCode(java.lang.String table) throws java.sql.SQLException
java.sql.SQLException
private void checkSimpleCompare(int[] expected_order) throws java.sql.SQLException
Check <, <=, =, >=, > of constant to column, ie. of the form select * from table where col boolean constant
java.sql.SQLException
private void checkTwoPersistentCompare(int[] expected_order) throws java.sql.SQLException
Check <, &glt;=, =, >=, > of constant to column, ie. of the form select * from table where col boolean constant
java.sql.SQLException
private void dropTable() throws java.sql.SQLException
java.sql.SQLException
private void runQueries(int db_index, java.lang.String create_idx_qry, java.lang.String idx_name) throws java.sql.SQLException
java.sql.SQLException
private void runLikeTests(int db_index) throws java.sql.SQLException
java.sql.SQLException
private void runAlterTableCompress(int db_index) throws java.sql.SQLException
java.sql.SQLException
private void runAlterTableDropColumn(int db_index) throws java.sql.SQLException
Drop column will drop and recreate base table and associated indexes, need to test to make sure correct colation ids get passed to new containers. Tests: T11: alter table drop column with indexes
java.sql.SQLException
private void runAlterTableAddColumn(int db_index) throws java.sql.SQLException
Add column adds a new template column which requires a collation info related store update. Test that added column had right collation setting. Tests: T12: alter table add column with index
java.sql.SQLException
private void runBulkInsert(int db_index) throws java.sql.SQLException
Tests code path through create conglomerate code executed as part of a bulk table insert. In empty table and replace case the bulk table code will create new conglomerates for the base table and index table and this tests the code that the correct collation is associated with the new tables/indexes. Tests: T13: (DONE) bulk insert into empty table, with and without indexes T14: (DONE) bulk insert replace, with and without indexes
java.sql.SQLException
private void runDerby2670() throws java.sql.SQLException
Before fix, the table/query below would return results like B and C, obviously wrong for like %a%. The code was incorrectly caching collation key info in a DataValueDescriptor across the reuse of the holder object from one row to the next.
Added more patterns to also test DERBY-2710 and DERBY-2706, both to do with bad like optimization which can not be applied to collation based like.
java.sql.SQLException
private void runDerby5530TruncateIndex() throws java.sql.SQLException
java.sql.SQLException
private void runDerby5530TruncateNoIndex() throws java.sql.SQLException
java.sql.SQLException
private void runTestIter(int db_index) throws java.sql.SQLException
Pass in the index of which TEST_DATABASE database to test. So for instance to run the default, pass in 0.
db_index
- index of which test to run.java.sql.SQLException
public void testDefaultCollation() throws java.sql.SQLException
java.sql.SQLException
public void testEnglishCollation() throws java.sql.SQLException
java.sql.SQLException
public void testPolishCollation() throws java.sql.SQLException
java.sql.SQLException
public void testNorwayCollation() throws java.sql.SQLException
java.sql.SQLException
public void testDefaultJVMTerritoryCollation() throws java.sql.SQLException
java.sql.SQLException
public static junit.framework.Test suite()
private static junit.framework.Test collatedTest(java.lang.String locale, java.lang.String fixture)
private static junit.framework.Test caseInsensitiveCollationSuite()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.