Derby
  1. Derby
  2. DERBY-2727

convert lang/AggregateClassLoading to JUnit.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.4.1.3
    • Component/s: Test
    • Labels:
      None
    1. DERBY-2727_diff_120607.txt
      7 kB
      Ugo Matrangolo
    2. DERBY-2727_stat_120607.txt
      0.3 kB
      Ugo Matrangolo
    3. DERBY-2727_diff_240607.txt
      7 kB
      Ugo Matrangolo
    4. DERBY-2727_stat_240607.txt
      0.3 kB
      Ugo Matrangolo

      Activity

      Hide
      Ugo Matrangolo added a comment -

      Initial attempt to convert this test.

      At first sight it seems trivial to convert but, obviously, he doesn't work!

      Running the test I get a security exception:

      java.security.AccessControlException: access denied (java.lang.RuntimePermission getProtectionDomain)
      at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
      at java.security.AccessController.checkPermission(AccessController.java:401)
      at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
      at java.lang.Class.getProtectionDomain(Class.java:1392)
      at org.apache.derbyTesting.functionTests.tests.lang.AggregateClassLoadingTest$1.decorateSQL(AggregateClassLoadingTest.java:106)
      at org.apache.derbyTesting.junit.CleanDatabaseTestSetup.setUp(CleanDatabaseTestSetup.java:70)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:20)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.extensions.TestSetup.run(TestSetup.java:25)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.extensions.TestSetup.run(TestSetup.java:25)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.extensions.TestSetup.run(TestSetup.java:25)
      at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
      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)

      Can someone point me toward the solution of this ??

      Thank you in advance,
      – Ugo.

      Show
      Ugo Matrangolo added a comment - Initial attempt to convert this test. At first sight it seems trivial to convert but, obviously, he doesn't work! Running the test I get a security exception: java.security.AccessControlException: access denied (java.lang.RuntimePermission getProtectionDomain) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269) at java.security.AccessController.checkPermission(AccessController.java:401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:524) at java.lang.Class.getProtectionDomain(Class.java:1392) at org.apache.derbyTesting.functionTests.tests.lang.AggregateClassLoadingTest$1.decorateSQL(AggregateClassLoadingTest.java:106) at org.apache.derbyTesting.junit.CleanDatabaseTestSetup.setUp(CleanDatabaseTestSetup.java:70) at junit.extensions.TestSetup$1.protect(TestSetup.java:20) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.extensions.TestSetup.run(TestSetup.java:25) at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.extensions.TestSetup.run(TestSetup.java:25) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.extensions.TestSetup.run(TestSetup.java:25) at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57) 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) Can someone point me toward the solution of this ?? Thank you in advance, – Ugo.
      Hide
      Ugo Matrangolo added a comment -

      Followinf from the previous comment: the code that fails is :

      /*

      • Find the location of the code for the Derby connection. The
      • rest of the engine will be at the same location!
        */
        derbyURL = s.getConnection().getClass().getProtectionDomain().getCodeSource().getLocation();

      borrowed from the old test. I suspect that the context is not the same of the old harness test.

      – Ugo.

      Show
      Ugo Matrangolo added a comment - Followinf from the previous comment: the code that fails is : /* Find the location of the code for the Derby connection. The rest of the engine will be at the same location! */ derbyURL = s.getConnection().getClass().getProtectionDomain().getCodeSource().getLocation(); borrowed from the old test. I suspect that the context is not the same of the old harness test. – Ugo.
      Hide
      Kathey Marsden added a comment -

      I see that for the original test there is a AggregateClassLoading_app.properties
      which has:

      1. this test creates a class loader, adding that permission to
      2. derbyTesting.jar would mean that permission was granted all
      3. the way up the stack to the derby engine. Thus increasing
      4. the chance that incorrectly a privileged block could be dropped
      5. but the tests continue to pass.
        noSecurityManager=true

      The equivalant junit decorator is org.apache.derbyTesting.junit.SecurityManagerSetup.noSecurityManager(Test test);
      http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.html#noSecurityManager(junit.framework.Test)

      Show
      Kathey Marsden added a comment - I see that for the original test there is a AggregateClassLoading_app.properties which has: this test creates a class loader, adding that permission to derbyTesting.jar would mean that permission was granted all the way up the stack to the derby engine. Thus increasing the chance that incorrectly a privileged block could be dropped but the tests continue to pass. noSecurityManager=true The equivalant junit decorator is org.apache.derbyTesting.junit.SecurityManagerSetup.noSecurityManager(Test test); http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.html#noSecurityManager(junit.framework.Test )
      Hide
      Ugo Matrangolo added a comment -

      Thank you Kathey. I will modify the code asap.

      Bye,
      – Ugo

      Show
      Ugo Matrangolo added a comment - Thank you Kathey. I will modify the code asap. Bye, – Ugo
      Hide
      Ugo Matrangolo added a comment -

      Code modified accordingly to the Kathey's comments.

      Please review,
      – Ugo.

      Show
      Ugo Matrangolo added a comment - Code modified accordingly to the Kathey's comments. Please review, – Ugo.
      Hide
      Kathey Marsden added a comment -

      I committed this patch with the following changes.

      • Removed old test files
      • Removed Database/System property setup for usedefaults. usedefaults has no meaning outside the old test harness.

      Thanks Ugo!

      Show
      Kathey Marsden added a comment - I committed this patch with the following changes. Removed old test files Removed Database/System property setup for usedefaults. usedefaults has no meaning outside the old test harness. Thanks Ugo!
      Hide
      Daniel John Debrunner added a comment -

      I have a fix for this but cannot apply it because the patch was already reverted

      Show
      Daniel John Debrunner added a comment - I have a fix for this but cannot apply it because the patch was already reverted
      Hide
      Daniel John Debrunner added a comment -

      Renabled converted test with fixes for IBM 1.5. Committed revision 551732

      Show
      Daniel John Debrunner added a comment - Renabled converted test with fixes for IBM 1.5. Committed revision 551732
      Hide
      Myrna van Lunteren added a comment -

      It appears to me that this is fixed, now. Leaving to reporter to close.

      Show
      Myrna van Lunteren added a comment - It appears to me that this is fixed, now. Leaving to reporter to close.

        People

        • Assignee:
          Ugo Matrangolo
          Reporter:
          Ugo Matrangolo
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved:

            Development