--- old/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java 2016-07-21 20:35:45.508027778 -0700 +++ new/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java 2016-07-21 20:35:45.394027778 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ package xpath; +import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; @@ -42,6 +43,8 @@ import javax.xml.xpath.XPathFunctionException; import javax.xml.xpath.XPathFunctionResolver; +import jaxp.library.JAXPTestUtilities; + import org.testng.Assert; import org.testng.annotations.Test; import org.w3c.dom.Document; @@ -50,19 +53,19 @@ /* * @summary Test when FEATURE_SECURE_PROCESSING is true, calling an external function will cause XPathFunctionException. */ +@Test(singleThreaded = true) public class SecureProcessingTest { - static boolean _isSecureMode = false; - static { - if (System.getSecurityManager() != null) { - _isSecureMode = true; - System.out.println("Security Manager is present"); - } else { - System.out.println("Security Manager is NOT present"); - } + public void runWithSecurityManager() throws Exception { + JAXPTestUtilities.tryRunWithPolicyManager(() -> testSecureProcessing(), + new FilePermission(System.getProperty("test.src") + "/-", "read")); + } + + public void runWithoutSecurityManager() throws Exception { + testSecureProcessing(); } - @Test - public final void testSecureProcessing() { + private final void testSecureProcessing() { + boolean _isSecureMode = System.getSecurityManager() != null; final String XPATH_EXPRESSION = "ext:helloWorld()"; @@ -150,7 +153,7 @@ } } - public class MyXPathFunctionResolver implements XPathFunctionResolver { + private class MyXPathFunctionResolver implements XPathFunctionResolver { public XPathFunction resolveFunction(QName functionName, int arity) { @@ -159,7 +162,7 @@ } } - public class MyXPathFunction implements XPathFunction { + private class MyXPathFunction implements XPathFunction { public Object evaluate(List list) throws XPathFunctionException { @@ -167,7 +170,7 @@ } } - public class MyNamespaceContext implements NamespaceContext { + private class MyNamespaceContext implements NamespaceContext { public String getNamespaceURI(String prefix) { if (prefix == null) {