1 /*
2 * Copyright (c) 2014, 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
24 package parsers;
25
26 import java.io.File;
27 import java.io.IOException;
28 import java.io.InputStream;
29
30 import javax.xml.XMLConstants;
31 import javax.xml.parsers.DocumentBuilder;
32 import javax.xml.parsers.DocumentBuilderFactory;
33 import javax.xml.parsers.ParserConfigurationException;
34 import javax.xml.parsers.SAXParser;
35 import javax.xml.parsers.SAXParserFactory;
36 import javax.xml.transform.stream.StreamSource;
37 import javax.xml.validation.Schema;
38 import javax.xml.validation.SchemaFactory;
39
40 import org.testng.Assert;
41 import org.testng.annotations.Test;
42 import org.w3c.dom.Document;
43 import org.w3c.dom.Node;
44 import org.w3c.dom.Text;
45 import org.xml.sax.SAXException;
46 import org.xml.sax.helpers.DefaultHandler;
47
48 /*
49 * @bug 6564400
50 * @summary Test ignorable whitespace handling with schema validation.
51 */
52 public class Bug6564400 {
53 private boolean sawIgnorable = false;
54 Schema schema = null;
55
56 public Bug6564400(String name) {
57 String xsdFile = "Bug6564400.xsd";
58 File schemaFile = new File(xsdFile);
59
60 // Now attempt to load up the schema
61 try {
62 SchemaFactory schFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
63 schema = schFactory.newSchema(new StreamSource(getClass().getResourceAsStream(xsdFile)));
64 } catch (Exception e) {
65 // Nevermind, bad things will happen later
66 }
67 }
68
69 @Test
70 public void testDOM() throws ParserConfigurationException, SAXException, IOException {
71 InputStream xmlFile = getClass().getResourceAsStream("Bug6564400.xml");
|
1 /*
2 * Copyright (c) 2014, 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
24 package parsers;
25
26 import java.io.File;
27 import java.io.IOException;
28 import java.io.InputStream;
29
30 import javax.xml.XMLConstants;
31 import javax.xml.parsers.DocumentBuilder;
32 import javax.xml.parsers.DocumentBuilderFactory;
33 import javax.xml.parsers.ParserConfigurationException;
34 import javax.xml.parsers.SAXParser;
35 import javax.xml.parsers.SAXParserFactory;
36 import javax.xml.transform.stream.StreamSource;
37 import javax.xml.validation.Schema;
38 import javax.xml.validation.SchemaFactory;
39
40 import org.testng.Assert;
41 import org.testng.annotations.Listeners;
42 import org.testng.annotations.Test;
43 import org.w3c.dom.Document;
44 import org.w3c.dom.Node;
45 import org.w3c.dom.Text;
46 import org.xml.sax.SAXException;
47 import org.xml.sax.helpers.DefaultHandler;
48
49 /*
50 * @bug 6564400
51 * @summary Test ignorable whitespace handling with schema validation.
52 */
53 @Listeners({jaxp.library.FilePolicy.class})
54 public class Bug6564400 {
55 private boolean sawIgnorable = false;
56 Schema schema = null;
57
58 public Bug6564400(String name) {
59 String xsdFile = "Bug6564400.xsd";
60 File schemaFile = new File(xsdFile);
61
62 // Now attempt to load up the schema
63 try {
64 SchemaFactory schFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
65 schema = schFactory.newSchema(new StreamSource(getClass().getResourceAsStream(xsdFile)));
66 } catch (Exception e) {
67 // Nevermind, bad things will happen later
68 }
69 }
70
71 @Test
72 public void testDOM() throws ParserConfigurationException, SAXException, IOException {
73 InputStream xmlFile = getClass().getResourceAsStream("Bug6564400.xml");
|