Derby
  1. Derby
  2. DERBY-3568

Convert jdbcapi/savepointJdbc30_JSR169.java and jdbcapi/savepointJdbc30_XA.java to JUnit

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.5.1.1
    • Component/s: Test
    • Labels:
      None

      Description

      These are the last two in the jdk14 suite and might be a good beginner task.

      1. DERBY-3568.diff
        40 kB
        Erlend Birkenes
      2. DERBY-3568_2.diff
        92 kB
        Erlend Birkenes
      3. DERBY-3568_3.diff
        109 kB
        Erlend Birkenes
      4. DERBY-3568_4.diff
        9 kB
        Erlend Birkenes

        Issue Links

          Activity

          Hide
          Erlend Birkenes added a comment -

          My first attempt at converting to JUnit.

          Show
          Erlend Birkenes added a comment - My first attempt at converting to JUnit.
          Hide
          Daniel John Debrunner added a comment -

          I don't think there's any need for the fields in the class, namely:

          + Connection con, con2;
          + ResultSet rs1, rs2, rs1WithHold, rs2WithHold;
          + Savepoint savepoint1, savepoint2, savepoint3, savepoint4;
          + Statement s,s2;

          A test fixture always corresponds to a new instance of the class, so while it appears the setup maybe sharing these objects across multiple fixtures, it's not. Each fixture will be in its own object and run its own setup and teardown methods.

          Local variables are more natural for a fixture since they are indeed locally scoped to be used only in that fixture.

          Also, the utility methods and parent class already handle a single connection being shared across the setup, fixture and teardown method, so this is not required:

          + con = getConnection();

          Each getConnection() call (or the utility methods such as createStatement(), prepareStatement() etc.) already use a single connection, so there's no need for a field to store it, it's already handled by the parent class.

          Show
          Daniel John Debrunner added a comment - I don't think there's any need for the fields in the class, namely: + Connection con, con2; + ResultSet rs1, rs2, rs1WithHold, rs2WithHold; + Savepoint savepoint1, savepoint2, savepoint3, savepoint4; + Statement s,s2; A test fixture always corresponds to a new instance of the class, so while it appears the setup maybe sharing these objects across multiple fixtures, it's not. Each fixture will be in its own object and run its own setup and teardown methods. Local variables are more natural for a fixture since they are indeed locally scoped to be used only in that fixture. Also, the utility methods and parent class already handle a single connection being shared across the setup, fixture and teardown method, so this is not required: + con = getConnection(); Each getConnection() call (or the utility methods such as createStatement(), prepareStatement() etc.) already use a single connection, so there's no need for a field to store it, it's already handled by the parent class.
          Hide
          Kathey Marsden added a comment -

          Thanks for the quick work and patch. Looks like a good first effort. Below are some comments.

          some general comments:

          • Add the test to jdbcapi._Suite
          • Remove the test from the jdbcapi suite in the old harness and remove masters.
          • Run suites.All and derbyall.
          • Keep connections,result sets, statements and savepoints local to
            the fixtures. These do not get cleaned up by JUnit.
          • I wonder if there is a Jira issue that nested savepoints are not
            supported with the client driver. If not we should file one.
          • There are comments that refer to JCC that can probably be changed to client instead.

          Some detailed comments on the code:

          suite()
          Instead of !TestUtil.isNetFramework() use usingEmbedded() in BaseJDBCTestCase.
          http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.html#usingEmbedded()

          I'm not sure though if the current code is going to get things running at all with network server. I have always just used TestConfiguration.defaultSuite() and had the fixtures return if usingDerbyNetClient() if I don't want them to run, but it may make more sense not to add them into the suite at all as you have attempted to do. CallableTest has an example of how this can be done.

          setup()/teardown() - Instead of creating the tables once per fixture, you can it once using CleanDatabaseSetup and decorateSQL and then the cleanup will be automatic. See BatchUpdateTest for an example.

          When catching an exception check that the SQLState that you get is correct with
          assertSQLState.
          http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.html#assertSQLState(java.lang.String,%20java.sql.SQLException)

          If no exception is expected, it is better just to let the exception be thrown instead of catching it and printing a message. e.g. Instead of
          try

          { savepoint2 = con.setSavepoint("s1"); }

          catch (SQLException se)

          { fail("After releasing a savepoint, should be able to reuse it"); }

          just use
          savepoint2 = con.setSavepoint("s1");

          I see a few failures when I run the test.
          testSavepointsInBatch:
          java.sql.SQLException: Table/View 't1' does not exist.
          at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
          at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:201)
          at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391)
          at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
          at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2082)
          at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614)
          at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(EmbedStatement.java:152)
          at org.apache.derbyTesting.junit.BaseJDBCTestCase.assertEscapedTableRowCount(BaseJDBCTestCase.java:895)
          at org.apache.derbyTesting.junit.BaseJDBCTestCase.assertTableRowCount(BaseJDBCTestCase.java:879)
          at org.apache.derbyTesting.functionTests.tests.jdbcapi.SavepointJdbc30_JSR169Test.testSavepointsInBatch(SavepointJdbc30_JSR169Test.java:489)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:615)
          at junit.framework.TestCase.runTest(TestCase.java:154)
          at junit.framework.TestCase.runBare(TestCase.java:127)
          at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:103)
          at junit.framework.TestResult$1.protect(TestResult.java:106)
          at junit.framework.TestResult.runProtected(TestResult.java:124)
          at junit.framework.TestResult.run(TestResult.java:109)
          at junit.framework.TestCase.run(TestCase.java:118)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
          Caused by: ERROR 42X05: Table/View 't1' does not exist.
          at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:286)
          at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(FromBaseTable.java:2451)
          at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(FromBaseTable.java:2175)
          at org.apache.derby.impl.sql.compile.FromList.bindTables(FromList.java:310)
          at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(SelectNode.java:390)
          at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(DMLStatementNode.java:199)
          at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java:137)
          at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(CursorNode.java:236)
          at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:314)
          at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88)
          at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:768)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606)
          ... 25 more

          testBug5817
          java.sql.SQLException: 'DROP TABLE' cannot be performed on 'SAVEPOINT' because it does not exist.
          at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
          at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:201)
          at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391)
          at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
          at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2082)
          at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:555)
          at org.apache.derbyTesting.functionTests.tests.jdbcapi.SavepointJdbc30_JSR169Test.testBug5817(SavepointJdbc30_JSR169Test.java:633)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:615)
          at junit.framework.TestCase.runTest(TestCase.java:154)
          at junit.framework.TestCase.runBare(TestCase.java:127)
          at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:103)
          at junit.framework.TestResult$1.protect(TestResult.java:106)
          at junit.framework.TestResult.runProtected(TestResult.java:124)
          at junit.framework.TestResult.run(TestResult.java:109)
          at junit.framework.TestCase.run(TestCase.java:118)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
          Caused by: ERROR 42Y55: 'DROP TABLE' cannot be performed on 'SAVEPOINT' because it does not exist.
          at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303)
          at org.apache.derby.impl.sql.compile.DDLStatementNode.getTableDescriptor(DDLStatementNode.java:296)
          at org.apache.derby.impl.sql.compile.DDLStatementNode.getTableDescriptor(DDLStatementNode.java:263)
          at org.apache.derby.impl.sql.compile.DropTableNode.bindStatement(DropTableNode.java:97)
          at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:314)
          at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88)
          at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:768)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606)
          ... 23 more

          xtestRollbackWillReleaseLaterSavepoints
          java.sql.SQLException: Table/View 't1' does not exist.
          at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
          at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:201)
          at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391)
          at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
          at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2082)
          at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614)
          at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(EmbedStatement.java:152)
          at org.apache.derbyTesting.junit.BaseJDBCTestCase.assertEscapedTableRowCount(BaseJDBCTestCase.java:895)
          at org.apache.derbyTesting.junit.BaseJDBCTestCase.assertTableRowCount(BaseJDBCTestCase.java:879)
          at org.apache.derbyTesting.functionTests.tests.jdbcapi.SavepointJdbc30_JSR169Test.xtestRollbackWillReleaseLaterSavepoints(SavepointJdbc30_JSR169Test.java:758)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:615)
          at junit.framework.TestCase.runTest(TestCase.java:154)
          at junit.framework.TestCase.runBare(TestCase.java:127)
          at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:103)
          at junit.framework.TestResult$1.protect(TestResult.java:106)
          at junit.framework.TestResult.runProtected(TestResult.java:124)
          at junit.framework.TestResult.run(TestResult.java:109)
          at junit.framework.TestCase.run(TestCase.java:118)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
          Caused by: ERROR 42X05: Table/View 't1' does not exist.
          at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:286)
          at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(FromBaseTable.java:2451)
          at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(FromBaseTable.java:2175)
          at org.apache.derby.impl.sql.compile.FromList.bindTables(FromList.java:310)
          at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(SelectNode.java:390)
          at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(DMLStatementNode.java:199)
          at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java:137)
          at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(CursorNode.java:236)
          at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:314)
          at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88)
          at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:768)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606)
          ... 23 more

          Show
          Kathey Marsden added a comment - Thanks for the quick work and patch. Looks like a good first effort. Below are some comments. some general comments: Add the test to jdbcapi._Suite Remove the test from the jdbcapi suite in the old harness and remove masters. Run suites.All and derbyall. Keep connections,result sets, statements and savepoints local to the fixtures. These do not get cleaned up by JUnit. I wonder if there is a Jira issue that nested savepoints are not supported with the client driver. If not we should file one. There are comments that refer to JCC that can probably be changed to client instead. Some detailed comments on the code: suite() Instead of !TestUtil.isNetFramework() use usingEmbedded() in BaseJDBCTestCase. http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.html#usingEmbedded( ) I'm not sure though if the current code is going to get things running at all with network server. I have always just used TestConfiguration.defaultSuite() and had the fixtures return if usingDerbyNetClient() if I don't want them to run, but it may make more sense not to add them into the suite at all as you have attempted to do. CallableTest has an example of how this can be done. setup()/teardown() - Instead of creating the tables once per fixture, you can it once using CleanDatabaseSetup and decorateSQL and then the cleanup will be automatic. See BatchUpdateTest for an example. When catching an exception check that the SQLState that you get is correct with assertSQLState. http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.html#assertSQLState(java.lang.String,%20java.sql.SQLException ) If no exception is expected, it is better just to let the exception be thrown instead of catching it and printing a message. e.g. Instead of try { savepoint2 = con.setSavepoint("s1"); } catch (SQLException se) { fail("After releasing a savepoint, should be able to reuse it"); } just use savepoint2 = con.setSavepoint("s1"); I see a few failures when I run the test. testSavepointsInBatch: java.sql.SQLException: Table/View 't1' does not exist. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:201) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2082) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614) at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(EmbedStatement.java:152) at org.apache.derbyTesting.junit.BaseJDBCTestCase.assertEscapedTableRowCount(BaseJDBCTestCase.java:895) at org.apache.derbyTesting.junit.BaseJDBCTestCase.assertTableRowCount(BaseJDBCTestCase.java:879) at org.apache.derbyTesting.functionTests.tests.jdbcapi.SavepointJdbc30_JSR169Test.testSavepointsInBatch(SavepointJdbc30_JSR169Test.java:489) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:103) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: ERROR 42X05: Table/View 't1' does not exist. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:286) at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(FromBaseTable.java:2451) at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(FromBaseTable.java:2175) at org.apache.derby.impl.sql.compile.FromList.bindTables(FromList.java:310) at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(SelectNode.java:390) at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(DMLStatementNode.java:199) at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java:137) at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(CursorNode.java:236) at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:314) at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88) at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:768) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606) ... 25 more testBug5817 java.sql.SQLException: 'DROP TABLE' cannot be performed on 'SAVEPOINT' because it does not exist. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:201) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2082) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:555) at org.apache.derbyTesting.functionTests.tests.jdbcapi.SavepointJdbc30_JSR169Test.testBug5817(SavepointJdbc30_JSR169Test.java:633) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:103) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: ERROR 42Y55: 'DROP TABLE' cannot be performed on 'SAVEPOINT' because it does not exist. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.compile.DDLStatementNode.getTableDescriptor(DDLStatementNode.java:296) at org.apache.derby.impl.sql.compile.DDLStatementNode.getTableDescriptor(DDLStatementNode.java:263) at org.apache.derby.impl.sql.compile.DropTableNode.bindStatement(DropTableNode.java:97) at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:314) at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88) at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:768) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606) ... 23 more xtestRollbackWillReleaseLaterSavepoints java.sql.SQLException: Table/View 't1' does not exist. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:201) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2082) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614) at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(EmbedStatement.java:152) at org.apache.derbyTesting.junit.BaseJDBCTestCase.assertEscapedTableRowCount(BaseJDBCTestCase.java:895) at org.apache.derbyTesting.junit.BaseJDBCTestCase.assertTableRowCount(BaseJDBCTestCase.java:879) at org.apache.derbyTesting.functionTests.tests.jdbcapi.SavepointJdbc30_JSR169Test.xtestRollbackWillReleaseLaterSavepoints(SavepointJdbc30_JSR169Test.java:758) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:103) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: ERROR 42X05: Table/View 't1' does not exist. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:286) at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(FromBaseTable.java:2451) at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(FromBaseTable.java:2175) at org.apache.derby.impl.sql.compile.FromList.bindTables(FromList.java:310) at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(SelectNode.java:390) at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(DMLStatementNode.java:199) at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java:137) at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(CursorNode.java:236) at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:314) at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88) at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:768) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606) ... 23 more
          Hide
          Erlend Birkenes added a comment -

          Here is my second attempt.

          • I moved database setup to CleanDatabaseSetup and decorateSQL so it only happens once. setUp() now only makes sure that AutoCommit is off.
          • I now keep everything local in the fixtures.
          • Instead of !TestUtil.isNetFramework() I now use usingEmbedded() in BaseJDBCTestCase.
          • I changed JCC to client in comments.
          • I now assertSQLState when catching exception.
          • I don't catch unexpected exceptions anymore.
          • Added the test to jdbcapi._Suite
          • Removed the test from the jdbcapi suite in the old harness
          • Removed masters.
          • Ran suites.All and derbyall.
          Show
          Erlend Birkenes added a comment - Here is my second attempt. I moved database setup to CleanDatabaseSetup and decorateSQL so it only happens once. setUp() now only makes sure that AutoCommit is off. I now keep everything local in the fixtures. Instead of !TestUtil.isNetFramework() I now use usingEmbedded() in BaseJDBCTestCase. I changed JCC to client in comments. I now assertSQLState when catching exception. I don't catch unexpected exceptions anymore. Added the test to jdbcapi._Suite Removed the test from the jdbcapi suite in the old harness Removed masters. Ran suites.All and derbyall.
          Hide
          Kathey Marsden added a comment -

          Thanks Erlend for the new patch. I am the one that suggested removing the old test, but I guess that wasn't such a smart idea as it causes a build failure because the savepointJDbc30_XA test still extends from it.
          [javac] Compiling 10 source files to C:\svn3\trunk\classes
          [javac] C:\svn3\trunk\java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\savepointJdbc30_XA.java:42: c
          nnot find symbol
          [javac] symbol: class savepointJdbc30_JSR169
          [javac] public class savepointJdbc30_XA extends savepointJdbc30_JSR169{
          [javac] ^
          [javac] C:\svn3\trunk\java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\savepointJdbc30_XA.java:62: c
          nnot find symbol
          [javac] symbol : method runTests(java.lang.String,java.sql.Connection,java.sql.Connection)
          [javac] location: class org.apache.derbyTesting.functionTests.tests.jdbcapi.savepointJdbc30_XA
          [javac] runTests("connections from XADataSource (local tranasaction)",
          [javac] ^
          [javac] C:\svn3\trunk\java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\savepointJdbc30_XA.java:68: c
          nnot find symbol
          [javac] symbol : method dumpSQLExceptions(java.sql.SQLException)
          [javac] location: class org.apache.derbyTesting.functionTests.tests.jdbcapi.savepointJdbc30_XA
          [javac] dumpSQLExceptions(e);
          [javac] ^
          [javac] 3 errors

          Other comments.

          I think we still have a problem that this won't run with network server. You will have to use the clientServerDecorator to get it to run with network server. See CallableStatmentTest for an example of how to use the clientServerDecorator and omit some tests for running with client.

          When creating statements, you can just use createStatement() instead of con.createStatement() and then the statements will get closed automatically.

          In decorateSQL, I think we can omit the code that tries to drop the tables and catches the exception. I think we can assume a clean database.

          I think in JDBCHarnessJavaTest we can just remove the savepointJdbc30_JSR169 line instead of commenting it out.

          All else looks good.

          Kathey

          Show
          Kathey Marsden added a comment - Thanks Erlend for the new patch. I am the one that suggested removing the old test, but I guess that wasn't such a smart idea as it causes a build failure because the savepointJDbc30_XA test still extends from it. [javac] Compiling 10 source files to C:\svn3\trunk\classes [javac] C:\svn3\trunk\java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\savepointJdbc30_XA.java:42: c nnot find symbol [javac] symbol: class savepointJdbc30_JSR169 [javac] public class savepointJdbc30_XA extends savepointJdbc30_JSR169{ [javac] ^ [javac] C:\svn3\trunk\java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\savepointJdbc30_XA.java:62: c nnot find symbol [javac] symbol : method runTests(java.lang.String,java.sql.Connection,java.sql.Connection) [javac] location: class org.apache.derbyTesting.functionTests.tests.jdbcapi.savepointJdbc30_XA [javac] runTests("connections from XADataSource (local tranasaction)", [javac] ^ [javac] C:\svn3\trunk\java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\savepointJdbc30_XA.java:68: c nnot find symbol [javac] symbol : method dumpSQLExceptions(java.sql.SQLException) [javac] location: class org.apache.derbyTesting.functionTests.tests.jdbcapi.savepointJdbc30_XA [javac] dumpSQLExceptions(e); [javac] ^ [javac] 3 errors Other comments. I think we still have a problem that this won't run with network server. You will have to use the clientServerDecorator to get it to run with network server. See CallableStatmentTest for an example of how to use the clientServerDecorator and omit some tests for running with client. When creating statements, you can just use createStatement() instead of con.createStatement() and then the statements will get closed automatically. In decorateSQL, I think we can omit the code that tries to drop the tables and catches the exception. I think we can assume a clean database. I think in JDBCHarnessJavaTest we can just remove the savepointJdbc30_JSR169 line instead of commenting it out. All else looks good. Kathey
          Hide
          Erlend Birkenes added a comment -

          The third version.
          I merged jdbcapi/SavepointJdbc30_JSR169 and /jdbcapi/SavepointJdbc30_XA back into one file. The split and jdbcapi/savepointJdbc30_XA.java is mentioned here: http://wiki.apache.org/db-derby/CdcTesting so that should be changed also..

          and I think I have set everything up properly with the decorators this time.

          Please comment.

          Show
          Erlend Birkenes added a comment - The third version. I merged jdbcapi/SavepointJdbc30_JSR169 and /jdbcapi/SavepointJdbc30_XA back into one file. The split and jdbcapi/savepointJdbc30_XA.java is mentioned here: http://wiki.apache.org/db-derby/CdcTesting so that should be changed also.. and I think I have set everything up properly with the decorators this time. Please comment.
          Hide
          Kathey Marsden added a comment -

          Erlend, I think the changes look good except we are missing the Client XA tests.
          The base tests should run 4 times: embedded, client, embedded xa, client xa.
          I am going to go ahead and commit this patch after I run some tests and then you can
          put in a followup patch to add client xa.

          Kathey

          Show
          Kathey Marsden added a comment - Erlend, I think the changes look good except we are missing the Client XA tests. The base tests should run 4 times: embedded, client, embedded xa, client xa. I am going to go ahead and commit this patch after I run some tests and then you can put in a followup patch to add client xa. Kathey
          Hide
          Kathey Marsden added a comment -

          Committed revision 645716. In followup patch,please add client xa tests and remove master/savepointJdbc30_XA.out

          Show
          Kathey Marsden added a comment - Committed revision 645716. In followup patch,please add client xa tests and remove master/savepointJdbc30_XA.out
          Hide
          Erlend Birkenes added a comment -

          Added client XA tests and deleted master/savepointJdbc30_XA.out

          Show
          Erlend Birkenes added a comment - Added client XA tests and deleted master/savepointJdbc30_XA.out
          Hide
          Kathey Marsden added a comment -

          Committed revision 648041. I fixed up indentation and added the Apache header which we forgot with the first checkin.

          Kathey

          Show
          Kathey Marsden added a comment - Committed revision 648041. I fixed up indentation and added the Apache header which we forgot with the first checkin. Kathey
          Hide
          Myrna van Lunteren added a comment -

          some minor comments:

          • there are still some orphaned files:
            [trunk]/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/savepointJdbc30_JSR169.out
            [trunk]/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30_JSR169.out
            [trunk]/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30_XA.out
          • there is an orphaned reference in:
            [trunk]/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
          • I think setting of and references to JDBCAPI_TESTS_EMEBDDED_JDBC3 in JDBCJavaHarnessTest can just be removed rather than commented out. The JDBCJavaHarnessTest was intended (as I understand it) to allow a number of tests to run under junit without actually converting them; if things disappear from here that's fine.
          Show
          Myrna van Lunteren added a comment - some minor comments: there are still some orphaned files: [trunk] /java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/savepointJdbc30_JSR169.out [trunk] /java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30_JSR169.out [trunk] /java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30_XA.out there is an orphaned reference in: [trunk] /java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude I think setting of and references to JDBCAPI_TESTS_EMEBDDED_JDBC3 in JDBCJavaHarnessTest can just be removed rather than commented out. The JDBCJavaHarnessTest was intended (as I understand it) to allow a number of tests to run under junit without actually converting them; if things disappear from here that's fine.
          Hide
          Myrna van Lunteren added a comment -

          I removed those references with revision 648413.

          Show
          Myrna van Lunteren added a comment - I removed those references with revision 648413.

            People

            • Assignee:
              Erlend Birkenes
              Reporter:
              Kathey Marsden
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development