< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.xml.sax.ptests;
  24 
  25 import javax.xml.parsers.SAXParser;
  26 import javax.xml.parsers.SAXParserFactory;
  27 import jaxp.library.JAXPBaseTest;
  28 import static org.testng.Assert.assertFalse;
  29 import static org.testng.Assert.assertTrue;





  30 import org.testng.annotations.Test;
  31 import org.xml.sax.XMLReader;
  32 
  33 /**
  34  * Class containing the test cases for Namespace Table defined at
  35  * http://www.megginson.com/SAX/Java/namespaces.html
  36  */
  37 public class NSTableTest extends JAXPBaseTest {

  38     private static final String NAMESPACES =
  39                         "http://xml.org/sax/features/namespaces";
  40     private static final String NAMESPACE_PREFIXES =
  41                         "http://xml.org/sax/features/namespace-prefixes";
  42 
  43     /**
  44      * Here namespace processing and namespace-prefixes are enabled.
  45      * The testcase tests XMLReader for this.
  46      *
  47      * @throws Exception If any errors occur.
  48      */
  49     @Test
  50     public void xrNSTable01() throws Exception {
  51         SAXParserFactory spf = SAXParserFactory.newInstance();
  52         spf.setNamespaceAware(true);
  53         SAXParser saxParser = spf.newSAXParser();
  54 
  55         XMLReader xmlReader = saxParser.getXMLReader();
  56         xmlReader.setFeature(NAMESPACE_PREFIXES, true);
  57 


   1 /*
   2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.xml.sax.ptests;
  24 



  25 import static org.testng.Assert.assertFalse;
  26 import static org.testng.Assert.assertTrue;
  27 
  28 import javax.xml.parsers.SAXParser;
  29 import javax.xml.parsers.SAXParserFactory;
  30 
  31 import org.testng.annotations.Listeners;
  32 import org.testng.annotations.Test;
  33 import org.xml.sax.XMLReader;
  34 
  35 /**
  36  * Class containing the test cases for Namespace Table defined at
  37  * http://www.megginson.com/SAX/Java/namespaces.html
  38  */
  39 @Listeners({jaxp.library.BasePolicy.class})
  40 public class NSTableTest {
  41     private static final String NAMESPACES =
  42                         "http://xml.org/sax/features/namespaces";
  43     private static final String NAMESPACE_PREFIXES =
  44                         "http://xml.org/sax/features/namespace-prefixes";
  45 
  46     /**
  47      * Here namespace processing and namespace-prefixes are enabled.
  48      * The testcase tests XMLReader for this.
  49      *
  50      * @throws Exception If any errors occur.
  51      */
  52     @Test
  53     public void xrNSTable01() throws Exception {
  54         SAXParserFactory spf = SAXParserFactory.newInstance();
  55         spf.setNamespaceAware(true);
  56         SAXParser saxParser = spf.newSAXParser();
  57 
  58         XMLReader xmlReader = saxParser.getXMLReader();
  59         xmlReader.setFeature(NAMESPACE_PREFIXES, true);
  60 


< prev index next >