--- old/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java 2016-07-18 00:51:00.322783771 -0700 +++ new/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java 2016-07-18 00:51:00.198845771 -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 @@ -28,37 +28,43 @@ import javax.xml.parsers.SAXParserFactory; +import jaxp.library.JAXPTestUtilities; + import org.testng.Assert; import org.testng.annotations.Test; /* * @summary Test Classloader for SAXParserFactory. */ +@Test(singleThreaded = true) public class FactoryFindTest { boolean myClassLoaderUsed = false; - @Test - public void testFactoryFind() { - try { - // System.setProperty("jaxp.debug", "true"); - - SAXParserFactory factory = SAXParserFactory.newInstance(); - Assert.assertTrue(factory.getClass().getClassLoader() == null); - - Thread.currentThread().setContextClassLoader(null); - factory = SAXParserFactory.newInstance(); - Assert.assertTrue(factory.getClass().getClassLoader() == null); - - Thread.currentThread().setContextClassLoader(new MyClassLoader()); - factory = SAXParserFactory.newInstance(); - if (System.getSecurityManager() == null) - Assert.assertTrue(myClassLoaderUsed); - else - Assert.assertFalse(myClassLoaderUsed); - } catch (Exception ex) { - } + public void runWithSecurityManager() throws Exception { + JAXPTestUtilities.tryRunWithPolicyManager(() -> testFactoryFind()); + } + + public void runWithoutSecurityManager() throws Exception { + testFactoryFind(); + } + + private void testFactoryFind() { + // System.setProperty("jaxp.debug", "true"); + + SAXParserFactory factory = SAXParserFactory.newInstance(); + Assert.assertTrue(factory.getClass().getClassLoader() == null); + Thread.currentThread().setContextClassLoader(null); + factory = SAXParserFactory.newInstance(); + Assert.assertTrue(factory.getClass().getClassLoader() == null); + + Thread.currentThread().setContextClassLoader(new MyClassLoader()); + factory = SAXParserFactory.newInstance(); + if (System.getSecurityManager() == null) + Assert.assertTrue(myClassLoaderUsed); + else + Assert.assertFalse(myClassLoaderUsed); } class MyClassLoader extends URLClassLoader {