Derby
  1. Derby
  2. DERBY-2517

convert lang/forupdate.sql to junit

    Details

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

      Description

      convert lang/forupdate.sql to junit

      1. DERBY_2517.stat
        0.9 kB
        Ramandeep Kaur
      2. DERBY_2517-0419.diff
        16 kB
        Ramandeep Kaur
      3. DERBY-2517.diff
        16 kB
        Ramandeep Kaur

        Activity

        Hide
        Kathey Marsden added a comment -

        The patch was committed with 530946/48

        Show
        Kathey Marsden added a comment - The patch was committed with 530946/48
        Hide
        Ramandeep Kaur added a comment -

        Kathy, thanks for your feedback.
        I have incorporated your suggestions and tests runs successfully now.

        Thanks, Raman

        Show
        Ramandeep Kaur added a comment - Kathy, thanks for your feedback. I have incorporated your suggestions and tests runs successfully now. Thanks, Raman
        Hide
        Kathey Marsden added a comment -

        Thanks Raman for the patch.

        I have not seen the stmt and connection set as instance variables. Typically I see each fixture call getConnection or createStatement as needed. I don't know if this is a problem, but just something I noticed.

        With the new patch can you also submit a file with the stat output?

        The issue with the delete statement is because the cursor C4 is closed, first by JDBC.assertSingleValueResultSet(rs, "1"); and then again by rs.close(). The following edits should make it pass.

        public void testUpdates2() throws SQLException {
        stmt.executeUpdate("insert into t1 values (1)");
        stmt.setCursorName("C4");
        ResultSet rs = stmt.executeQuery("select i from t1 s1 for update");
        rs.next();

        Statement stmt2 = createStatement();
        try

        { stmt2.executeUpdate("delete from s1 where current of C4"); fail("ForUpdateTest: should have thrown exception"); }

        catch (SQLException e)

        { assertSQLState("42X28", e); }

        Statement stmt3 = createStatement();
        stmt3.executeUpdate("delete from t1 where current of C4");
        stmt3.executeUpdate("delete from t1");

        rs.close();
        ...

        Thanks

        Kathey

        Show
        Kathey Marsden added a comment - Thanks Raman for the patch. I have not seen the stmt and connection set as instance variables. Typically I see each fixture call getConnection or createStatement as needed. I don't know if this is a problem, but just something I noticed. With the new patch can you also submit a file with the stat output? The issue with the delete statement is because the cursor C4 is closed, first by JDBC.assertSingleValueResultSet(rs, "1"); and then again by rs.close(). The following edits should make it pass. public void testUpdates2() throws SQLException { stmt.executeUpdate("insert into t1 values (1)"); stmt.setCursorName("C4"); ResultSet rs = stmt.executeQuery("select i from t1 s1 for update"); rs.next(); Statement stmt2 = createStatement(); try { stmt2.executeUpdate("delete from s1 where current of C4"); fail("ForUpdateTest: should have thrown exception"); } catch (SQLException e) { assertSQLState("42X28", e); } Statement stmt3 = createStatement(); stmt3.executeUpdate("delete from t1 where current of C4"); stmt3.executeUpdate("delete from t1"); rs.close(); ... Thanks Kathey
        Hide
        Ramandeep Kaur added a comment -

        I am attaching patch for conversion of forupdate.sql to junit test "ForUpdateTest.java".

        I am having one problem during conversion.
        In method "public void testUpdates2()" in ForUpdateTest.java file, whenever, I uncomment line stmt3.executeUpdate("delete from t1 where current of C4");, I get the following error.
        .......E..........E...
        Time: 38.224
        There were 2 errors:
        1) testUpdates2(org.apache.derbyTesting.functionTests.tests.lang.ForUpdateTest)java.sql.SQLException: Cursor 'C4' not found. Verify that autocommit is OFF.
        at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
        at org.apache.derby.impl.sql.compile.CurrentOfNode.bindNonVTITables(Unknown Source)
        at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
        at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown Source)
        at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown Source)
        at org.apache.derby.impl.sql.compile.DeleteNode.bindStatement(Unknown Source)
        at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
        at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
        at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unknown Source)
        at org.apache.derbyTesting.functionTests.tests.lang.ForUpdateTest.testUpdates2(ForUpdateTest.java:232)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:88)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        2) testUpdates2(org.apache.derbyTesting.functionTests.tests.lang.ForUpdateTest)java.sql.SQLException: Invalid cursor name 'C4'.
        at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
        at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
        at org.apache.derby.client.am.Statement.executeUpdate(Unknown Source)
        at org.apache.derbyTesting.functionTests.tests.lang.ForUpdateTest.testUpdates2(ForUpdateTest.java:232)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:88)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        Caused by: org.apache.derby.client.am.SqlException: Invalid cursor name 'C4'.
        at org.apache.derby.client.am.Statement.flowExecute(Unknown Source)
        at org.apache.derby.client.am.Statement.executeUpdateX(Unknown Source)
        ... 34 more

        FAILURES!!!
        Tests run: 20, Failures: 0, Errors: 2

        Show
        Ramandeep Kaur added a comment - I am attaching patch for conversion of forupdate.sql to junit test "ForUpdateTest.java". I am having one problem during conversion. In method "public void testUpdates2()" in ForUpdateTest.java file, whenever, I uncomment line stmt3.executeUpdate("delete from t1 where current of C4");, I get the following error. .......E..........E... Time: 38.224 There were 2 errors: 1) testUpdates2(org.apache.derbyTesting.functionTests.tests.lang.ForUpdateTest)java.sql.SQLException: Cursor 'C4' not found. Verify that autocommit is OFF. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.impl.sql.compile.CurrentOfNode.bindNonVTITables(Unknown Source) at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source) at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown Source) at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown Source) at org.apache.derby.impl.sql.compile.DeleteNode.bindStatement(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unknown Source) at org.apache.derbyTesting.functionTests.tests.lang.ForUpdateTest.testUpdates2(ForUpdateTest.java:232) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:88) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.extensions.TestSetup.run(TestSetup.java:23) 2) testUpdates2(org.apache.derbyTesting.functionTests.tests.lang.ForUpdateTest)java.sql.SQLException: Invalid cursor name 'C4'. at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source) at org.apache.derby.client.am.Statement.executeUpdate(Unknown Source) at org.apache.derbyTesting.functionTests.tests.lang.ForUpdateTest.testUpdates2(ForUpdateTest.java:232) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:88) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.extensions.TestSetup.run(TestSetup.java:23) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.extensions.TestSetup.run(TestSetup.java:23) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.extensions.TestSetup.run(TestSetup.java:23) Caused by: org.apache.derby.client.am.SqlException: Invalid cursor name 'C4'. at org.apache.derby.client.am.Statement.flowExecute(Unknown Source) at org.apache.derby.client.am.Statement.executeUpdateX(Unknown Source) ... 34 more FAILURES!!! Tests run: 20, Failures: 0, Errors: 2

          People

          • Assignee:
            Ramandeep Kaur
            Reporter:
            Ramandeep Kaur
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development