org.apache.derbyTesting.functionTests.tests.jdbcapi
Class SavepointJdbc30Test

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.derbyTesting.junit.BaseTestCase
              extended by org.apache.derbyTesting.junit.BaseJDBCTestCase
                  extended by org.apache.derbyTesting.functionTests.tests.jdbcapi.SavepointJdbc30Test
All Implemented Interfaces:
junit.framework.Test

public class SavepointJdbc30Test
extends BaseJDBCTestCase

Test the new class Savepoint in JDBC 30. Also, test some mix and match of defining savepoints through JDBC and SQL testing both callable and prepared statements meta data


Field Summary
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
SavepointJdbc30Test(java.lang.String name)
          Create a test
 
Method Summary
private static junit.framework.Test getEmbeddedSuite(java.lang.String name)
          Create a testsuite containing the tests that can only run in embedded mode.
protected  void setUp()
          setUp: Just keep AutoCommit off.
static junit.framework.Test suite()
          Set up the test suite for embedded mode, client mode, and embedded mode with XADataSources
 void testBug4465()
          TEST 5a and 5b for bug 4465 test 5a - create two savepoints in two different transactions and release the first one in the subsequent transaction
 void testBug5817()
          Test 23 - bug 5817 - make savepoint and release non-reserved keywords
 void testGrammarCheck()
          Test 16 grammar check for savepoint sq1
 void testNameCaseSensitivity()
          Test 10 test savepoint name case sensitivity
 void testNameLengthMax128Chars()
          Test 24 Savepoint name can't exceed 128 characters
 void testNamesAndIds()
          Test4 - Verify names/ids of named/unnamed savepoints named savepoints don't have an id. unnamed savepoints don't have a name (internally, all our savepoints have names, but for unnamed savepoint, that is not exposed through jdbc api)
 void testNoNestedSavepointsInsideJdbcSavepoint()
          Test 18
 void testNoNestedSavepointsInsideSqlSavepoint()
          Test 19
 void testNoNestedSavepointsWhenUsingSQL()
          Test 17
 void testNoSavepointsIfAutoCommit()
          Test1.
 void testNoSqlSavepointStartingWithSYS()
          Test 22
 void testNoSqlSavepointStartingWithSYSThroughJdbc()
          Test 25
 void testNullName()
          Test3 - Named savepoints can't pass null for name
 void testReleaseMultipleTimes()
          Test 12 releasing a savepoint multiple times - should not work
 void testReleaseNullSavepoint()
          Test 26b pass Null value to releaseSavepoint
 void testReleaseReleasedSavepoint()
          test 6a - create a savepoint release it and then create another with the same name. and release the first one
 void testReleaseSavepointFromOtherTransaction()
          Test 6c: TEST case just for bug 4467 // Test 10 - create a named savepoint with the a generated name savepoint1 = con2.setSavepoint("SAVEPT0"); // what exactly is the correct behaviour here?
 void testReleaseSqlSavepointAndRollback()
          Test 21
 void testReusingSavepoints()
          Test2 - After releasing a savepoint, should be able to reuse it.
 void testRollbackMultipleTimes()
          Test 11 rolling back a savepoint multiple times - should work
 void testRollbackNullSavepoint()
          bug 4451 - Test 26a pass Null value to rollback bug 5374 - Passing a null savepoint to rollback or release method used to give a npe in JCC it should give a SQLException aying "Cannot rollback to a null savepoint"
 void testRollbackReleasedSavepoint()
          test 6b - create a savepoints release it and then create another with the same name. and rollback the first one
 void testRollbackReleasesSavepointArray()
          Test 14 cause a transaction rollback and that should release the internal savepoint array
 void testRollbackSqlSavepointSameAsJdbc()
          Test 20
 void testSavepointFromEarlierTransactionAfterToggleAutocommit()
          Test 13 shouldn't be able to use a savepoint from earlier transaction after setting autocommit on and off
 void testSavepointName()
          Test 9 test savepoint name and verify case sensitivity
 void testSavepointsInBatch()
          Test 15 Check savepoints in batch
 void testSwapSavepointsAcrossConnectionAndRelease()
          Test 7a: BUG 4468 - should not be able to pass a savepoint from a different transaction for release/rollback
 void testSwapSavepointsAcrossConnectionsAndRollback()
          Test 7b - swap savepoints across connections
 void xtestCommitWillReleaseActiveSavepoints()
          Test42a - Commit on a connection will release all the savepoints created for that transaction
 void xtestCursorsCloseOnRollback()
          Test 46 bug 5145 Cursors declared before and within the savepoint unit will be closed when rolling back the savepoint
 void xtestGetSavepoint()
          Test 47 multiple tests for getSavepointId()
 void xtestNestedSavepoints()
          Test 48
 void xtestNoConflictWithGeneratedName()
          Test40 - We internally generate a unique name for unnamed savepoints.
 void xtestReuseNameAfterRelease()
          Test43 - After releasing a savepoint, should be able to reuse it.
 void xtestReuseNameAfterRollback()
          Test 45 reuse savepoint name after rollback - should not work
 void xtestRollbackWillReleaseActiveSavepoints()
          Test42 - Rollback on a connection will release all the savepoints created for that transaction
 void xtestRollbackWillReleaseLaterSavepoints()
          Test41 - Rolling back to a savepoint will release all the savepoints created after that savepoint.
 
