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