|
1 /* |
|
2 * Copyright (c) 2019, 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 /* |
|
25 * @test |
|
26 * @bug 8232357 |
|
27 * @library /test/lib |
|
28 * @summary Compare version info of Santuario to legal notice |
|
29 */ |
|
30 |
|
31 import jdk.test.lib.Asserts; |
|
32 |
|
33 import java.nio.file.Files; |
|
34 import java.nio.file.Path; |
|
35 |
|
36 public class Versions { |
|
37 |
|
38 public static void main(String[] args) throws Exception { |
|
39 |
|
40 Path src = Path.of(System.getProperty("test.root"), |
|
41 "../../src/java.xml.crypto"); |
|
42 Path legal = Path.of(System.getProperty("test.jdk"), "legal"); |
|
43 |
|
44 Path provider = src.resolve( |
|
45 "share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java"); |
|
46 |
|
47 Path mdInSrc = src.resolve( |
|
48 "share/legal/santuario.md"); |
|
49 Path mdInImage = legal.resolve( |
|
50 "java.xml.crypto/santuario.md"); |
|
51 |
|
52 // Files in src should either both exist or not |
|
53 if (!Files.exists(provider) && !Files.exists(mdInSrc)) { |
|
54 System.out.println("Source not available. Cannot proceed."); |
|
55 return; |
|
56 } |
|
57 |
|
58 // The line containing the version number looks like |
|
59 // // Apache Santuario XML Security for Java, version n.n.n |
|
60 String s1 = Files.lines(provider) |
|
61 .filter(s -> s.contains( |
|
62 "// Apache Santuario XML Security for Java, version ")) |
|
63 .findFirst() |
|
64 .get() |
|
65 .replaceFirst(".* ", ""); // keep chars after the last space |
|
66 |
|
67 // The first line of this file should look like |
|
68 // ## Apache Santuario v2.1.3 |
|
69 String s2 = Files.lines(mdInSrc) |
|
70 .findFirst() |
|
71 .get() |
|
72 .replace("## Apache Santuario v", ""); |
|
73 |
|
74 Asserts.assertEQ(s1, s2); |
|
75 |
|
76 if (Files.exists(legal)) { |
|
77 Asserts.assertTrue(Files.mismatch(mdInSrc, mdInImage) == -1); |
|
78 } else { |
|
79 System.out.println("Warning: skip image compare. Exploded build?"); |
|
80 } |
|
81 } |
|
82 } |