Methods inherited from class org.apache.derbyTesting.junit.BaseJDBCTestCase
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertTableRowCount, assertUpdateCount, assertUpdateCount, checkAllConsistency, checkEstimatedRowCount, commit, createStatement, createStatement, createStatement, dropTable, dropTable, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
 
Methods inherited from class org.apache.derbyTesting.junit.BaseTestCase
alarm, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertSecurityManager, assertThrowableEquals, execJavaCmd, fail, getFailureFolder, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeSystemProperty, runBare, setSystemProperty, traceit
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
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, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SavepointJdbc30Test

public SavepointJdbc30Test(java.lang.String name)
Create a test

Parameters:
name -
Method Detail

suite

public static junit.framework.Test suite()
Set up the test suite for embedded mode, client mode, and embedded mode with XADataSources

Returns:
A suite containing embedded, client and embedded with XA suites

getEmbeddedSuite

private static junit.framework.Test getEmbeddedSuite(java.lang.String name)
Create a testsuite containing the tests that can only run in embedded mode. These tests have names starting with x and are added automatically.


setUp

protected void setUp()
              throws java.lang.Exception
setUp: Just keep AutoCommit off.

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

testNoSavepointsIfAutoCommit

public void testNoSavepointsIfAutoCommit()
                                  throws java.sql.SQLException
Test1. It should not be possible to set a savepoint if autocommit is on.

Throws:
java.sql.SQLException

testReusingSavepoints

public void testReusingSavepoints()
                           throws java.sql.SQLException
Test2 - After releasing a savepoint, should be able to reuse it.

Throws:
java.sql.SQLException

testNullName

public void testNullName()
                  throws java.sql.SQLException
Test3 - Named savepoints can't pass null for name

Throws:
java.sql.SQLException

testNamesAndIds

public void testNamesAndIds()
                     throws java.sql.SQLException
Test4 - Verify names/ids of named/unnamed savepoints named savepoints don't have an id. unnamed savepoints don't have a name (internally, all our savepoints have names, but for unnamed savepoint, that is not exposed through jdbc api)

Throws:
java.sql.SQLException

testBug4465

public void testBug4465()
                 throws java.sql.SQLException
TEST 5a and 5b for bug 4465 test 5a - create two savepoints in two different transactions and release the first one in the subsequent transaction

Throws:
java.sql.SQLException

testReleaseReleasedSavepoint

