Fix security testcases for IBM JVM.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@1456669 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -87,7 +87,13 @@ public class MockSecurityManager extends SecurityManager {
|
||||
for(int i=1; i<stack.length; ++i) {
|
||||
String cname = stack[i].getClassName();
|
||||
System.out.println("" + i + ":" + stack[i].getClassName() +
|
||||
"." + stack[i].getMethodName());
|
||||
"." + stack[i].getMethodName() + stack[i].getLineNumber());
|
||||
|
||||
if (cname.equals("java.util.logging.Handler") && stack[i].getMethodName().equals("setLevel")) {
|
||||
// LOGGING CODE CAUSES ACCESSCONTROLEXCEPTION
|
||||
// http://www-01.ibm.com/support/docview.wss?uid=swg1IZ51152
|
||||
return;
|
||||
}
|
||||
|
||||
if (cname.equals("java.security.AccessController")) {
|
||||
// Presumably method name equals "doPrivileged"
|
||||
|
||||
@@ -123,7 +123,9 @@ public class SecurityAllowedTestCase extends TestCase
|
||||
assertNotNull(factoryTable);
|
||||
assertEquals(CustomHashtable.class.getName(), factoryTable.getClass().getName());
|
||||
|
||||
assertEquals(0, untrustedCodeCount);
|
||||
// we better compare that we have no security exception during the call to log
|
||||
// IBM JVM tries to load bundles during the invoke call, which increase the count
|
||||
assertEquals(untrustedCodeCount, mySecurityManager.getUntrustedCodeCount());
|
||||
} catch(Throwable t) {
|
||||
// Restore original security manager so output can be generated; the
|
||||
// PrintWriter constructor tries to read the line.separator
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SecurityForbiddenTestCase extends TestCase
|
||||
|
||||
/**
|
||||
* Test what happens when JCL is run with absolutely no security
|
||||
* priveleges at all, including reading system properties. Everything
|
||||
* privileges at all, including reading system properties. Everything
|
||||
* should fall back to the built-in defaults.
|
||||
*/
|
||||
public void testAllForbidden() {
|
||||
@@ -93,6 +93,7 @@ public class SecurityForbiddenTestCase extends TestCase
|
||||
LogFactory.HASHTABLE_IMPLEMENTATION_PROPERTY,
|
||||
CustomHashtable.class.getName());
|
||||
MockSecurityManager mySecurityManager = new MockSecurityManager();
|
||||
|
||||
System.setSecurityManager(mySecurityManager);
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user