< prev index next >

test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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.

@@ -20,174 +20,142 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 package org.xml.sax.ptests;
 
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
-import static jaxp.library.JAXPTestUtilities.failUnexpected;
+import jaxp.library.JAXPBaseTest;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 import org.testng.annotations.Test;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
 import org.xml.sax.XMLReader;
 
 /**
  * Class containing the test cases for Namespace Table defined at
  * http://www.megginson.com/SAX/Java/namespaces.html
  */
-public class NSTableTest01 {
+public class NSTableTest extends JAXPBaseTest {
     private static final String NAMESPACES =
                         "http://xml.org/sax/features/namespaces";
     private static final String NAMESPACE_PREFIXES =
                         "http://xml.org/sax/features/namespace-prefixes";
 
     /**
      * Here namespace processing and namespace-prefixes are enabled.
      * The testcase tests XMLReader for this.
+     * 
+     * @throws Exception If any errors occur.
      */
     @Test
-    public void xrNSTable01() {
-        try {
+    public void xrNSTable01() throws Exception {
             SAXParserFactory spf = SAXParserFactory.newInstance();
             spf.setNamespaceAware(true);
             SAXParser saxParser = spf.newSAXParser();
 
             XMLReader xmlReader = saxParser.getXMLReader();
             xmlReader.setFeature(NAMESPACE_PREFIXES, true);
 
             assertTrue(xmlReader.getFeature(NAMESPACES));
             assertTrue(xmlReader.getFeature(NAMESPACE_PREFIXES));
-        } catch (ParserConfigurationException | SAXException ex) {
-            failUnexpected(ex);
-        }
     }
 
     /**
      * Here namespace processing is enabled. This will make namespace-prefixes
      * disabled. The testcase tests XMLReader for this.
+     * 
+     * @throws Exception If any errors occur.
      */
     @Test
-    public void xrNSTable02() {
-        try {
+    public void xrNSTable02() throws Exception {
             SAXParserFactory spf = SAXParserFactory.newInstance();
             spf.setNamespaceAware(true);
-            SAXParser saxParser = spf.newSAXParser();
 
-            XMLReader xmlReader = saxParser.getXMLReader();
+        XMLReader xmlReader = spf.newSAXParser().getXMLReader();
             assertTrue(xmlReader.getFeature(NAMESPACES));
             assertFalse(xmlReader.getFeature(NAMESPACE_PREFIXES));
-        } catch (ParserConfigurationException | SAXException ex) {
-            failUnexpected(ex);
-        }
-
     }
 
     /**
      * Here namespace processing is disabled. This will make namespace-prefixes
      * enabled. The testcase tests XMLReader for this.
+     * 
+     * @throws Exception If any errors occur.
      */
     @Test
-    public void xrNSTable03() {
-        try {
-            SAXParserFactory spf = SAXParserFactory.newInstance();
-            SAXParser saxParser = spf.newSAXParser();
-            XMLReader xmlReader = saxParser.getXMLReader();
+    public void xrNSTable03() throws Exception {
+        XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
             assertFalse(xmlReader.getFeature(NAMESPACES));
             assertTrue(xmlReader.getFeature(NAMESPACE_PREFIXES));
-        } catch (ParserConfigurationException | SAXException ex) {
-            failUnexpected(ex);
-        }
     }
 
     /**
      * Here namespace processing is disabled, and namespace-prefixes is
      * disabled. This will make namespace processing on.The testcase tests
      * XMLReader for this.  This behavior only apply to crimson, not
-     * xerces
+     * XERCES.
+     * 
+     * @throws Exception If any errors occur.
      */
     @Test
-    public void xrNSTable04() {
-        try {
-            SAXParserFactory spf = SAXParserFactory.newInstance();
-            SAXParser saxParser = spf.newSAXParser();
-            XMLReader xmlReader = saxParser.getXMLReader();
+    public void xrNSTable04() throws Exception {
+        XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
             xmlReader.setFeature(NAMESPACE_PREFIXES, false);
-
             assertFalse(xmlReader.getFeature(NAMESPACE_PREFIXES));
-        } catch (ParserConfigurationException | SAXException ex) {
-            failUnexpected(ex);
-        }
     }
 
     /**
      * Here namespace processing and namespace-prefixes are enabled.
      * The testcase tests SAXParserFactory for this.
+     * 
+     * @throws Exception If any errors occur.
      */
     @Test
-    public void spNSTable01() {
-        try {
+    public void spNSTable01() throws Exception {
             SAXParserFactory spf = SAXParserFactory.newInstance();
             spf.setNamespaceAware(true);
             spf.setFeature(NAMESPACE_PREFIXES,true);
             assertTrue(spf.getFeature(NAMESPACES));
             assertTrue(spf.getFeature(NAMESPACE_PREFIXES));
-        } catch (ParserConfigurationException | SAXNotRecognizedException
-                | SAXNotSupportedException ex) {
-            failUnexpected(ex);
-        }
     }
 
     /**
      * Here namespace processing is enabled. This will make namespace-prefixes
      * disabled. The testcase tests SAXParserFactory for this.
+     * 
+     * @throws Exception If any errors occur.
      */
     @Test
-    public void spNSTable02() {
-        try {
+    public void spNSTable02() throws Exception {
             SAXParserFactory spf = SAXParserFactory.newInstance();
             spf.setNamespaceAware(true);
             assertTrue(spf.getFeature(NAMESPACES));
             assertFalse(spf.getFeature(NAMESPACE_PREFIXES));
-        } catch (ParserConfigurationException | SAXNotRecognizedException
-                | SAXNotSupportedException ex) {
-            failUnexpected(ex);
-        }
     }
 
     /**
      * Here namespace processing is disabled. This will make namespace-prefixes
      * enabled. The testcase tests SAXParserFactory for this.
+     * 
+     * @throws Exception If any errors occur.
      */
     @Test
-    public void spNSTable03() {
-        try {
+    public void spNSTable03() throws Exception {
             SAXParserFactory spf = SAXParserFactory.newInstance();
             assertFalse(spf.getFeature(NAMESPACES));
             assertTrue(spf.getFeature(NAMESPACE_PREFIXES));
-        } catch (ParserConfigurationException | SAXNotRecognizedException
-                | SAXNotSupportedException ex) {
-            failUnexpected(ex);
-        }
     }
     /**
      * Here namespace processing is disabled, and namespace-prefixes is
      * disabled. This will make namespace processing on.The testcase tests
      * SAXParserFactory for this.  This behavior only apply to crimson,
      * not xerces.
+     * 
+     * @throws Exception If any errors occur.
      */
     @Test
-    public void spNSTable04() {
-        try {
+    public void spNSTable04() throws Exception {
             SAXParserFactory spf = SAXParserFactory.newInstance();
             spf.setFeature(NAMESPACE_PREFIXES, false);
-
             assertFalse(spf.getFeature(NAMESPACE_PREFIXES));
-        } catch (ParserConfigurationException | SAXNotRecognizedException
-                | SAXNotSupportedException ex) {
-            failUnexpected(ex);
-        }
     }
 }
< prev index next >