Derby
  1. Derby
  2. DERBY-993

junitTests cannot be run with J2ME

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.2.1.6
    • Fix Version/s: 10.2.1.6
    • Component/s: Test
    • Labels:
      None
    • Environment:
      using J2ME jvm

      Description

      The test suite junitTests/LangSuite, and the .junit tests jdbcapi/SURTest.java and jdbcapi/SURQueryMixTest.java fail with J2ME, because it uses java.sql.Driver.
      There should be a way to use java.sql.DataSource instead of the Driver mechanism.

      1. DERBY-993-skipwfoundation.stat
        0.1 kB
        Myrna van Lunteren
      2. DERBY-993-skipwfoundation.diff
        0.6 kB
        Myrna van Lunteren
      3. DERBY-993_2006_03_20.diff
        14 kB
        Andreas Korneliussen
      4. DERBY-993_2006_03_20_b.stat
        0.6 kB
        Myrna van Lunteren
      5. DERBY-993_2006_03_20_b.diff
        15 kB
        Myrna van Lunteren
      6. DERBY-993_2006_03_18.diff
        15 kB
        Myrna van Lunteren

        Issue Links

          Activity

          Hide
          Myrna van Lunteren added a comment -

          Patch adds runwithfoundation=false to default_app.properties in this dir, so that the test gets skipped with j9_foundation, for now.

          Show
          Myrna van Lunteren added a comment - Patch adds runwithfoundation=false to default_app.properties in this dir, so that the test gets skipped with j9_foundation, for now.
          Hide
          Andrew McIntyre added a comment -

          Committed the skipwfoundation patch with revision 378129. Leaving this bug open because I think DerbyJUnitTest should have a way to use DataSource in J2ME environments. Ideally, DerbyJUnitTest.getConnection() should try to detect a J2ME environment and adjust as needed. The code already in functionTests.util.TestUtil can probably be reused/adapted for this purpose.

          Show
          Andrew McIntyre added a comment - Committed the skipwfoundation patch with revision 378129. Leaving this bug open because I think DerbyJUnitTest should have a way to use DataSource in J2ME environments. Ideally, DerbyJUnitTest.getConnection() should try to detect a J2ME environment and adjust as needed. The code already in functionTests.util.TestUtil can probably be reused/adapted for this purpose.
          Hide
          Rajesh Kartha added a comment -

          I suggest the main issue of providing a mechanism in DerbyJUnitTest to use DataSource, should be logged as a new JIRA entry. Hence this issue could be closed.

          Show
          Rajesh Kartha added a comment - I suggest the main issue of providing a mechanism in DerbyJUnitTest to use DataSource, should be logged as a new JIRA entry. Hence this issue could be closed.
          Hide
          Myrna van Lunteren added a comment -

          I disagree. The current patch was only an intermediate workaround to prevent the problem showing up in all nightly runs with J2ME. I maybe should change the title a bit, so it reads: test junitTest/LangSuite should be made to run with J2ME
          (instead of original: test junitTest/LangSuite cannot be run with J2ME)

          Show
          Myrna van Lunteren added a comment - I disagree. The current patch was only an intermediate workaround to prevent the problem showing up in all nightly runs with J2ME. I maybe should change the title a bit, so it reads: test junitTest/LangSuite should be made to run with J2ME (instead of original: test junitTest/LangSuite cannot be run with J2ME)
          Hide
          Myrna van Lunteren added a comment -

          I made this issue more generic to include the 2 jdbcapi/SUR*.java junit tests

          Show
          Myrna van Lunteren added a comment - I made this issue more generic to include the 2 jdbcapi/SUR*.java junit tests
          Hide
          Myrna van Lunteren added a comment -

          svn stat for patch DERBY-993_2006_03_18.diff is:
          M java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\SURBaseTest.java
          M java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\SURDataModelSetup.java
          M java\testing\org\apache\derbyTesting\functionTests\tests\junitTests\lang\BooleanTest.java
          M java\testing\org\apache\derbyTesting\functionTests\tests\junitTests\lang\default_app.properties
          M java\testing\org\apache\derbyTesting\functionTests\util\BaseJDBCTestCase.java

          This change affects the following tests:
          junitTests/lang/LangSuite.java (currently only listing BooleanTest.java)
          jdbcapi/SURTest.junit
          jdbcapi/SURQueryMixTest.junit
          lang/holdabilityTest.junit
          lang/SqlException.junit

          After this change, support for JSR169 run is implemented in a basic way in the new junit base jdbc test class, BaseJDBCTestCase (see also DERBY-1122).
          After this change, support for JSR169 is implemented for the junitTests/lang/LangSuite.java.

          As a side-effect, also, the SUR* tests are now dependent on the new ...util/BaseJDBCTestCase class rather
          then the default junit TestCase. (See DERBY-1122).
          I also removed the dependency on util.DerbyJunitTest.java, after copying the println, printstacktrace and alarm methods into BaseJDBCTestCase.java.

          I tried to make the junitTests/lang/LangSuite.java use the BaseJDBCTestCase, but it was too involved for me to tackle at this time, I'll leave that to someone else. I had to modify junitTests/lang/BooleanTest.java further because in addition to using java.sql.Driver, it was also using java.math.BigDecimal.

          With the changes in place, I can successfully run with both jdk142 and wctme5.7_foundation the following tests:
          junitTests/lang/LangSuite.java
          jdbcapi/SURTest.junit
          jdbcapi/SURQueryMixTest.junit
          jdbcapi/ConcurrencyTest.junit

          With the changes in place, the test
          lang/holdabilityTest.junit
          which is currently not in any suite, failed for me like this:
          -----------------------
          0 add
          > ........E.......
          > There was 1 error:
          > 1) testHeldScrollableResultSetScanInProgress(org.apache.derbyTesting.functionT
          ests.tests.jdbcapi.HoldabilityTest)ERROR XSCB8: The btree conglomerate 1,142,688
          ,750,742 is closed.
          > FAILURES!!!
          > Tests run: 15, Failures: 0, Errors: 1
          ---------------------------------
          Hopefully someone can verify that this test is still running as expected after my change, it fails for me with
          jdk14 with, or without my changes, although it seems the conglomerate number is different.
          Note, that after my change, with wctme5.7_foundation this test passes, which I found peculiar, but I'll not look into that either.

          derbynet/SqlExceptionTest.junit passes with -Dframework=DerbyNetClient, but I have not run it with
          wctme5.7_foundation, because we don't run networkserver with that setup.

          I have not looked at the junitTests/derbynet/Compatibility junit test, as they are only run in derbynetclientmats and thus,
          do not run with wctme5.7_foundation like this; and I didn't change anything that the test depends on.

          Show
          Myrna van Lunteren added a comment - svn stat for patch DERBY-993 _2006_03_18.diff is: M java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\SURBaseTest.java M java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\SURDataModelSetup.java M java\testing\org\apache\derbyTesting\functionTests\tests\junitTests\lang\BooleanTest.java M java\testing\org\apache\derbyTesting\functionTests\tests\junitTests\lang\default_app.properties M java\testing\org\apache\derbyTesting\functionTests\util\BaseJDBCTestCase.java This change affects the following tests: junitTests/lang/LangSuite.java (currently only listing BooleanTest.java) jdbcapi/SURTest.junit jdbcapi/SURQueryMixTest.junit lang/holdabilityTest.junit lang/SqlException.junit After this change, support for JSR169 run is implemented in a basic way in the new junit base jdbc test class, BaseJDBCTestCase (see also DERBY-1122 ). After this change, support for JSR169 is implemented for the junitTests/lang/LangSuite.java. As a side-effect, also, the SUR* tests are now dependent on the new ...util/BaseJDBCTestCase class rather then the default junit TestCase. (See DERBY-1122 ). I also removed the dependency on util.DerbyJunitTest.java, after copying the println, printstacktrace and alarm methods into BaseJDBCTestCase.java. I tried to make the junitTests/lang/LangSuite.java use the BaseJDBCTestCase, but it was too involved for me to tackle at this time, I'll leave that to someone else. I had to modify junitTests/lang/BooleanTest.java further because in addition to using java.sql.Driver, it was also using java.math.BigDecimal. With the changes in place, I can successfully run with both jdk142 and wctme5.7_foundation the following tests: junitTests/lang/LangSuite.java jdbcapi/SURTest.junit jdbcapi/SURQueryMixTest.junit jdbcapi/ConcurrencyTest.junit With the changes in place, the test lang/holdabilityTest.junit which is currently not in any suite, failed for me like this: ----------------------- 0 add > ........E....... > There was 1 error: > 1) testHeldScrollableResultSetScanInProgress(org.apache.derbyTesting.functionT ests.tests.jdbcapi.HoldabilityTest)ERROR XSCB8: The btree conglomerate 1,142,688 ,750,742 is closed. > FAILURES!!! > Tests run: 15, Failures: 0, Errors: 1 --------------------------------- Hopefully someone can verify that this test is still running as expected after my change, it fails for me with jdk14 with, or without my changes, although it seems the conglomerate number is different. Note, that after my change, with wctme5.7_foundation this test passes, which I found peculiar, but I'll not look into that either. derbynet/SqlExceptionTest.junit passes with -Dframework=DerbyNetClient, but I have not run it with wctme5.7_foundation, because we don't run networkserver with that setup. I have not looked at the junitTests/derbynet/Compatibility junit test, as they are only run in derbynetclientmats and thus, do not run with wctme5.7_foundation like this; and I didn't change anything that the test depends on.
          Hide
          Andreas Korneliussen added a comment -

          Review of DERBY-993-skipwfoundation.diff :
          Patch looks good, however I hope the following could be addressed:

          1. In SURBaseTest you have removed the getConnection() method. However getNewConnection() has been rewritten to use TestUtil instread of calling getConnection().. I think getNewConnection() could be left unchanged, so that it uses the BaseJDBCTestCase's getConnection() method.
          2. BaseTestCase: here methods for printing debug is added, which is good. I would like the _DEBUG flag removed from the class, and instead use CONFIG.verbose(). The _DEBUG flag does not seem to be initialized anywhere.

          The HoldabilityTest fails due to a bug in Derby. It should be enabled as part of fixing the bug in DERBY-1058.

          Show
          Andreas Korneliussen added a comment - Review of DERBY-993 -skipwfoundation.diff : Patch looks good, however I hope the following could be addressed: 1. In SURBaseTest you have removed the getConnection() method. However getNewConnection() has been rewritten to use TestUtil instread of calling getConnection().. I think getNewConnection() could be left unchanged, so that it uses the BaseJDBCTestCase's getConnection() method. 2. BaseTestCase: here methods for printing debug is added, which is good. I would like the _DEBUG flag removed from the class, and instead use CONFIG.verbose(). The _DEBUG flag does not seem to be initialized anywhere. The HoldabilityTest fails due to a bug in Derby. It should be enabled as part of fixing the bug in DERBY-1058 .
          Hide
          Andreas Korneliussen added a comment -

          The above review was for : DERBY-993_2006_03_18.diff, not for DERBY-993-skipwfoundation.diff .

          Show
          Andreas Korneliussen added a comment - The above review was for : DERBY-993 _2006_03_18.diff, not for DERBY-993 -skipwfoundation.diff .
          Hide
          Andreas Korneliussen added a comment -

          Attached is a patch where I have addressed the review comments above.
          The println, printStackTrace and alarm methods have been moved to BaseTestCase

          Show
          Andreas Korneliussen added a comment - Attached is a patch where I have addressed the review comments above. The println, printStackTrace and alarm methods have been moved to BaseTestCase
          Hide
          Myrna van Lunteren added a comment -

          The patch dated 3/20 gives the following with wctme5.7_foundation in test SURTest.junit:
          ------------
          java.sql.SQLException: org.apache.derby.jdbc.EmbeddedDriver is not registered with the JDBC driver manager
          at org.apache.derby.jdbc.EmbeddedSimpleDataSource.findDriver(EmbeddedSimpleDataSource.java:434)
          at org.apache.derby.jdbc.EmbeddedSimpleDataSource.getConnection(EmbeddedSimpleDataSource.java:405)
          at org.apache.derby.jdbc.EmbeddedSimpleDataSource.getConnection(EmbeddedSimpleDataSource.java:372)
          at org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase.getConnection(BaseJDBCTestCase.java:84)
          at org.apache.derbyTesting.functionTests.tests.jdbcapi.SURDataModelSetup.getNewConnection(SURDataModelSetup.java:174)
          at org.apache.derbyTesting.functionTests.tests.jdbcapi.SURDataModelSetup.setUp(SURDataModelSetup.java:140)
          at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
          at junit.framework.TestResult.runProtected(TestResult.java:124)
          at junit.extensions.TestSetup.run(TestSetup.java:23)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at junit.textui.TestRunner.doRun(TestRunner.java:116)
          at junit.textui.TestRunner.start(TestRunner.java:172)
          at junit.textui.TestRunner.main(TestRunner.java:138)
          -----------------------
          let me see what I can do.
          Also, it doesn't have the fix to TestUtil (which I erroneously added to DERBY-949), so I'll add that as well.

          Show
          Myrna van Lunteren added a comment - The patch dated 3/20 gives the following with wctme5.7_foundation in test SURTest.junit: ------------ java.sql.SQLException: org.apache.derby.jdbc.EmbeddedDriver is not registered with the JDBC driver manager at org.apache.derby.jdbc.EmbeddedSimpleDataSource.findDriver(EmbeddedSimpleDataSource.java:434) at org.apache.derby.jdbc.EmbeddedSimpleDataSource.getConnection(EmbeddedSimpleDataSource.java:405) at org.apache.derby.jdbc.EmbeddedSimpleDataSource.getConnection(EmbeddedSimpleDataSource.java:372) at org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase.getConnection(BaseJDBCTestCase.java:84) at org.apache.derbyTesting.functionTests.tests.jdbcapi.SURDataModelSetup.getNewConnection(SURDataModelSetup.java:174) at org.apache.derbyTesting.functionTests.tests.jdbcapi.SURDataModelSetup.setUp(SURDataModelSetup.java:140) at junit.extensions.TestSetup$1.protect(TestSetup.java:18) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.extensions.TestSetup.run(TestSetup.java:23) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.textui.TestRunner.doRun(TestRunner.java:116) at junit.textui.TestRunner.start(TestRunner.java:172) at junit.textui.TestRunner.main(TestRunner.java:138) ----------------------- let me see what I can do. Also, it doesn't have the fix to TestUtil (which I erroneously added to DERBY-949 ), so I'll add that as well.
          Hide
          Myrna van Lunteren added a comment -

          I tried supersimple in that environment with wctme5.7_foundation, and it failed too...
          So I redid Andreas' patch in another environment, and it all looked good.
          I added my TestUtil change and removed the unused and incorrect classname from BaseJDBCTestCase.java.

          I reran the affected tests again and it all looks ok now - except HoldabilityTest which we identified was suffering from DERBY-1058.

          Show
          Myrna van Lunteren added a comment - I tried supersimple in that environment with wctme5.7_foundation, and it failed too... So I redid Andreas' patch in another environment, and it all looked good. I added my TestUtil change and removed the unused and incorrect classname from BaseJDBCTestCase.java. I reran the affected tests again and it all looks ok now - except HoldabilityTest which we identified was suffering from DERBY-1058 .
          Hide
          Andrew McIntyre added a comment -

          Patch 20_b looks good to me. I'll commit shortly. Thanks for working on this, Andreas and Myrna.

          Show
          Andrew McIntyre added a comment - Patch 20_b looks good to me. I'll commit shortly. Thanks for working on this, Andreas and Myrna.
          Hide
          Andrew McIntyre added a comment -

          Committed revision 387605.

          Show
          Andrew McIntyre added a comment - Committed revision 387605.

            People

            • Assignee:
              Myrna van Lunteren
              Reporter:
              Myrna van Lunteren
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development