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
24package transform;
25
26import java.io.File;
27import java.io.StringWriter;
28
29import javax.xml.transform.Transformer;
30import javax.xml.transform.TransformerFactory;
31import javax.xml.transform.stream.StreamResult;
32import javax.xml.transform.stream.StreamSource;
33
34import org.testng.Assert;
35import org.testng.annotations.Listeners;
36import org.testng.annotations.Test;
37
38/*
39 * @test
40 * @bug 6905829
41 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
42 * @run testng/othervm -DrunSecMngr=true transform.CR6905829Test
43 * @run testng/othervm transform.CR6905829Test
44 * @summary Test XSLT can parse certain xsl.
45 */
46@Listeners({jaxp.library.FilePolicy.class})
47public class CR6905829Test {
48
49    @Test
50    public final void testTransform() {
51        try {
52            String file = getClass().getResource("CR6905829.xsl").getFile();
53            Transformer t = TransformerFactory.newInstance().newTransformer(new StreamSource(new File(file)));
54
55            System.out.printf("transformer: %s%n", t.getClass().getName());
56
57            StringWriter streamResult = new StringWriter();
58            t.transform(new StreamSource(getClass().getResourceAsStream("CR6905829.xml")), new StreamResult(streamResult));
59
60            // expected success
61        } catch (Exception e) {
62            // unexpected failure
63            e.printStackTrace();
64            Assert.fail(e.toString());
65        }
66    }
67}
68