public void testReleaseReleasedSavepoint()
                                  throws java.sql.SQLException
test 6a - create a savepoint release it and then create another with the same name. and release the first one

Throws:
java.sql.SQLException

testRollbackReleasedSavepoint

public void testRollbackReleasedSavepoint()
                                   throws java.sql.SQLException
test 6b - create a savepoints release it and then create another with the same name. and rollback the first one

Throws:
java.sql.SQLException

testReleaseSavepointFromOtherTransaction

public void testReleaseSavepointFromOtherTransaction()
                                              throws java.sql.SQLException
Test 6c: TEST case just for bug 4467 // Test 10 - create a named savepoint with the a generated name savepoint1 = con2.setSavepoint("SAVEPT0"); // what exactly is the correct behaviour here? try { savepoint2 = con2.setSavepoint(); } catch (SQLException se) { System.out.println("Expected Exception is " + se.getMessage()); } con2.commit();

Throws:
java.sql.SQLException

testSwapSavepointsAcrossConnectionAndRelease

public void testSwapSavepointsAcrossConnectionAndRelease()
                                                  throws java.sql.SQLException
Test 7a: BUG 4468 - should not be able to pass a savepoint from a different transaction for release/rollback

Throws:
java.sql.SQLException

testSwapSavepointsAcrossConnectionsAndRollback

public void testSwapSavepointsAcrossConnectionsAndRollback()
                                                    throws java.sql.SQLException
Test 7b - swap savepoints across connections

Throws:
java.sql.SQLException

testSavepointName

public void testSavepointName()
                       throws java.sql.SQLException
Test 9 test savepoint name and verify case sensitivity

Throws:
java.sql.SQLException

testNameCaseSensitivity

public void testNameCaseSensitivity()
                             throws java.sql.SQLException
Test 10 test savepoint name case sensitivity

Throws:
java.sql.SQLException

testRollbackMultipleTimes

public void testRollbackMultipleTimes()
                               throws java.sql.SQLException
Test 11 rolling back a savepoint multiple times - should work

Throws:
java.sql.SQLException

testReleaseMultipleTimes

public void testReleaseMultipleTimes()
                              throws java.sql.SQLException
Test 12 releasing a savepoint multiple times - should not work

Throws:
java.sql.SQLException

testSavepointFromEarlierTransactionAfterToggleAutocommit

public void testSavepointFromEarlierTransactionAfterToggleAutocommit()
                                                              throws java.sql.SQLException
Test 13 shouldn't be able to use a savepoint from earlier transaction after setting autocommit on and off

Throws:
java.sql.SQLException

testRollbackReleasesSavepointArray

public void testRollbackReleasesSavepointArray()
                                        throws java.sql.SQLException
Test 14 cause a transaction rollback and that should release the internal savepoint array

Throws:
java.sql.SQLException

testSavepointsInBatch

public void testSavepointsInBatch()
                           throws java.sql.SQLException
Test 15 Check savepoints in batch

Throws:
java.sql.SQLException

testGrammarCheck

public void testGrammarCheck()
                      throws java.sql.SQLException
Test 16 grammar check for savepoint sq1

Throws:
java.sql.SQLException

testNoNestedSavepointsWhenUsingSQL

public void testNoNestedSavepointsWhenUsingSQL()
                                        throws java.sql.SQLException
Test 17

Throws:
java.sql.SQLException

testNoNestedSavepointsInsideJdbcSavepoint

public void testNoNestedSavepointsInsideJdbcSavepoint()
                                               throws java.sql.SQLException
Test 18

Throws:
java.sql.SQLException

testNoNestedSavepointsInsideSqlSavepoint

public void testNoNestedSavepointsInsideSqlSavepoint()
                                              throws java.sql.SQLException
Test 19

Throws:
java.sql.SQLException

testRollbackSqlSavepointSameAsJdbc

public void testRollbackSqlSavepointSameAsJdbc()
                                        throws java.sql.SQLException
