< prev index next >

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

Print this page

        

*** 23,193 **** 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 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 { 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. */ @Test ! public void xrNSTable01() { ! try { 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. */ @Test ! public void xrNSTable02() { ! try { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); - SAXParser saxParser = spf.newSAXParser(); ! XMLReader xmlReader = saxParser.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. */ @Test ! public void xrNSTable03() { ! try { ! SAXParserFactory spf = SAXParserFactory.newInstance(); ! SAXParser saxParser = spf.newSAXParser(); ! XMLReader xmlReader = saxParser.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 */ @Test ! public void xrNSTable04() { ! try { ! SAXParserFactory spf = SAXParserFactory.newInstance(); ! SAXParser saxParser = spf.newSAXParser(); ! XMLReader xmlReader = saxParser.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. */ @Test ! public void spNSTable01() { ! try { 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. */ @Test ! public void spNSTable02() { ! try { 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. */ @Test ! public void spNSTable03() { ! try { 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. */ @Test ! public void spNSTable04() { ! try { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setFeature(NAMESPACE_PREFIXES, false); - assertFalse(spf.getFeature(NAMESPACE_PREFIXES)); - } catch (ParserConfigurationException | SAXNotRecognizedException - | SAXNotSupportedException ex) { - failUnexpected(ex); - } } } --- 23,179 ---- package org.xml.sax.ptests; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; ! 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.XMLReader; /** * Class containing the test cases for Namespace Table defined at * http://www.megginson.com/SAX/Java/namespaces.html */ ! public class NSTableTest01 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 SAXException If any parse errors occur. + * @throws ParserConfigurationException if a DocumentBuilder cannot be + * created which satisfies the configuration requested. */ @Test ! public void xrNSTable01() throws ParserConfigurationException, SAXException { 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)); } /** * Here namespace processing is enabled. This will make namespace-prefixes * disabled. The testcase tests XMLReader for this. + * + * @throws SAXException If any parse errors occur. + * @throws ParserConfigurationException if a DocumentBuilder cannot be + * created which satisfies the configuration requested. */ @Test ! public void xrNSTable02() throws ParserConfigurationException, SAXException { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); ! XMLReader xmlReader = spf.newSAXParser().getXMLReader(); assertTrue(xmlReader.getFeature(NAMESPACES)); assertFalse(xmlReader.getFeature(NAMESPACE_PREFIXES)); } /** * Here namespace processing is disabled. This will make namespace-prefixes * enabled. The testcase tests XMLReader for this. + * + * @throws SAXException If any parse errors occur. + * @throws ParserConfigurationException if a DocumentBuilder cannot be + * created which satisfies the configuration requested. */ @Test ! public void xrNSTable03() throws ParserConfigurationException, SAXException { ! XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); assertFalse(xmlReader.getFeature(NAMESPACES)); assertTrue(xmlReader.getFeature(NAMESPACE_PREFIXES)); } /** * 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. ! * ! * @throws SAXException If any parse errors occur. ! * @throws ParserConfigurationException if a DocumentBuilder cannot be ! * created which satisfies the configuration requested. */ @Test ! public void xrNSTable04() throws SAXException, ParserConfigurationException { ! XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); xmlReader.setFeature(NAMESPACE_PREFIXES, false); assertFalse(xmlReader.getFeature(NAMESPACE_PREFIXES)); } /** * Here namespace processing and namespace-prefixes are enabled. * The testcase tests SAXParserFactory for this. + * + * @throws SAXException If any parse errors occur. + * @throws ParserConfigurationException if a DocumentBuilder cannot be + * created which satisfies the configuration requested. */ @Test ! public void spNSTable01() throws ParserConfigurationException, SAXException { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); spf.setFeature(NAMESPACE_PREFIXES,true); assertTrue(spf.getFeature(NAMESPACES)); assertTrue(spf.getFeature(NAMESPACE_PREFIXES)); } /** * Here namespace processing is enabled. This will make namespace-prefixes * disabled. The testcase tests SAXParserFactory for this. + * + * @throws SAXException If any parse errors occur. + * @throws ParserConfigurationException if a DocumentBuilder cannot be + * created which satisfies the configuration requested. */ @Test ! public void spNSTable02() throws ParserConfigurationException, SAXException { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); assertTrue(spf.getFeature(NAMESPACES)); assertFalse(spf.getFeature(NAMESPACE_PREFIXES)); } /** * Here namespace processing is disabled. This will make namespace-prefixes * enabled. The testcase tests SAXParserFactory for this. + * + * @throws SAXException If any parse errors occur. + * @throws ParserConfigurationException if a DocumentBuilder cannot be + * created which satisfies the configuration requested. */ @Test ! public void spNSTable03() throws ParserConfigurationException, SAXException { SAXParserFactory spf = SAXParserFactory.newInstance(); assertFalse(spf.getFeature(NAMESPACES)); assertTrue(spf.getFeature(NAMESPACE_PREFIXES)); } /** * 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 SAXException If any parse errors occur. + * @throws ParserConfigurationException if a DocumentBuilder cannot be + * created which satisfies the configuration requested. */ @Test ! public void spNSTable04() throws ParserConfigurationException, SAXException { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setFeature(NAMESPACE_PREFIXES, false); assertFalse(spf.getFeature(NAMESPACE_PREFIXES)); } }
< prev index next >