public class XATransactionTest extends BaseJDBCTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
XATransactionTest(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
(package private) static javax.transaction.xa.Xid |
createXid(int gtrid,
int bqual)
Create the Xid object for global transaction identification
with the specified identification values.
|
private static javax.transaction.xa.Xid |
parseXid(java.lang.String str)
Parses the xid value from the string.
|
static junit.framework.Test |
suite() |
void |
testDerby5562ReadOnlyTimeout()
Regression test case for DERBY-5562.
|
void |
testForgetExceptionDerby1016NOTA()
Further test case prompted by DERBY-1016.
|
void |
testForgetExceptionDerby1016PROTO()
This fixture triggers DERBY-1016.
|
void |
testGlobalXIDinTransactionTable()
Tests whether it is possible to reconstruct the original Xid value
correctly from SYSCS_DIAG.TRANSACTION_TABLE.
|
void |
testPendingLocalTranAndServerShutdown()
This test does following
1)Start the network server
2)Start a local xa transaction
3)Do not commit the local XA transaction
4)Shutdown the network server
5)Start the server again
Before the fix for DERBY-4053 went in, step 4) would not shutdown the
server properly because of the pending local XA transaction.
|
void |
testTransactionTimeoutAndJoin()
DERBY-4232: Test that two branches can be joined after the timeout has
been set.
|
void |
testTransactionTimeoutAndSuspendResume()
DERBY-4232: Test that an XA transaction can be suspended and resumed
when a timeout is in effect.
|
void |
testXAExceptionErrorCodeOnSQLExceptionDerby4141()
DERBY-4141 XAExceptions caused by SQLExceptions should have a
non-zero errorCode.
|
void |
testXATransactionTimeout()
Tests the functionality of the XA transaction timeout.
|
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, setUp, toString
public void testPendingLocalTranAndServerShutdown() throws java.lang.Exception
java.lang.Exception
public void testGlobalXIDinTransactionTable() throws java.lang.Exception
java.lang.Exception
public void testXATransactionTimeout() throws java.lang.Exception
It executes 66 global transactions during the test. Everyone of them just inserts a row into XATT table. The rows inserted by the transactions are different. Some of these transactions are committed and some of them are left in different stages. The stage of the transaction in which it is left is chosed depending on division remainders.
After finishing these 1000 transactions a select statement is executed on that table. However, if there are still some unfinished transactions that were not aborted they will hold a lock on a XATT table until they will get rolled back by the transaction timeout. The number of rows in the XATT table is calculated. It is then compared with the excepted number of rows (the transaction we know we have committed).
The call to xaRes.setTransactionTimeout(5) before the call to xaRes.start() makes the transactions to be rolled back due to timeout.
java.lang.Exception
public void testTransactionTimeoutAndSuspendResume() throws java.lang.Exception
java.lang.Exception
public void testTransactionTimeoutAndJoin() throws java.lang.Exception
java.lang.Exception
public void testXAExceptionErrorCodeOnSQLExceptionDerby4141() throws java.lang.Exception
java.lang.Exception
public void testForgetExceptionDerby1016PROTO() throws javax.transaction.xa.XAException, java.sql.SQLException
javax.transaction.xa.XAException
java.sql.SQLException
public void testForgetExceptionDerby1016NOTA() throws javax.transaction.xa.XAException, java.sql.SQLException
javax.transaction.xa.XAException
java.sql.SQLException
public void testDerby5562ReadOnlyTimeout() throws java.lang.InterruptedException, java.sql.SQLException, javax.transaction.xa.XAException
Regression test case for DERBY-5562.
The timer that aborts long-running transactions if a transaction timeout has been specified, was not cancelled when preparing a read-only transaction. Since read-only transactions are implicitly committed when they are prepared, this meant that the timer would try to abort an already completed transaction. In addition to printing a confusing message in derby.log about the transaction being rolled back, when it actually had been committed, this could also make the timer roll back the wrong transaction, if a new transaction with the same Xid was started later.
This test case exposes the bug by running a read-only transaction with a timeout and preparing it, and then starting a new transaction with the same Xid and no timeout. The bug would cause the second transaction to time out.
java.lang.InterruptedException
java.sql.SQLException
javax.transaction.xa.XAException
static javax.transaction.xa.Xid createXid(int gtrid, int bqual) throws javax.transaction.xa.XAException
gtrid
- Global Transaction IDbqual
- Branch Qualifierjavax.transaction.xa.XAException
private static javax.transaction.xa.Xid parseXid(java.lang.String str)
str
- Global Transaction ID converted to a string.public static junit.framework.Test suite()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.