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 dom;
25
26 import java.io.ByteArrayInputStream;
27 import java.io.IOException;
28 import java.io.InputStreamReader;
29
30 import javax.xml.parsers.DocumentBuilder;
31 import javax.xml.parsers.DocumentBuilderFactory;
32 import javax.xml.parsers.ParserConfigurationException;
33
34 import org.testng.Assert;
35 import org.testng.annotations.Test;
36 import org.w3c.dom.DOMException;
37 import org.w3c.dom.Document;
38 import org.w3c.dom.Entity;
39 import org.xml.sax.InputSource;
40 import org.xml.sax.SAXException;
41
42 /*
43 * @bug 6517707
44 * @summary Test Node.setNodeValue(value) shall throw DOMException.NO_MODIFICATION_ALLOWED_ERR if the node is read-only.
45 */
46 public class CR6517707Test {
47
48 @Test
49 public void testCanonicalForm001() {
50 String data = "<?xml version=\"1.0\" ?>" + "<!DOCTYPE root [" + "<!ELEMENT root ANY>" + "<!ENTITY ent \"foo\">"
51 + "<!NOTATION not PUBLIC \"http://xxx.xxx.xx/x.txt\">" + "]>" + "<root>" + "</root>";
52
53 Document document = null;
54 try {
55 DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
56 docBF.setNamespaceAware(true);
57 DocBuilderWrapper docBuilder = new DocBuilderWrapper(docBF.newDocumentBuilder());
58 document = docBuilder.parse(data);
59 } catch (ParserConfigurationException e) {
60 // return Status.failed(e.toString());
61 } catch (IOException e) {
62 // return Status.failed(e.toString());
63 } catch (SAXException e) {
64 // return Status.failed(e.toString());
65 }
|
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 dom;
25
26 import java.io.ByteArrayInputStream;
27 import java.io.IOException;
28 import java.io.InputStreamReader;
29
30 import javax.xml.parsers.DocumentBuilder;
31 import javax.xml.parsers.DocumentBuilderFactory;
32 import javax.xml.parsers.ParserConfigurationException;
33
34 import org.testng.Assert;
35 import org.testng.annotations.Listeners;
36 import org.testng.annotations.Test;
37 import org.w3c.dom.DOMException;
38 import org.w3c.dom.Document;
39 import org.w3c.dom.Entity;
40 import org.xml.sax.InputSource;
41 import org.xml.sax.SAXException;
42
43 /*
44 * @bug 6517707
45 * @summary Test Node.setNodeValue(value) shall throw DOMException.NO_MODIFICATION_ALLOWED_ERR if the node is read-only.
46 */
47 @Listeners({jaxp.library.BasePolicy.class})
48 public class CR6517707Test {
49
50 @Test
51 public void testCanonicalForm001() {
52 String data = "<?xml version=\"1.0\" ?>" + "<!DOCTYPE root [" + "<!ELEMENT root ANY>" + "<!ENTITY ent \"foo\">"
53 + "<!NOTATION not PUBLIC \"http://xxx.xxx.xx/x.txt\">" + "]>" + "<root>" + "</root>";
54
55 Document document = null;
56 try {
57 DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
58 docBF.setNamespaceAware(true);
59 DocBuilderWrapper docBuilder = new DocBuilderWrapper(docBF.newDocumentBuilder());
60 document = docBuilder.parse(data);
61 } catch (ParserConfigurationException e) {
62 // return Status.failed(e.toString());
63 } catch (IOException e) {
64 // return Status.failed(e.toString());
65 } catch (SAXException e) {
66 // return Status.failed(e.toString());
67 }
|