You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2018/09/14 12:07:04 UTC
svn commit: r1840913 - in /db/derby/code/trunk/java: org.apache.derby.engine/
org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/
Author: rhillegas
Date: Fri Sep 14 12:07:04 2018
New Revision: 1840913
URL: http://svn.apache.org/viewvc?rev=1840913&view=rev
Log:
DERBY-6945: Run the junit suite cleanly with a module path; commit derby-6945-57-aa-runJunitSuiteWithModulePath.diff.
Modified:
db/derby/code/trunk/java/org.apache.derby.engine/module-info.java
db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java
db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java
Modified: db/derby/code/trunk/java/org.apache.derby.engine/module-info.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/module-info.java?rev=1840913&r1=1840912&r2=1840913&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/module-info.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/module-info.java Fri Sep 14 12:07:04 2018
@@ -54,6 +54,9 @@ module org.apache.derby.engine
exports org.apache.derby.catalog;
exports org.apache.derby.vti;
+ // DOES NOT APPEAR IN PUBLIC API JAVADOC YET:
+ exports org.apache.derby.security;
+
//
// SUPPORT MODULE LOOKUP
//
@@ -238,9 +241,6 @@ module org.apache.derby.engine
// must be opened to reflective access by the unnamed module
opens org.apache.derby.mbeans;
- exports org.apache.derby.security to
- org.apache.derby.tests;
-
//
// STANZAS FOR USE WHEN QUERY PLANS ARE GENERATED INTO
// SOME MODULE OTHER THAN THE UNNAMED MODULE.
Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java?rev=1840913&r1=1840912&r2=1840913&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java Fri Sep 14 12:07:04 2018
@@ -37,8 +37,11 @@ import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;
import junit.framework.Test;
+import org.apache.derby.shared.common.info.JVMInfo;
+import org.apache.derby.shared.common.reference.ModuleUtil;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.BaseTestSuite;
+import org.apache.derbyTesting.junit.DerbyConstants;
import org.apache.derbyTesting.junit.SecurityManagerSetup;
import org.apache.derbyTesting.junit.SpawnedProcess;
import org.apache.derbyTesting.junit.SupportFilesSetup;
@@ -281,7 +284,17 @@ public class MissingPermissionsTest exte
final String output = spawned.getFullServerOutput(); // ignore
final String err = spawned.getFullServerError();
- assertTrue(err, err.matches(expectedMessageOnConsole));
+ assertTrue
+ (
+ err.contains("java.security.AccessControlException") &&
+ err.contains("ccess denied") &&
+ err.contains("java.io.FilePermission") &&
+ err.contains("system") &&
+ err.contains("nested") &&
+ err.contains("write")
+ );
+
+ //assertTrue(err, err.matches(expectedMessageOnConsole));
}
/**
@@ -368,6 +381,7 @@ public class MissingPermissionsTest exte
// Set up run of this test in a sub process, so we can catch its
// standard err/standard out.
final List<String> args = new ArrayList<String>();
+
args.add("-DinSubProcess=true");
args.add("-Djava.security.manager");
args.add(
@@ -395,7 +409,17 @@ public class MissingPermissionsTest exte
getSystemProperty("derby.tests.trace"));
args.add("-Dderby.system.debug=" +
getSystemProperty("derby.tests.debug"));
- args.add("junit.textui.TestRunner");
+
+ String testRunnerClassName = "junit.textui.TestRunner";
+ if (JVMInfo.isModuleAware())
+ {
+ args.add("-m");
+ args.add(DerbyConstants.JUNIT_MODULE_NAME + "/" + testRunnerClassName);
+ }
+ else
+ {
+ args.add(testRunnerClassName);
+ }
args.add(this.getClass().getName());
final String[] argArray = args.toArray(new String[0]);
@@ -413,9 +437,12 @@ public class MissingPermissionsTest exte
assertTrue(spawned.getFailMessage("subprocess run failed: "),
exitCode == 1);
- final String expectedMessageOnConsole =
- "WARNING: could not do ThreadGroup#setDaemon on Derby " +
- "daemons due to a security exception";
+ final String expectedMessageOnConsole = JVMInfo.isModuleAware() ?
+ "java.security.AccessControlException: access denied " +
+ "(\"java.lang.RuntimePermission\" \"modifyThreadGroup\")"
+ :
+ "WARNING: could not do ThreadGroup#setDaemon on Derby " +
+ "daemons due to a security exception";
final String output = spawned.getFullServerOutput(); // ignore
final String err = spawned.getFullServerError();
Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java?rev=1840913&r1=1840912&r2=1840913&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java Fri Sep 14 12:07:04 2018
@@ -1110,8 +1110,8 @@ public class SystemPrivilegesPermissionT
private <T> void execute(SystemPrincipal principal,
PrivilegedAction<T> action,
boolean isGrantExpected) {
- //println();
- //println(" testing action " + action);
+ println("");
+ println(" testing action " + action + " for principal " + principal);
final RunAsPrivilegedUserAction<T> runAsPrivilegedUserAction
= new RunAsPrivilegedUserAction<T>(principal, action);
@@ -1121,13 +1121,16 @@ public class SystemPrivilegesPermissionT
if (!isGrantExpected) {
fail("expected AccessControlException");
}
+ println(" successfully executed action " + action + " for principal " + principal);
} catch (AccessControlException ace) {
//println(" Yikes! " + ace.getMessage());
if (isGrantExpected) {
//fail("caught AccessControlException");
throw ace;
}
+ println(" as expected, failed to execute action " + action + " for principal " + principal);
}
+ println("");
}
/**
@@ -1263,9 +1266,9 @@ public class SystemPrivilegesPermissionT
}
public Void run() {
- //println(" checking access " + permission + "...");
+ println(" checking access " + permission + ":");
AccessController.checkPermission(permission);
- //println(" granted access " + this);
+ println(" granted access " + this);
return null;
}