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 transform;
25
26 import java.io.IOException;
27 import java.io.StringReader;
28 import java.io.StringWriter;
29
30 import javax.xml.parsers.ParserConfigurationException;
31 import javax.xml.parsers.SAXParserFactory;
32 import javax.xml.transform.Transformer;
33 import javax.xml.transform.TransformerException;
34 import javax.xml.transform.TransformerFactory;
35 import javax.xml.transform.sax.SAXSource;
36 import javax.xml.transform.sax.SAXTransformerFactory;
37 import javax.xml.transform.stream.StreamResult;
38
39 import org.testng.Assert;
40 import org.testng.annotations.Test;
41 import org.xml.sax.InputSource;
42 import org.xml.sax.SAXException;
43 import org.xml.sax.helpers.XMLFilterImpl;
44
45 /*
46 * @bug 6490921
47 * @summary Test property org.xml.sax.driver is always applied in transformer API.
48 */
49 public class Bug6490921 {
50
51 public static class ReaderStub extends XMLFilterImpl {
52 static boolean used = false;
53
54 public ReaderStub() throws ParserConfigurationException, SAXException {
55 super();
56 super.setParent(SAXParserFactory.newInstance().newSAXParser().getXMLReader());
57 }
58
59 public void parse(InputSource input) throws SAXException, IOException {
60 used = true;
61 super.parse(input);
62 }
63
64 public void parse(String systemId) throws SAXException, IOException {
65 used = true;
66 super.parse(systemId);
67 }
68 }
|
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 transform;
25
26 import java.io.IOException;
27 import java.io.StringReader;
28 import java.io.StringWriter;
29
30 import javax.xml.parsers.ParserConfigurationException;
31 import javax.xml.parsers.SAXParserFactory;
32 import javax.xml.transform.Transformer;
33 import javax.xml.transform.TransformerException;
34 import javax.xml.transform.TransformerFactory;
35 import javax.xml.transform.sax.SAXSource;
36 import javax.xml.transform.sax.SAXTransformerFactory;
37 import javax.xml.transform.stream.StreamResult;
38
39 import jaxp.library.JAXPTestUtilities;
40
41 import org.testng.Assert;
42 import org.testng.annotations.Listeners;
43 import org.testng.annotations.Test;
44 import org.xml.sax.InputSource;
45 import org.xml.sax.SAXException;
46 import org.xml.sax.helpers.XMLFilterImpl;
47
48 /*
49 * @bug 6490921
50 * @summary Test property org.xml.sax.driver is always applied in transformer API.
51 */
52 @Listeners({jaxp.library.BasePolicy.class})
53 public class Bug6490921 {
54
55 public static class ReaderStub extends XMLFilterImpl {
56 static boolean used = false;
57
58 public ReaderStub() throws ParserConfigurationException, SAXException {
59 super();
60 super.setParent(SAXParserFactory.newInstance().newSAXParser().getXMLReader());
61 }
62
63 public void parse(InputSource input) throws SAXException, IOException {
64 used = true;
65 super.parse(input);
66 }
67
68 public void parse(String systemId) throws SAXException, IOException {
69 used = true;
70 super.parse(systemId);
71 }
72 }
|