diff --git a/THIRD_PARTY_README b/THIRD_PARTY_README index a091d904b88b3b724deb9dfad3ac02068e29751f..814e5f234580c3f1b7267dc11e189ea10ca95d5f 100644 --- a/THIRD_PARTY_README +++ b/THIRD_PARTY_README @@ -2898,7 +2898,7 @@ included with JRE 8, JDK 8, and OpenJDK 8. Apache Jakarta BCEL 5.1 Apache Jakarta Regexp 1.4 Apache Santuario XML Security for Java 1.5.4 - Apache Xalan-Java 2.7.1 + Apache Xalan-Java 2.7.2 Apache Xerces Java 2.10.0 Apache XML Resolver 1.1 diff --git a/test/javax/xml/jaxp/transform/sort/SortTest.java b/test/javax/xml/jaxp/transform/sort/SortTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e8622e8fced6838605549dd4b042834222898569 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/SortTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.StringWriter; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +/* + * @test + * @bug 8193830 + * @run testng/othervm -DrunSecMngr=true SortTest + * @run testng/othervm SortTest + * @summary verify xsl:sort lang attribute + */ +public class SortTest { + + static final String LAND_EN = "en"; + static final String LAND_PL = "pl"; + static final String LAND_RU = "ru"; + + String filepath; + String slash = ""; + + @BeforeClass + public void setUpClass() throws Exception { + String file1 = getClass().getResource("/sort-alphabet-english.xml").getFile(); + if (System.getProperty("os.name").contains("Windows")) { + filepath = file1.substring(1, file1.lastIndexOf("/") + 1); + slash = "/"; + } else { + filepath = file1.substring(0, file1.lastIndexOf("/") + 1); + } + } + + /* + * DataProvider fields: + * lang, xml, xsl, gold file + */ + @DataProvider(name = "parameters") + public Object[][] getParameters() { + + return new Object[][]{ + {LAND_EN, "sort-alphabet-english.xml", "sort-alphabet-english.xsl", "sort-alphabet-english.out"}, + {LAND_PL, "sort-alphabet-polish.xml", "sort-alphabet-polish.xsl", "sort-alphabet-polish.out"}, + {LAND_RU, "sort-alphabet-russian.xml", "sort-alphabet-russian.xsl", "sort-alphabet-russian.out"},}; + } + + @Test(dataProvider = "parameters") + public final void testTransform(String lang, String xml, String xsl, String gold) + throws Exception { + + StringWriter sw = new StringWriter(); + // Create transformer factory + TransformerFactory factory = TransformerFactory.newInstance(); + + // Use the factory to create a template containing the xsl file + Templates template = factory.newTemplates(new StreamSource(getClass().getResourceAsStream(xsl))); + // Use the template to create a transformer + Transformer xformer = template.newTransformer(); + xformer.setParameter("lang", lang); + // Prepare the input and output files + Source source = new StreamSource(getClass().getResourceAsStream(xml)); + + /* + * The following may be used to produce gold files. + * Using however the original gold files, and compare without considering + * the format + */ + //String output = getClass().getResource(gold).getPath(); + //Result result = new StreamResult(new FileOutputStream(output)); + // use the following to verify the output against the pre-generated one + Result result = new StreamResult(sw); + + // Apply the xsl file to the source file and write the result to the + // output file + xformer.transform(source, result); + + String out = sw.toString(); + + List lines = Files.readAllLines(Paths.get(filepath + gold)); + String[] resultLines = out.split("\n"); + int i = 0; + + // the purpose is to test sort, so ignore the format of the output + + for (String line : lines) { + Assert.assertEquals(resultLines[i++].trim(), line.trim()); + } + } +} diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.out b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.out new file mode 100644 index 0000000000000000000000000000000000000000..a34c49ab47eac46cade517f76452d062dad1d16f --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.out @@ -0,0 +1,30 @@ + +

lang: en

+ +
\ No newline at end of file diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xml b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xml new file mode 100644 index 0000000000000000000000000000000000000000..7093d67c5325858877ccb222505c4a425efc8709 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xml @@ -0,0 +1,46 @@ + + + + A + E + C + D + F + G + H + I + J + K + L + M + N + Y + O + P + Q + U + R + S + V + W + T + X + Z + + diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xsl b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xsl new file mode 100644 index 0000000000000000000000000000000000000000..ef57a3d543d0a2ccd4376cbe5563cf1d3c0efeee --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xsl @@ -0,0 +1,40 @@ + + + + + + + + +

lang:

+
    + + + +
+
+
+ +
  • + +
  • +
    +
    + diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.out b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.out new file mode 100644 index 0000000000000000000000000000000000000000..5219d79d9d6c2fda79c5e4df6e39edafd62868d4 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.out @@ -0,0 +1,37 @@ + +

    lang: pl

    + +
    \ No newline at end of file diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xml b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xml new file mode 100644 index 0000000000000000000000000000000000000000..cf08ac1bfc3fc3cb55f55afe4d0b46752d46d50e --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xml @@ -0,0 +1,52 @@ + + + + A + Ż + B + C + Ć + D + Ł + E + Ę + F + G + H + I + J + K + L + Z + Ź + M + N + Ń + O + Ó + P + R + S + Ś + T + U + W + Ą + Y + \ No newline at end of file diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xsl b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xsl new file mode 100644 index 0000000000000000000000000000000000000000..e91e53c6195eef2482500d69463e3e02a4a0dfb2 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xsl @@ -0,0 +1,39 @@ + + + + + + + + +

    lang:

    +
      + + + +
    +
    +
    + +
  • + +
  • +
    +
    \ No newline at end of file diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.out b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.out new file mode 100644 index 0000000000000000000000000000000000000000..724d22d6e839c8fab5a5a6675458d3d9cbbd742a --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.out @@ -0,0 +1,38 @@ + +

    lang: ru

    + +
    \ No newline at end of file diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xml b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xml new file mode 100644 index 0000000000000000000000000000000000000000..6811b16c934aa8decc0ffa4e0ce2f7575018bcf8 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xml @@ -0,0 +1,53 @@ + + + + А + Б + В + Г + Д + Е + Ё + Ж + З + Й + П + Я + К + Л + С + М + Н + О + Р + И + Т + Ф + Х + Ц + У + Ш + Щ + Ъ + Ы + Ч + Ь + Э + Ю + diff --git a/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xsl b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xsl new file mode 100644 index 0000000000000000000000000000000000000000..e91e53c6195eef2482500d69463e3e02a4a0dfb2 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xsl @@ -0,0 +1,39 @@ + + + + + + + + +

    lang:

    +
      + + + +
    +
    +
    + +
  • + +
  • +
    +
    \ No newline at end of file