public class BatchUpdateTest extends BaseJDBCTestCase
This test examines the behavior fo BatchUpdate test. One fixture tests creating tables in batch, the other fixtures can be grouped into 5 rough categories: - tests that verify that correct usage with Statements work as expected - testEmptyStatementBatch() try executing a batch which nothing in it. - testSingleStatementBatch() try executing a batch which one statement in it. - testMultipleStatementsBatch() try executing a batch with 3 different statements in it. - test1000StatementsBatch() try executing a batch with 1000 statements in it. - testAutoCommitTrueBatch() try batch with autocommit true - testCombinationsOfClearBatch() try clear batch - testAssociatedParams() confirm associated parameters run ok with batches - tests that verify that incorrect usage with Statments give appropriate errors - testStatementWithResultSetBatch() statements which will return a resultset are not allowed in batch update. The following case should throw an exception for select. Below trying various placements of select statement in the batch, i.e. as 1st stmt, nth stmt and last stmt - testStatementNonBatchStuffInBatch() try executing a batch with regular statement intermingled. - testStatementWithErrorsBatch() Below trying various placements of overflow update statement in the batch, i.e. as 1st stmt, nth stat and last stmt - testTransactionErrorBatch() try transaction error, i.e. time out while getting the lock - tests that verify that usage with callableStatements work as expected - testCallableStatementBatch() try callable statements - testCallableStatementWithOutputParamBatch() try callable statement with output parameters - tests that verify that correct usage with preparedStatements work as expected - testEmptyValueSetPreparedBatch() try executing a batch which nothing in it. - testNoParametersPreparedBatch() try executing a batch with no parameters. - testSingleValueSetPreparedBatch() try executing a batch which one parameter set in it. - testMultipleValueSetPreparedBatch() try executing a batch with 3 parameter sets in it. - testMultipleValueSetNullPreparedBatch() try executing a batch with 2 parameter sets in it and they are set to null. - test1000ValueSetPreparedBatch() try executing a batch with 1000 statements in it. - testPreparedStatRollbackAndCommitCombinations() try executing batches with various rollback and commit combinations. - testAutoCommitTruePreparedStatBatch() try prepared statement batch with autocommit true - testCombinationsOfClearPreparedStatBatch() try clear batch - tests that verify that incorrect use with preparedStatements give appropriate errors - testPreparedStmtWithResultSetBatch() statements which will return a resultset are not allowed in batch update. The following case should throw an exception for select. - testPreparedStmtNonBatchStuffInBatch(); try executing a batch with regular statement intermingled. - testPreparedStmtWithErrorsBatch(); trying various placements of overflow update statement in the batch - testTransactionErrorPreparedStmtBatch() try transaction error, in this particular case time out while getting the lock Almost all fixtures but 1 execute with embedded and NetworkServer/DerbyNetClient - however, there is a difference in functionality between the two when an error condition is reaches. Thus, the negative tests have if / else if blocks for embedded and client. The 1 fixture that ise not running with network server is identified with //TODO: tags and has an if (usingEmbedded()) block and a JIRA issue attached to it.
Modifier and Type | Class and Description |
---|---|
static class |
BatchUpdateTest.BatchUpdateExceptionWrapper
This wrapper is used to expose JDBC 4.2 methods which can run on
VM rev levels lower than Java 8.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
BatchUpdateTest(java.lang.String name)
Creates a new instance of BatchUpdateTest
|
Modifier and Type | Method and Description |
---|---|
static void |
assertBatchExecuteError(java.lang.String expectedError,
java.sql.Statement stmt,
long[] expectedUpdateCount)
helper method to evaluate negative tests where we expect a
batchExecuteException to be returned.
|
private static void |
assertBatchUpdateCounts(int[] expectedBatchResult,
int[] executeBatchResult) |
static void |
assertBatchUpdateCounts(long[] expectedBatchResult,
java.sql.BatchUpdateException bue) |
protected static junit.framework.Test |
baseSuite(java.lang.String name) |
protected void |
cleanUpCallableStatement(java.sql.CallableStatement cs,
java.lang.String tableName) |
static junit.framework.Test |
embeddedSuite()
embeddedSuite runs tests only in embedded mode.
|
private static void |
executeBatchCallableStatement(java.sql.CallableStatement cs) |
void |
setUp()
Set up the conection to the database.
|
static int[] |
squashLongs(long[] longs)
Squash an array of longs into an array of ints
|
static junit.framework.Test |
suite() |
static void |
takesString(java.lang.String[] outparam,
int type) |
void |
test1000StatementsBatch() |
void |
test1000ValueSetPreparedBatch() |
void |
testAssociatedParams() |
void |
testAutoCommitTrueBatch() |
void |
testAutoCommitTruePreparedStatBatch() |
void |
testCallableStatementBatch() |
void |
testCallableStatementWithOutputParamBatch() |
void |
testCombinationsOfClearBatch() |
void |
testCombinationsOfClearPreparedStatBatch() |
void |
testContinueAfterError()
Test the behaviour when one of the statements in a batch fails.
|
void |
testEmptyStatementBatch() |
void |
testEmptyValueSetPreparedBatch() |
void |
testMinimalDDLInBatch() |
void |
testMultipleStatementsBatch() |
void |
testMultipleStatementsBatchWithWarnings()
Regression test case for DERBY-6373.
|
void |
testMultipleValueSetNullPreparedBatch() |
void |
testMultipleValueSetPreparedBatch() |
void |
testNoParametersPreparedBatch() |
void |
testPreparedStatRollbackAndCommitCombinations() |
void |
testPreparedStmtNonBatchStuffInBatch() |
void |
testPreparedStmtWithErrorsBatch() |
void |
testPreparedStmtWithResultSetBatch() |
void |
testSingleStatementBatch() |
void |
testSingleValueSetPreparedBatch() |
void |
testStatementNonBatchStuffInBatch() |
void |
testStatementWithErrorsBatch() |
void |
testStatementWithResultSetBatch() |
void |
testTransactionErrorBatch() |
void |
testTransactionErrorPreparedStmtBatch() |
void |
testUnderlyingExceptionIsVisible()
Test that the underlying exception is included in the output when we
call printStackTrace() on a BatchUpdateException.
|
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 BatchUpdateTest(java.lang.String name)
public void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
public static junit.framework.Test suite()
public static junit.framework.Test embeddedSuite()
protected static junit.framework.Test baseSuite(java.lang.String name)
public static void assertBatchUpdateCounts(long[] expectedBatchResult, java.sql.BatchUpdateException bue)
public static int[] squashLongs(long[] longs)
private static void assertBatchUpdateCounts(int[] expectedBatchResult, int[] executeBatchResult)
public static void assertBatchExecuteError(java.lang.String expectedError, java.sql.Statement stmt, long[] expectedUpdateCount) throws java.sql.SQLException
expectedError
- The sqlstate to look for.stmt
- The Statement that contains the Batch to
be executed.expectedUpdateCount
- The expectedUpdateCount array.java.sql.SQLException
- Thrown if the expected error occurs
We expect a BatchUpdateException, and
verify it is so.public void testMinimalDDLInBatch() throws java.sql.SQLException
java.sql.SQLException
public void testEmptyStatementBatch() throws java.sql.SQLException
java.sql.SQLException
public void testSingleStatementBatch() throws java.sql.SQLException
java.sql.SQLException
public void testMultipleStatementsBatch() throws java.sql.SQLException
java.sql.SQLException
public void testMultipleStatementsBatchWithWarnings() throws java.sql.SQLException
java.sql.SQLException
public void test1000StatementsBatch() throws java.sql.SQLException
java.sql.SQLException
public void testAutoCommitTrueBatch() throws java.sql.SQLException
java.sql.SQLException
public void testCombinationsOfClearBatch() throws java.sql.SQLException
java.sql.SQLException
public void testAssociatedParams() throws java.sql.SQLException
java.sql.SQLException
public void testStatementWithResultSetBatch() throws java.sql.SQLException
java.sql.SQLException
public void testStatementNonBatchStuffInBatch() throws java.sql.SQLException
java.sql.SQLException
public void testStatementWithErrorsBatch() throws java.sql.SQLException
java.sql.SQLException
public void testTransactionErrorBatch() throws java.sql.SQLException
java.sql.SQLException
public void testCallableStatementBatch() throws java.sql.SQLException
java.sql.SQLException
private static void executeBatchCallableStatement(java.sql.CallableStatement cs) throws java.sql.SQLException
java.sql.SQLException
protected void cleanUpCallableStatement(java.sql.CallableStatement cs, java.lang.String tableName) throws java.sql.SQLException
java.sql.SQLException
public void testCallableStatementWithOutputParamBatch() throws java.sql.SQLException
java.sql.SQLException
public static void takesString(java.lang.String[] outparam, int type) throws java.lang.Throwable
java.lang.Throwable
public void testEmptyValueSetPreparedBatch() throws java.sql.SQLException
java.sql.SQLException
public void testNoParametersPreparedBatch() throws java.sql.SQLException
java.sql.SQLException
public void testSingleValueSetPreparedBatch() throws java.sql.SQLException
java.sql.SQLException
public void testMultipleValueSetPreparedBatch() throws java.sql.SQLException
java.sql.SQLException
public void testMultipleValueSetNullPreparedBatch() throws java.sql.SQLException
java.sql.SQLException
public void test1000ValueSetPreparedBatch() throws java.sql.SQLException
java.sql.SQLException
public void testPreparedStatRollbackAndCommitCombinations() throws java.sql.SQLException
java.sql.SQLException
public void testAutoCommitTruePreparedStatBatch() throws java.sql.SQLException
java.sql.SQLException
public void testCombinationsOfClearPreparedStatBatch() throws java.sql.SQLException
java.sql.SQLException
public void testPreparedStmtWithResultSetBatch() throws java.sql.SQLException
java.sql.SQLException
public void testPreparedStmtNonBatchStuffInBatch() throws java.sql.SQLException
java.sql.SQLException
public void testPreparedStmtWithErrorsBatch() throws java.sql.SQLException
java.sql.SQLException
public void testTransactionErrorPreparedStmtBatch() throws java.sql.SQLException
java.sql.SQLException
public void testUnderlyingExceptionIsVisible() throws java.sql.SQLException
java.sql.SQLException
public void testContinueAfterError() throws java.sql.SQLException
java.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.