jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java
changeset 28696 dd8c7efde993
child 40223 64662417aa2d
equal deleted inserted replaced
28695:427254b89b9e 28696:dd8c7efde993
       
     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 test.gaptest;
       
    24 
       
    25 import static jaxp.library.JAXPTestUtilities.filenameToURL;
       
    26 import static test.gaptest.GapTestConst.XML_DIR;
       
    27 
       
    28 import java.io.IOException;
       
    29 
       
    30 import javax.xml.XMLConstants;
       
    31 import javax.xml.parsers.ParserConfigurationException;
       
    32 import javax.xml.parsers.SAXParser;
       
    33 import javax.xml.parsers.SAXParserFactory;
       
    34 
       
    35 import jaxp.library.JAXPFileBaseTest;
       
    36 
       
    37 import org.testng.annotations.Test;
       
    38 import org.xml.sax.ErrorHandler;
       
    39 import org.xml.sax.InputSource;
       
    40 import org.xml.sax.SAXException;
       
    41 import org.xml.sax.SAXParseException;
       
    42 import org.xml.sax.XMLReader;
       
    43 
       
    44 /*
       
    45  * @bug 4848653
       
    46  * @summary Verify JAXP schemaLanguage property is ignored if setValidating(false)
       
    47  */
       
    48 
       
    49 public class Bug4848653 extends JAXPFileBaseTest {
       
    50 
       
    51     @Test
       
    52     public void test() throws IOException, SAXException, ParserConfigurationException {
       
    53         SAXParserFactory factory = SAXParserFactory.newInstance();
       
    54         factory.setValidating(false);
       
    55         SAXParser parser = factory.newSAXParser();
       
    56         parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", XMLConstants.W3C_XML_SCHEMA_NS_URI);
       
    57 
       
    58         String filename = XML_DIR + "Bug4848653.xml";
       
    59         InputSource is = new InputSource(filenameToURL(filename));
       
    60         XMLReader xmlReader = parser.getXMLReader();
       
    61         xmlReader.setErrorHandler(new MyErrorHandler());
       
    62         xmlReader.parse(is);
       
    63     }
       
    64 
       
    65     class MyErrorHandler implements ErrorHandler {
       
    66         public void error(SAXParseException exception) throws SAXParseException {
       
    67             throw exception;
       
    68         }
       
    69 
       
    70         public void warning(SAXParseException exception) throws SAXParseException {
       
    71             throw exception;
       
    72         }
       
    73 
       
    74         public void fatalError(SAXParseException exception) throws SAXParseException {
       
    75             throw exception;
       
    76         }
       
    77 
       
    78     }
       
    79 
       
    80 }