From 25d5529e66f5b2b89606a1160f20c306420edf88 Mon Sep 17 00:00:00 2001 From: stooke Date: Wed, 5 Jun 2019 04:14:02 +0100 Subject: [PATCH] 8193830: Xalan Update: Xalan Java 2.7.2 Reviewed-by: lancea, clanger, andrew --- THIRD_PARTY_README | 2 +- .../xml/jaxp/transform/sort/SortTest.java | 126 ++++++++++++++++++ .../transform/sort/sort-alphabet-english.out | 30 +++++ .../transform/sort/sort-alphabet-english.xml | 46 +++++++ .../transform/sort/sort-alphabet-english.xsl | 40 ++++++ .../transform/sort/sort-alphabet-polish.out | 37 +++++ .../transform/sort/sort-alphabet-polish.xml | 52 ++++++++ .../transform/sort/sort-alphabet-polish.xsl | 39 ++++++ .../transform/sort/sort-alphabet-russian.out | 38 ++++++ .../transform/sort/sort-alphabet-russian.xml | 53 ++++++++ .../transform/sort/sort-alphabet-russian.xsl | 39 ++++++ 11 files changed, 501 insertions(+), 1 deletion(-) create mode 100644 test/javax/xml/jaxp/transform/sort/SortTest.java create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-english.out create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xml create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-english.xsl create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.out create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xml create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.xsl create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.out create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xml create mode 100644 test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xsl diff --git a/THIRD_PARTY_README b/THIRD_PARTY_README index a091d904b..814e5f234 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 000000000..e8622e8fc --- /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 000000000..a34c49ab4 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-english.out @@ -0,0 +1,30 @@ + +

lang: en

+
    +
  • A
  • +
  • C
  • +
  • D
  • +
  • E
  • +
  • F
  • +
  • G
  • +
  • H
  • +
  • I
  • +
  • J
  • +
  • K
  • +
  • L
  • +
  • M
  • +
  • N
  • +
  • O
  • +
  • P
  • +
  • Q
  • +
  • R
  • +
  • S
  • +
  • T
  • +
  • U
  • +
  • V
  • +
  • W
  • +
  • X
  • +
  • Y
  • +
  • Z
  • +
+
\ 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 000000000..7093d67c5 --- /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 000000000..ef57a3d54 --- /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 000000000..5219d79d9 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-polish.out @@ -0,0 +1,37 @@ + +

    lang: pl

    +
      +
    • A
    • +
    • Ą
    • +
    • B
    • +
    • C
    • +
    • Ć
    • +
    • D
    • +
    • E
    • +
    • Ę
    • +
    • F
    • +
    • G
    • +
    • H
    • +
    • I
    • +
    • J
    • +
    • K
    • +
    • L
    • +
    • Ł
    • +
    • M
    • +
    • N
    • +
    • Ń
    • +
    • O
    • +
    • Ó
    • +
    • P
    • +
    • R
    • +
    • S
    • +
    • Ś
    • +
    • T
    • +
    • U
    • +
    • W
    • +
    • Y
    • +
    • Z
    • +
    • Ź
    • +
    • Ż
    • +
    +
    \ 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 000000000..cf08ac1bf --- /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 000000000..e91e53c61 --- /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 000000000..724d22d6e --- /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 000000000..6811b16c9 --- /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 000000000..e91e53c61 --- /dev/null +++ b/test/javax/xml/jaxp/transform/sort/sort-alphabet-russian.xsl @@ -0,0 +1,39 @@ + + + + + + + + +

    lang:

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