Test 20

Throws:
java.sql.SQLException

testReleaseSqlSavepointAndRollback

public void testReleaseSqlSavepointAndRollback()
                                        throws java.sql.SQLException
Test 21

Throws:
java.sql.SQLException

testNoSqlSavepointStartingWithSYS

public void testNoSqlSavepointStartingWithSYS()
                                       throws java.sql.SQLException
Test 22

Throws:
java.sql.SQLException

testBug5817

public void testBug5817()
                 throws java.sql.SQLException
Test 23 - bug 5817 - make savepoint and release non-reserved keywords

Throws:
java.sql.SQLException

testNameLengthMax128Chars

public void testNameLengthMax128Chars()
                               throws java.sql.SQLException
Test 24 Savepoint name can't exceed 128 characters

Throws:
java.sql.SQLException

testNoSqlSavepointStartingWithSYSThroughJdbc

public void testNoSqlSavepointStartingWithSYSThroughJdbc()
                                                  throws java.sql.SQLException
Test 25

Throws:
java.sql.SQLException

testRollbackNullSavepoint

public void testRollbackNullSavepoint()
                               throws java.sql.SQLException
bug 4451 - Test 26a pass Null value to rollback bug 5374 - Passing a null savepoint to rollback or release method used to give a npe in JCC it should give a SQLException aying "Cannot rollback to a null savepoint"

Throws:
java.sql.SQLException

testReleaseNullSavepoint

public void testReleaseNullSavepoint()
                              throws java.sql.SQLException
Test 26b pass Null value to releaseSavepoint

Throws:
java.sql.SQLException

xtestNoConflictWithGeneratedName

public void xtestNoConflictWithGeneratedName()
                                      throws java.sql.SQLException
Test40 - We internally generate a unique name for unnamed savepoints. If a named savepoint uses the currently used internal savepoint name, we won't get an exception thrown for it because we prepend external saves with "e." to avoid name conflicts.

Throws:
java.sql.SQLException

xtestRollbackWillReleaseLaterSavepoints

public void xtestRollbackWillReleaseLaterSavepoints()
                                             throws java.sql.SQLException
Test41 - Rolling back to a savepoint will release all the savepoints created after that savepoint.

Throws:
java.sql.SQLException

xtestRollbackWillReleaseActiveSavepoints

public void xtestRollbackWillReleaseActiveSavepoints()
                                              throws java.sql.SQLException
Test42 - Rollback on a connection will release all the savepoints created for that transaction

Throws:
java.sql.SQLException

xtestCommitWillReleaseActiveSavepoints

public void xtestCommitWillReleaseActiveSavepoints()
                                            throws java.sql.SQLException
Test42a - Commit on a connection will release all the savepoints created for that transaction

Throws:
java.sql.SQLException

xtestReuseNameAfterRelease

public void xtestReuseNameAfterRelease()
                                throws java.sql.SQLException
Test43 - After releasing a savepoint, should be able to reuse it.

Throws:
java.sql.SQLException

xtestReuseNameAfterRollback

public void xtestReuseNameAfterRollback()
                                 throws java.sql.SQLException
Test 45 reuse savepoint name after rollback - should not work

Throws:
java.sql.SQLException

xtestCursorsCloseOnRollback

public void xtestCursorsCloseOnRollback()
                                 throws java.sql.SQLException
Test 46 bug 5145 Cursors declared before and within the savepoint unit will be closed when rolling back the savepoint

Throws:
java.sql.SQLException

xtestGetSavepoint

public void xtestGetSavepoint()
                       throws java.sql.SQLException
Test 47 multiple tests for getSavepointId()

Throws:
java.sql.SQLException

xtestNestedSavepoints

public void xtestNestedSavepoints()
                           throws java.sql.SQLException
Test 48

Throws:
java.sql.SQLException

Built on Wed 2009-11-25 18:43:31-0800, from revision 884373

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.