Derby
  1. Derby
  2. DERBY-4950

AccessControlException when running AssertFailureTest from Ant

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.8.1.2
    • Fix Version/s: 10.8.1.2
    • Component/s: Test
    • Labels:
      None
    • Bug behavior facts:
      Regression Test Failure

      Description

      Seen when running "ant junit-all":

      [junit] Running org.apache.derbyTesting.unitTests.junit._Suite
      [junit] Exception in thread "main" java.security.AccessControlException: access denied (java.io.FilePermission /code/derby/trunk0/junit_20101222_2349/junitvmwatcher3394322945027170783.properties write)
      [junit] at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
      [junit] at java.security.AccessController.checkPermission(AccessController.java:546)
      [junit] at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
      [junit] at java.lang.SecurityManager.checkWrite(SecurityManager.java:962)
      [junit] at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
      [junit] at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
      [junit] at java.io.FileWriter.<init>(FileWriter.java:46)
      [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.registerTestCase(JUnitTestRunner.java:939)
      [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.access$000(JUnitTestRunner.java:68)
      [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner$2.startTest(JUnitTestRunner.java:808)
      [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner$3.startTest(JUnitTestRunner.java:1004)
      [junit] at junit.framework.TestResult.startTest(TestResult.java:151)
      [junit] at junit.framework.TestResult.run(TestResult.java:103)
      [junit] at junit.framework.TestCase.run(TestCase.java:120)
      [junit] at junit.framework.TestSuite.runTest(TestSuite.java:230)
      [junit] at junit.framework.TestSuite.run(TestSuite.java:225)
      [junit] at junit.framework.TestSuite.runTest(TestSuite.java:230)
      [junit] at junit.framework.TestSuite.run(TestSuite.java:225)
      [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:420)
      [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:911)
      [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:768)
      [junit] Running org.apache.derbyTesting.unitTests.junit._Suite
      [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
      [junit] Test org.apache.derbyTesting.unitTests.junit._Suite FAILED (crashed)

      1. d4950.diff
        1 kB
        Knut Anders Hatlen

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        Committed revision 1052203.

        Show
        Knut Anders Hatlen added a comment - Committed revision 1052203.
        Hide
        Knut Anders Hatlen added a comment -

        The problem seems to be that AssertFailureTest installs its own security policy, but this policy doesn't grant any privileges to junit.jar. The attached patch copies the following from derby_test.policy into the custom policy files for AssertFailureTest:

        grant codeBase "$

        {derbyTesting.junit}

        " {
        // This permission is needed when running the tests using ant 1.7
        permission java.io.FilePermission "$

        {user.dir}

        $

        {/}

        *", "write";
        };

        This allows Ant's JUnit runner to write to junitvmwatcherXYZ.properties, and the test runs cleanly again.

        Show
        Knut Anders Hatlen added a comment - The problem seems to be that AssertFailureTest installs its own security policy, but this policy doesn't grant any privileges to junit.jar. The attached patch copies the following from derby_test.policy into the custom policy files for AssertFailureTest: grant codeBase "$ {derbyTesting.junit} " { // This permission is needed when running the tests using ant 1.7 permission java.io.FilePermission "$ {user.dir} $ {/} *", "write"; }; This allows Ant's JUnit runner to write to junitvmwatcherXYZ.properties, and the test runs cleanly again.

          People

          • Assignee:
            Knut Anders Hatlen
            Reporter:
            Knut Anders Hatlen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development