db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1620793 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: junit/SecurityManagerSetup.java unitTests/junit/MissingPermissionsTest.policy
Date Wed, 27 Aug 2014 08:09:56 GMT
Author: kahatlen
Date: Wed Aug 27 08:09:56 2014
New Revision: 1620793

URL: http://svn.apache.org/r1620793
Log:
DERBY-6715: MissingPermissionsTest fails under JaCoCo

Add permissions required by JaCoCo to the custom policy used by the test.

Change how SecurityManagerSetup checks for JaCoCo. By using
Class.forName() instead of getURL() we avoid the need for calling the
privileged getProtectionDomain() method, and the URL of the JaCoCo jar
file is not needed.

(It is usually OK to call this method without any special permissions
granted when the SecurityManagerSetup class is initialized. This is
because the SecurityManagerSetup is usually initialized before a
SecurityManager has been installed. In this test, however, a
subprocess is started with -Djava.security.manager, so a
SecurityManager is already in place before the SecurityManagerSetup
class is initialized in the subprocess.)

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java?rev=1620793&r1=1620792&r2=1620793&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
Wed Aug 27 08:09:56 2014
@@ -97,11 +97,14 @@ public final class SecurityManagerSetup 
     private static boolean checkIfJacocoIsRunning() {
         return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
                 public Boolean run() {
-                    if (getURL("org.jacoco.agent.rt.RT") != null) {
-                        System.setProperty("jacoco.active", "");
-                        return Boolean.TRUE;
+                    try {
+                        Class.forName("org.jacoco.agent.rt.RT");
+                        return true;
+                    } catch (ClassNotFoundException e) {
+                        return false;
+                    } catch (LinkageError e) {
+                        return false;
                     }
-                    return Boolean.FALSE;
                 }
         });
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy?rev=1620793&r1=1620792&r2=1620793&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy
Wed Aug 27 08:09:56 2014
@@ -154,3 +154,9 @@ grant codeBase "${derbyTesting.antjunit}
     // This permission is needed when running the tests using ant 1.7
     permission java.io.FilePermission "${user.dir}${/}*", "write";
 };
+
+// Grant the required permissions for JaCoCo (code coverage tool).
+grant {
+  permission java.io.FilePermission "${jacoco.active}${user.dir}${/}*", "read, write";
+  permission java.lang.RuntimePermission "${jacoco.active}shutdownHooks";
+};



Mime
View raw message