jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java
changeset 28696 dd8c7efde993
child 40223 64662417aa2d
equal deleted inserted replaced
28695:427254b89b9e 28696:dd8c7efde993
       
     1 /*
       
     2  * Copyright (c) 2003, 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 test.gaptest;
       
    25 
       
    26 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
       
    27 import static jaxp.library.JAXPTestUtilities.USER_DIR;
       
    28 import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold;
       
    29 import static org.testng.Assert.assertTrue;
       
    30 import static test.gaptest.GapTestConst.GOLDEN_DIR;
       
    31 import static test.gaptest.GapTestConst.XML_DIR;
       
    32 
       
    33 import java.io.File;
       
    34 import java.io.IOException;
       
    35 import java.nio.file.Files;
       
    36 import java.nio.file.Paths;
       
    37 
       
    38 import javax.xml.parsers.ParserConfigurationException;
       
    39 import javax.xml.transform.Transformer;
       
    40 import javax.xml.transform.TransformerException;
       
    41 import javax.xml.transform.TransformerFactory;
       
    42 import javax.xml.transform.stream.StreamResult;
       
    43 import javax.xml.transform.stream.StreamSource;
       
    44 
       
    45 import jaxp.library.JAXPFileBaseTest;
       
    46 
       
    47 import org.testng.annotations.Test;
       
    48 import org.xml.sax.SAXException;
       
    49 
       
    50 /*
       
    51  * @bug 4693341
       
    52  * @summary test transforming to stream with external dtd
       
    53  */
       
    54 
       
    55 public class Bug4693341 extends JAXPFileBaseTest {
       
    56 
       
    57     @Test
       
    58     public void test() throws TransformerException, ParserConfigurationException, SAXException, IOException {
       
    59 
       
    60         Transformer transformer = TransformerFactory.newInstance().newTransformer();
       
    61 
       
    62         String out = USER_DIR + File.separator + "Bug4693341.out";
       
    63         StreamResult result = new StreamResult(new File(out));
       
    64 
       
    65         String in = XML_DIR + "Bug4693341.xml";
       
    66         String golden = GOLDEN_DIR + "Bug4693341.xml";
       
    67         File file = new File(in);
       
    68         StreamSource source = new StreamSource(file);
       
    69         System.out.println(source.getSystemId());
       
    70 
       
    71         Files.copy(Paths.get(XML_DIR + "Bug4693341.dtd"),
       
    72                 Paths.get(USER_DIR + File.separator + "Bug4693341.dtd"), REPLACE_EXISTING);
       
    73 
       
    74         transformer.transform(source, result);
       
    75 
       
    76         assertTrue(compareDocumentWithGold(golden, out));
       
    77     }
       
    78 
       
    79 }