public class TriggerTest extends BaseJDBCTestCase
| Modifier and Type | Field and Description |
|---|---|
(package private) java.lang.StringBuffer |
listOfCreatedTriggers |
private static java.lang.ThreadLocal |
TRIGGER_INFO
Thread local that a trigger can access to
allow recording information about the firing.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE| Constructor and Description |
|---|
TriggerTest(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
private void |
actionTypesCompareMainToAction(int actionCount,
java.lang.String type)
Compare the contents of the main table to the action table.
|
private void |
actionTypesCompareMainToActionForUpdate(java.lang.String type,
int id)
Compare the values for an update trigger.
|
private void |
actionTypesDeleteTest(java.lang.String type)
Test deletes with the specified types in the action statement.
|
private void |
actionTypesInsertTest(java.lang.String type)
Execute three insert statements.
|
private void |
actionTypesSetup(java.lang.String type)
Setup the tables and triggers for a single type for actionTypeTest
|
private void |
actionTypesUpdateTest(java.lang.String type)
Test updates of the specified types in the action statement.
|
private void |
actionTypeTest(java.lang.String type)
Test that the action statement of a trigger
can work with a specific datatype.
|
private int |
assertFiringOrder(java.lang.String iud,
int modifiedRowCount)
Look at the ordered information in the thread local
and ensure it reflects correct sequenceing of
triggers created in testFiringOrder.
|
private int |
assertFiringOrder(java.lang.String iud,
int modifiedRowCount,
boolean noAfter) |
private int[] |
createRandomTriggers() |
static void |
derby4610proc(java.lang.String str)
Procedure that does nothing.
|
static java.lang.Object |
getRandomValue(java.util.Random r,
int jdbcType,
int precision)
Generate a random object (never null) for
a given JDBC type.
|
protected void |
initializeConnection(java.sql.Connection conn)
Allow a sub-class to initialize a connection to provide
consistent connection state for its tests.
|
static void |
logTriggerInfo(java.lang.String info)
Record the trigger information in the thread local.
|
private int |
numberOfInvalidStatementsInSysstatements(java.sql.Statement st) |
private int |
numberOfRowsInSysstatements(java.sql.Statement st) |
private int |
numberOfValidStatementsInSysstatements(java.sql.Statement st) |
private static byte[] |
randomBinary(java.util.Random r,
int len) |
private static java.lang.String |
randomString(java.util.Random r,
int len) |
static void |
setRandomValue(java.util.Random r,
java.sql.PreparedStatement ps,
int column,
int jdbcType,
int precision) |
protected void |
setUp() |
static junit.framework.Test |
suite()
Run only in embedded as TRIGGERs are server side logic.
|
protected void |
tearDown()
Tear down this fixture, sub-classes should call
super.tearDown().
|
void |
testAlerColumnLength()
Altering the column length should regenerate the trigger
action plan which is saved in SYSSTATEMENTS.
|
void |
testBlobInTriggerTable()
Test for DERBY-3238 trigger fails with IOException if triggering table has large lob.
|
private void |
testBlobInTriggerTable(int blobSize)
Create a table with after update trigger on non-lob column.
|
void |
testClobInTriggerTable()
Test for DERBY-3238 trigger fails with IOException if triggering table has large lob.
|
private void |
testClobInTriggerTable(int clobSize)
Create a table with after update trigger on non-lob column.
|
void |
testDerby4095NewTriggerRows()
Test that a nested loop join that accesses the
TriggerNewTransitionRowsVTI can reopen the ResultSet properly
when it re-executes.
|
void |
testDerby4095OldTriggerRows()
Test that a nested loop join that accesses the
TriggerOldTransitionRowsVTI can reopen the ResultSet properly
when it re-executes.
|
void |
testDerby4610WrongDataType()
Regression test case for DERBY-4610, where a DELETE statement failed
because a trigger used the wrong meta-data and mixed up the data types.
|
void |
testDERBY5121() |
void |
testDerby5578InvalidateAllStatementsProc()
Test that invalidating stored statements marks the statement invalid
in SYS.SYSSTATEMENTS.
|
void |
testDerby6348() |
void |
testDerby6351TransitionTableCorrelation()
Regression test case for DERBY-6351, where CREATE TRIGGER would fail
with a syntax error if the triggered SQL statement referenced a
transition table using a correlation name, and that correlation name
was equal to the transition table name.
|
void |
testDerby6357TempTable()
Verify that CREATE TRIGGER fails if a temporary table is referenced.
|
void |
testDerby6371DropColumn()
Verify the fix for DERBY-6371.
|
void |
testDerby6383StatementTriggerBugTst1()
DERBY-6383(Update trigger defined on one column fires on update
of other columns).
|
void |
testDerby6383StatementTriggerBugTst2()
DERBY-6383(Update trigger defined on one column fires on update
of other columns).
|
void |
testFiringConstraintOrder()
Test that a order of firing is before triggers,
constraint checking and after triggers.
|
void |
testFiringOrder()
Test the firing order of triggers.
|
void |
testNPEinTriggerFire()
Test for DERBY-3718 NPE when a trigger is fired
|
void |
testReadRequiredColumnsOnlyFromTriggerTable() |
void |
testTypesInActionStatement()
Test that the action statement of a trigger
can work with all datatypes.
|
void |
testUpdateTriggerOnClobColumn() |
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, emptyStatementCache, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbeddedalarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isJava8, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemProperty, sleep, sleepAtLeastOneTick, traceitassertEquals, 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, toStringprivate static java.lang.ThreadLocal TRIGGER_INFO
java.lang.StringBuffer listOfCreatedTriggers
public static junit.framework.Test suite()
protected void initializeConnection(java.sql.Connection conn)
throws java.sql.SQLException
BaseJDBCTestCaseinitializeConnection in class BaseJDBCTestCaseconn - Connection to be intializedjava.sql.SQLException - Error setting the initial state.protected void setUp()
throws java.lang.Exception
setUp in class junit.framework.TestCasejava.lang.Exceptionprotected void tearDown()
throws java.lang.Exception
BaseJDBCTestCasetearDown in class BaseJDBCTestCasejava.lang.Exceptionpublic void testDerby6383StatementTriggerBugTst1()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testDerby6383StatementTriggerBugTst2()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testDerby5578InvalidateAllStatementsProc()
throws java.sql.SQLException
java.sql.SQLExceptionprivate int numberOfInvalidStatementsInSysstatements(java.sql.Statement st)
throws java.sql.SQLException
java.sql.SQLExceptionprivate int numberOfValidStatementsInSysstatements(java.sql.Statement st)
throws java.sql.SQLException
java.sql.SQLExceptionprivate int numberOfRowsInSysstatements(java.sql.Statement st)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testAlerColumnLength()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testFiringOrder()
throws java.sql.SQLException
java.sql.SQLExceptionprivate int[] createRandomTriggers()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testFiringConstraintOrder()
throws java.sql.SQLException
java.sql.SQLExceptionprivate int assertFiringOrder(java.lang.String iud,
int modifiedRowCount)
iud - private int assertFiringOrder(java.lang.String iud,
int modifiedRowCount,
boolean noAfter)
public static void logTriggerInfo(java.lang.String info)
info - trigger informationpublic void testNPEinTriggerFire()
throws java.sql.SQLException
java.sql.SQLExceptionjava.io.IOExceptionpublic void testReadRequiredColumnsOnlyFromTriggerTable()
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionpublic void testDERBY5121()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testClobInTriggerTable()
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionprivate void testClobInTriggerTable(int clobSize)
throws java.sql.SQLException,
java.io.IOException
clobSize - size of clob to testjava.sql.SQLExceptionjava.io.IOExceptionpublic void testBlobInTriggerTable()
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionprivate void testBlobInTriggerTable(int blobSize)
throws java.sql.SQLException,
java.io.IOException
blobSize - size of blob to test.java.sql.SQLExceptionjava.io.IOExceptionpublic void testUpdateTriggerOnClobColumn()
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionpublic void testTypesInActionStatement()
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionprivate void actionTypeTest(java.lang.String type)
throws java.sql.SQLException,
java.io.IOException
type - SQL type to be testedjava.sql.SQLExceptionjava.io.IOExceptionprivate void actionTypesSetup(java.lang.String type)
throws java.sql.SQLException
java.sql.SQLExceptionprivate void actionTypesInsertTest(java.lang.String type)
throws java.sql.SQLException,
java.io.IOException
type - java.sql.SQLExceptionjava.io.IOExceptionprivate void actionTypesUpdateTest(java.lang.String type)
throws java.sql.SQLException,
java.io.IOException
type - java.sql.SQLExceptionjava.io.IOExceptionprivate void actionTypesCompareMainToActionForUpdate(java.lang.String type,
int id)
throws java.sql.SQLException,
java.io.IOException
type - id - java.sql.SQLExceptionjava.io.IOExceptionprivate void actionTypesDeleteTest(java.lang.String type)
throws java.sql.SQLException,
java.io.IOException
type - java.sql.SQLExceptionjava.io.IOExceptionprivate void actionTypesCompareMainToAction(int actionCount,
java.lang.String type)
throws java.sql.SQLException,
java.io.IOException
actionCount - type - java.sql.SQLExceptionjava.io.IOExceptionpublic static void setRandomValue(java.util.Random r,
java.sql.PreparedStatement ps,
int column,
int jdbcType,
int precision)
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionpublic static java.lang.Object getRandomValue(java.util.Random r,
int jdbcType,
int precision)
throws java.io.IOException
Caller should check the return type using instanceof and use setCharacterStream() for Reader objects and setBinaryStream for InputStreams. (work in progress)
java.io.IOExceptionprivate static byte[] randomBinary(java.util.Random r,
int len)
private static java.lang.String randomString(java.util.Random r,
int len)
public void testDerby4095OldTriggerRows()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testDerby4095NewTriggerRows()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testDerby4610WrongDataType()
throws java.sql.SQLException
java.sql.SQLExceptionpublic static void derby4610proc(java.lang.String str)
public void testDerby6351TransitionTableCorrelation()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testDerby6357TempTable()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testDerby6348()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testDerby6371DropColumn()
throws java.sql.SQLException
java.sql.SQLExceptionApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.