test/jdk/javax/xml/crypto/dsig/Versions.java
author weijun
Thu, 17 Oct 2019 07:31:35 +0800
changeset 58656 7322c48a84cf
permissions -rw-r--r--
8232357: Compare version info of Santuario to legal notice Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58656
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     1
/*
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     4
 *
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     8
 *
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    13
 * accompanied this code).
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    14
 *
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    18
 *
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    21
 * questions.
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    22
 */
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    23
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    24
/*
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    25
 * @test
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    26
 * @bug 8232357
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    27
 * @library /test/lib
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    28
 * @summary Compare version info of Santuario to legal notice
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    29
 */
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    30
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    31
import jdk.test.lib.Asserts;
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    32
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    33
import java.nio.file.Files;
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    34
import java.nio.file.Path;
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    35
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    36
public class Versions {
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    37
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    38
    public static void main(String[] args) throws Exception {
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    39
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    40
        Path src = Path.of(System.getProperty("test.root"),
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    41
                "../../src/java.xml.crypto");
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    42
        Path legal = Path.of(System.getProperty("test.jdk"), "legal");
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    43
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    44
        Path provider = src.resolve(
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    45
                "share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java");
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    46
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    47
        Path mdInSrc = src.resolve(
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    48
                "share/legal/santuario.md");
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    49
        Path mdInImage = legal.resolve(
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    50
                "java.xml.crypto/santuario.md");
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    51
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    52
        // Files in src should either both exist or not
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    53
        if (!Files.exists(provider) && !Files.exists(mdInSrc)) {
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    54
            System.out.println("Source not available. Cannot proceed.");
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    55
            return;
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    56
        }
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    57
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    58
        // The line containing the version number looks like
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    59
        // // Apache Santuario XML Security for Java, version n.n.n
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    60
        String s1 = Files.lines(provider)
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    61
                .filter(s -> s.contains(
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    62
                        "// Apache Santuario XML Security for Java, version "))
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    63
                .findFirst()
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    64
                .get()
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    65
                .replaceFirst(".* ", ""); // keep chars after the last space
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    66
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    67
        // The first line of this file should look like
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    68
        // ## Apache Santuario v2.1.3
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    69
        String s2 = Files.lines(mdInSrc)
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    70
                .findFirst()
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    71
                .get()
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    72
                .replace("## Apache Santuario v", "");
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    73
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    74
        Asserts.assertEQ(s1, s2);
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    75
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    76
        if (Files.exists(legal)) {
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    77
            Asserts.assertTrue(Files.mismatch(mdInSrc, mdInImage) == -1);
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    78
        } else {
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    79
            System.out.println("Warning: skip image compare. Exploded build?");
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    80
        }
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    81
    }
7322c48a84cf 8232357: Compare version info of Santuario to legal notice
weijun
parents:
diff changeset
    82
}