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.File;
27
28 import javax.xml.transform.Source;
29 import javax.xml.transform.Transformer;
30 import javax.xml.transform.TransformerFactory;
31 import javax.xml.transform.dom.DOMResult;
32 import javax.xml.transform.sax.SAXResult;
33 import javax.xml.transform.stax.StAXResult;
34 import javax.xml.transform.stream.StreamResult;
35
36 import org.testng.Assert;
37 import org.testng.annotations.AfterMethod;
38 import org.testng.annotations.BeforeMethod;
39 import org.testng.annotations.Test;
40
41 import transform.util.DOMUtil;
42 import transform.util.SAXUtil;
43 import transform.util.StAXUtil;
44 import transform.util.StreamUtil;
45
46 /*
47 * @bug 4892774
48 * @summary Test identity transformer with all possible types of Source and Result combinations for doucment version and encoding information.
49 */
50
51 public class Bug4892774 {
52
53 private final String XML_FILE = "catalog.xml";
54 private final String XML10_FILE = "catalog_10.xml"; // 1.0 version document
55 private final String TEMP_FILE = "tmp.xml";
56 private final String EXPECTED_VERSION = "1.1";
57 static private Transformer idTransform = null;
58
59 private static DOMUtil domUtil = null;
60 private static StreamUtil streamUtil = null;
61 private static SAXUtil saxUtil = null;
62 private static StAXUtil staxUtil = null;
63
64 @BeforeMethod
65 protected void setUp() {
66 File tmpFile = new File(TEMP_FILE);
67 if (tmpFile.exists())
68 tmpFile.delete();
69 try {
70
|
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.File;
27
28 import javax.xml.transform.Source;
29 import javax.xml.transform.Transformer;
30 import javax.xml.transform.TransformerFactory;
31 import javax.xml.transform.dom.DOMResult;
32 import javax.xml.transform.sax.SAXResult;
33 import javax.xml.transform.stax.StAXResult;
34 import javax.xml.transform.stream.StreamResult;
35
36 import org.testng.Assert;
37 import org.testng.annotations.AfterMethod;
38 import org.testng.annotations.BeforeMethod;
39 import org.testng.annotations.Listeners;
40 import org.testng.annotations.Test;
41
42 import transform.util.DOMUtil;
43 import transform.util.SAXUtil;
44 import transform.util.StAXUtil;
45 import transform.util.StreamUtil;
46
47 /*
48 * @bug 4892774
49 * @summary Test identity transformer with all possible types of Source and Result combinations for doucment version and encoding information.
50 */
51
52 @Listeners({jaxp.library.FilePolicy.class})
53 public class Bug4892774 {
54
55 private final String XML_FILE = "catalog.xml";
56 private final String XML10_FILE = "catalog_10.xml"; // 1.0 version document
57 private final String TEMP_FILE = "tmp.xml";
58 private final String EXPECTED_VERSION = "1.1";
59 static private Transformer idTransform = null;
60
61 private static DOMUtil domUtil = null;
62 private static StreamUtil streamUtil = null;
63 private static SAXUtil saxUtil = null;
64 private static StAXUtil staxUtil = null;
65
66 @BeforeMethod
67 protected void setUp() {
68 File tmpFile = new File(TEMP_FILE);
69 if (tmpFile.exists())
70 tmpFile.delete();
71 try {
72
|