< prev index next >

test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -26,23 +26,32 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 
 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 {
+    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);
 

@@ -54,13 +63,10 @@
             factory = SAXParserFactory.newInstance();
             if (System.getSecurityManager() == null)
                 Assert.assertTrue(myClassLoaderUsed);
             else
                 Assert.assertFalse(myClassLoaderUsed);
-        } catch (Exception ex) {
-        }
-
     }
 
     class MyClassLoader extends URLClassLoader {
 
         public MyClassLoader() {
< prev index next >