--- old/test/javax/xml/jaxp/unittest/validation/Bug6483188.java 2016-07-18 00:52:23.028130271 -0700 +++ new/test/javax/xml/jaxp/unittest/validation/Bug6483188.java 2016-07-18 00:52:22.899130271 -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 validation; +import java.io.FilePermission; import java.net.URL; import javax.xml.XMLConstants; @@ -30,6 +31,8 @@ import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; +import jaxp.library.JAXPTestUtilities; + import org.testng.Assert; import org.testng.annotations.Test; import org.xml.sax.SAXParseException; @@ -38,22 +41,26 @@ * @bug 6483188 * @summary Test Schema Validator can handle element with having large maxOccurs, but doesn't accept sequence with having large maxOccurs in FEATURE_SECURE_PROCESSING mode. */ +@Test(singleThreaded = true) public class Bug6483188 { - 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"); - } + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + + public void runWithSecurityManager() throws Exception { + JAXPTestUtilities.tryRunWithPolicyManager(() -> { + testLargeElementNoSecurity(); + testLargeElementWithSecurity(); + testLargeSequenceWithSecurity(); + }, new FilePermission(System.getProperty("test.src") + "/-", "read")); } - SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + public void runWithoutSecurityManager() throws Exception { + testLargeElementNoSecurity(); + testLargeElementWithSecurity(); + testLargeSequenceWithSecurity(); + } - @Test - public void testLargeElementNoSecurity() { - if (_isSecureMode) + private void testLargeElementNoSecurity() { + if (System.getSecurityManager() != null) return; // jaxp secure feature can not be turned off when security // manager is present try { @@ -66,8 +73,7 @@ } } - @Test - public void testLargeElementWithSecurity() { + private void testLargeElementWithSecurity() { try { sf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); URL url = getClass().getResource("test-element.xsd"); @@ -78,8 +84,7 @@ } } - @Test - public void testLargeSequenceWithSecurity() { + private void testLargeSequenceWithSecurity() { try { sf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); URL url = getClass().getResource("test-sequence.xsd");