public class BooleanValuesTest extends GeneratedColumnsHelper
Test Derby's expanding support for BOOLEAN values.
Modifier and Type | Field and Description |
---|---|
private boolean |
_supportsXML |
private static java.lang.String |
BAD_CAST |
private static java.lang.String |
BAD_CONVERSION |
private static java.lang.String |
BAD_DEFAULT |
private static java.lang.String |
ILLEGAL_GET |
private static java.lang.String |
ILLEGAL_INSERT |
private static java.lang.String |
ILLEGAL_UPDATE |
private static java.lang.String |
ILLEGAL_XML_SELECTION |
private static java.lang.String |
NON_BOOLEAN_OPERAND |
private static java.lang.String |
NOT_UNION_COMPATIBLE |
BAD_BEFORE_TRIGGER, BAD_FOREIGN_KEY_ACTION, CANT_CONTAIN_NULLS, CANT_MODIFY_IDENTITY, CANT_OVERRIDE_GENERATION_CLAUSE, CANT_REFERENCE_GENERATED_COLUMN, CASCADED_COLUMN_DROP_WARNING, COLUMN_OUT_OF_SCOPE, CONSTRAINT_DROPPED_WARNING, CONSTRAINT_VIOLATION, DUPLICATE_CLAUSE, FORBIDDEN_DROP_TRIGGER, FORBIDDEN_ORDERING_OPERATION, FOREIGN_KEY_VIOLATION, GRANT_REVOKE_NOT_ALLOWED, ILLEGAL_ADD_DEFAULT, ILLEGAL_AGG, ILLEGAL_AGGREGATE, ILLEGAL_COMPARISON, ILLEGAL_DUPLICATE, ILLEGAL_RENAME, ILLEGAL_STORAGE, ILLEGAL_UDT_CLASS, JAVA_EXCEPTION, LACK_COLUMN_PRIV, LACK_EXECUTE_PRIV, LACK_TABLE_PRIV, LACK_USAGE_PRIV, LANG_INVALID_USE_OF_DEFAULT, LEXICAL_ERROR, LOCK_TIMEOUT, MISSING_OBJECT, NEED_EXPLICIT_DATATYPE, NO_GENERIC_PERMISSION, NO_SELECT_OR_UPDATE_PERMISSION, NO_TABLE_PERMISSION, NON_EMPTY_SCHEMA, NONEXISTENT_OBJECT, NOT_IMPLEMENTED, NOT_NULL_NEEDS_DATATYPE, NOT_NULL_VIOLATION, OBJECT_DOES_NOT_EXIST, OPERATION_FORBIDDEN, REDUNDANT_CLAUSE, ROUTINE_CANT_ISSUE_SQL, ROUTINE_DEPENDS_ON_TYPE, STRING_TRUNCATION, SYNTAX_ERROR, TABLE_DEPENDS_ON_TYPE, TOO_MUCH_CONTENTION, TRIGGER_DROPPED_WARNING, UNSTABLE_RESULTS, VIEW_DEPENDENCY
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
BooleanValuesTest(java.lang.String name)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
assertScalarResult(java.sql.PreparedStatement ps,
java.lang.String result) |
static java.lang.String |
booleanValue(java.lang.Boolean b) |
private void |
generatedMinion(java.sql.Connection conn) |
private java.lang.String |
makeQuery(java.lang.String columnName) |
static java.sql.Blob |
makeSimpleBlob() |
private void |
minion_4889(java.sql.Connection conn,
int value,
boolean expectedBooleanResult) |
private boolean |
routineExists(java.sql.Connection conn,
java.lang.String functionName)
Return true if the SQL routine exists
|
protected void |
setUp() |
static junit.framework.Test |
suite()
Construct top level suite in this JUnit test
|
private boolean |
tableExists(java.sql.Connection conn,
java.lang.String tableName)
Return true if the table exists
|
void |
test_01_datatypeCount()
Verify the number of datatypes supported by Derby.
|
void |
test_02_defined()
Test that ResultSet.getBoolean() behaves well for the datatypes for
which the JDBC spec defines correct values: CHAR, VARCHAR, TINYINT,
SMALLINT, INTEGER, BIGINT.
|
void |
test_03_undefinedButLegal()
Verifies Derby's behavior is the same for embedded and client
drivers on datatypes for which the JDBC spec does not define results
but which Derby handles.
|
void |
test_04_undefinedAndIllegal()
Verify Derby's behavior is the same for embedded and client
drivers on datatypes for which the JDBC spec does not define results
and which Derby does not handle.
|
void |
test_05_undefinedIllegalOutliers()
Regression tests for outliers.
|
void |
test_06_unions()
Test that unions fail if one but not both sides of the union is BOOLEAN.
|
void |
test_07_booleanLiterals()
Verify that boolean literals work.
|
void |
test_08_stringCasts()
Verify that explicit casts to and from string work as expected.
|
void |
test_09_explicitCasts()
Verify that most explicit casts to and from boolean are not allowed.
|
void |
test_10_nullabilityOfCastFromLiteral() |
void |
test_11_booleanFunctionParameters()
Verify that boolean function parameters behave well.
|
void |
test_12_booleanColumns()
Verify that tables with boolean columns behave well.
|
void |
test_13_sortOrder()
Verify that boolean nulls sort at the end with or without an index,
the behavior of other datatypes.
|
void |
test_14_defaults()
Verify that you can declare literal defaults for boolean columns.
|
void |
test_15_selectList()
Verify that you can have boolean expressions in the SELECT list.
|
void |
test_16_alterTable()
Verify that you can alter a table and add boolean columns.
|
void |
test_17_generatedColumns()
Verify that you can create boolean-valued generated columns.
|
void |
test_18_views()
Verify views with boolean columns.
|
void |
test_19_foreignKeys()
Verify booleans in foreign keys.
|
void |
test_20_checkConstraints()
Verify booleans in check constraints.
|
void |
test_21_triggers()
Verify triggers on boolean columns.
|
void |
test_22_binary_operators()
Test that the binary operators return the expected values for all
possible combinations of operands.
|
void |
test_23_select_distinct()
Verify that SELECT DISTINCT works as expected on boolean columns.
|
void |
test_4889()
Verify fix for DERBY-4890.
|
void |
test_4890()
Verify fix for DERBY-4890.
|
private void |
test_4964_minion(java.sql.PreparedStatement ps,
java.lang.String input,
java.lang.Object expectedValue)
Set a boolean parameter using a string value and verify that we get
the expected result.
|
void |
test_4964()
Verify fix for DERBY-4964 - failure to convert string to boolean with
the client driver.
|
void |
test_4965()
Verify fix for DERBY-4965 - conversion from boolean to char results
in 1/0 instead of true/false.
|
void |
test_5042_updateBoolean()
Verify fix for DERBY-5042, where updateBoolean() and updateObject()
would fail on a BOOLEAN column when using the client driver.
|
void |
test_5063_updateBytes()
Verify fix for DERBY-5063 - updateBytes() should fail when invoked
on boolean columns.
|
void |
test_5918()
Verify that you can use CREATE TABLE AS SELECT to create
empty tables with BOOLEAN columns.
|
void |
test_5972()
Verify that you can use AND and OR expressions as BOOLEAN values.
|
void |
test_6363()
Some BOOLEAN expressions used to be transformed to non-equivalent
IN lists.
|
private void |
vet_getBoolean(java.sql.Connection conn,
java.lang.String columnName)
Test that ResultSet.getBoolean() returns the correct value.
|
private void |
vet_getBooleanException(java.sql.Connection conn,
java.lang.String columnName,
java.lang.String sqlstate)
Test that ResultSet.getBoolean() raises the expected error.
|
private void |
vet_getBooleanIsIllegal(java.sql.Connection conn,
java.lang.String columnName)
Test that ResultSet.getBoolean() raises an error on datatypes which
Derby doesn't handle.
|
void |
vet4704()
Regression test case for DERBY-4704.
|
private void |
vetBadExplicitCastFromBoolean(java.sql.Connection conn,
java.lang.String dataType) |
private void |
vetBadExplicitCasts(java.sql.Connection conn,
java.lang.String columnName,
java.lang.String dataType,
java.lang.String literal) |
private void |
vetBadExplicitCastToBoolean(java.sql.Connection conn,
java.lang.String columnName,
java.lang.String literal) |
private void |
vetBadImplicitCastFromBoolean(java.sql.Connection conn,
java.lang.String columnName) |
private void |
vetBadImplicitCasts(java.sql.Connection conn,
java.lang.String columnName) |
private void |
vetBadImplicitCastToBoolean(java.sql.Connection conn,
java.lang.String columnName) |
private void |
vetBadInsert(java.lang.String columnName) |
private void |
vetBadStringCast(java.sql.Connection conn,
java.lang.String columnName) |
private void |
vetStringInsert(java.sql.Connection conn,
java.lang.String columnName) |
assertColumnTypes, assertDeterministic, expectExecutionWarning, expectExecutionWarnings, expectInsertRowError, expectNoWarning, expectUpdateRowError, fill, verifyRestrictedDrop, verifyRevokePrivilege
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
private static final java.lang.String ILLEGAL_GET
private static final java.lang.String ILLEGAL_XML_SELECTION
private static final java.lang.String BAD_CAST
private static final java.lang.String NOT_UNION_COMPATIBLE
private static final java.lang.String BAD_CONVERSION
private static final java.lang.String ILLEGAL_INSERT
private static final java.lang.String BAD_DEFAULT
private static final java.lang.String ILLEGAL_UPDATE
private static final java.lang.String NON_BOOLEAN_OPERAND
private boolean _supportsXML
public BooleanValuesTest(java.lang.String name)
public static junit.framework.Test suite()
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
public void test_01_datatypeCount() throws java.lang.Exception
Verify the number of datatypes supported by Derby. If this number changes, then you need to add a new datatype to this test:
java.lang.Exception
public void test_02_defined() throws java.lang.Exception
Test that ResultSet.getBoolean() behaves well for the datatypes for which the JDBC spec defines correct values: CHAR, VARCHAR, TINYINT, SMALLINT, INTEGER, BIGINT.
java.lang.Exception
public void test_03_undefinedButLegal() throws java.lang.Exception
Verifies Derby's behavior is the same for embedded and client drivers on datatypes for which the JDBC spec does not define results but which Derby handles.
java.lang.Exception
public void test_04_undefinedAndIllegal() throws java.lang.Exception
Verify Derby's behavior is the same for embedded and client drivers on datatypes for which the JDBC spec does not define results and which Derby does not handle.
java.lang.Exception
public void test_05_undefinedIllegalOutliers() throws java.lang.Exception
Regression tests for outliers. If this behavior changes, hopefully the new behavior will fit into one of the categories above.
java.lang.Exception
private void vet_getBoolean(java.sql.Connection conn, java.lang.String columnName) throws java.lang.Exception
Test that ResultSet.getBoolean() returns the correct value. Expects to select a result set with the following rows:
0 0 1 1 2 2 3 for string columns, something other than a number
java.lang.Exception
private java.lang.String makeQuery(java.lang.String columnName)
private void vet_getBooleanIsIllegal(java.sql.Connection conn, java.lang.String columnName) throws java.lang.Exception
Test that ResultSet.getBoolean() raises an error on datatypes which Derby doesn't handle.
java.lang.Exception
private void vet_getBooleanException(java.sql.Connection conn, java.lang.String columnName, java.lang.String sqlstate) throws java.lang.Exception
Test that ResultSet.getBoolean() raises the expected error.
java.lang.Exception
public void test_06_unions() throws java.lang.Exception
Test that unions fail if one but not both sides of the union is BOOLEAN. The rules for union
compatibility are found in the SQL Standard, part 2, section 7.3 (
java.lang.Exception
private void vetBadImplicitCasts(java.sql.Connection conn, java.lang.String columnName) throws java.lang.Exception
java.lang.Exception
private void vetBadImplicitCastToBoolean(java.sql.Connection conn, java.lang.String columnName) throws java.lang.Exception
java.lang.Exception
private void vetBadImplicitCastFromBoolean(java.sql.Connection conn, java.lang.String columnName) throws java.lang.Exception
java.lang.Exception
public void test_07_booleanLiterals() throws java.lang.Exception
Verify that boolean literals work.
java.lang.Exception
public void test_08_stringCasts() throws java.lang.Exception
Verify that explicit casts to and from string work as expected.
java.lang.Exception
public void test_09_explicitCasts() throws java.lang.Exception
Verify that most explicit casts to and from boolean are not allowed.
java.lang.Exception
private void vetBadStringCast(java.sql.Connection conn, java.lang.String columnName) throws java.lang.Exception
java.lang.Exception
private void vetBadExplicitCasts(java.sql.Connection conn, java.lang.String columnName, java.lang.String dataType, java.lang.String literal) throws java.lang.Exception
java.lang.Exception
private void vetBadExplicitCastToBoolean(java.sql.Connection conn, java.lang.String columnName, java.lang.String literal) throws java.lang.Exception
java.lang.Exception
private void vetBadExplicitCastFromBoolean(java.sql.Connection conn, java.lang.String dataType) throws java.lang.Exception
java.lang.Exception
public void vet4704() throws java.sql.SQLException
java.sql.SQLException
public void test_10_nullabilityOfCastFromLiteral() throws java.sql.SQLException
java.sql.SQLException
public void test_11_booleanFunctionParameters() throws java.lang.Exception
Verify that boolean function parameters behave well.
java.lang.Exception
private void assertScalarResult(java.sql.PreparedStatement ps, java.lang.String result) throws java.lang.Exception
java.lang.Exception
public void test_12_booleanColumns() throws java.lang.Exception
Verify that tables with boolean columns behave well.
java.lang.Exception
private void vetBadInsert(java.lang.String columnName) throws java.lang.Exception
java.lang.Exception
private void vetStringInsert(java.sql.Connection conn, java.lang.String columnName) throws java.lang.Exception
java.lang.Exception
public void test_13_sortOrder() throws java.lang.Exception
Verify that boolean nulls sort at the end with or without an index, the behavior of other datatypes.
java.lang.Exception
public void test_14_defaults() throws java.lang.Exception
Verify that you can declare literal defaults for boolean columns.
java.lang.Exception
public void test_15_selectList() throws java.lang.Exception
Verify that you can have boolean expressions in the SELECT list.
java.lang.Exception
public void test_16_alterTable() throws java.lang.Exception
Verify that you can alter a table and add boolean columns.
java.lang.Exception
public void test_17_generatedColumns() throws java.lang.Exception
Verify that you can create boolean-valued generated columns.
java.lang.Exception
private void generatedMinion(java.sql.Connection conn) throws java.lang.Exception
java.lang.Exception
public void test_18_views() throws java.lang.Exception
Verify views with boolean columns.
java.lang.Exception
public void test_19_foreignKeys() throws java.lang.Exception
Verify booleans in foreign keys.
java.lang.Exception
public void test_20_checkConstraints() throws java.lang.Exception
Verify booleans in check constraints.
java.lang.Exception
public void test_21_triggers() throws java.lang.Exception
Verify triggers on boolean columns.
java.lang.Exception
public void test_22_binary_operators() throws java.sql.SQLException
java.sql.SQLException
public void test_23_select_distinct() throws java.sql.SQLException
java.sql.SQLException
public void test_4890() throws java.lang.Exception
Verify fix for DERBY-4890.
java.lang.Exception
public void test_4889() throws java.lang.Exception
Verify fix for DERBY-4890.
java.lang.Exception
private void minion_4889(java.sql.Connection conn, int value, boolean expectedBooleanResult) throws java.lang.Exception
java.lang.Exception
public void test_4964() throws java.sql.SQLException
java.sql.SQLException
private void test_4964_minion(java.sql.PreparedStatement ps, java.lang.String input, java.lang.Object expectedValue) throws java.sql.SQLException
ps
- a prepared statement that takes a boolean parameterinput
- input string for the parameterexpectedValue
- the expected result; either the expected Boolean return
value if the operation is expected to succeed, or the SQLState of the
exception if it is expected to failjava.sql.SQLException
public void test_4965() throws java.sql.SQLException
java.sql.SQLException
public void test_5042_updateBoolean() throws java.sql.SQLException
java.sql.SQLException
public void test_5063_updateBytes() throws java.sql.SQLException
java.sql.SQLException
public void test_5918() throws java.lang.Exception
java.lang.Exception
public void test_5972() throws java.sql.SQLException
java.sql.SQLException
public void test_6363() throws java.sql.SQLException
java.sql.SQLException
public static java.sql.Blob makeSimpleBlob() throws java.sql.SQLException
java.sql.SQLException
public static java.lang.String booleanValue(java.lang.Boolean b)
private boolean routineExists(java.sql.Connection conn, java.lang.String functionName) throws java.lang.Exception
java.lang.Exception
private boolean tableExists(java.sql.Connection conn, java.lang.String tableName) throws java.lang.Exception
java.lang.Exception
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.