Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/security/misc/Versions.java
41149 views
1
/*
2
* Copyright (c) 2019, 2020, 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 8221801 8244674
27
* @summary Make sure version info is consistent between code and license
28
* @run testng Versions
29
*/
30
31
import org.testng.Assert;
32
import org.testng.annotations.DataProvider;
33
import org.testng.annotations.Test;
34
35
import java.io.IOException;
36
import java.nio.file.Files;
37
import java.nio.file.Path;
38
import java.util.regex.Matcher;
39
import java.util.regex.Pattern;
40
41
public class Versions {
42
43
Path rootPath = Path.of(System.getProperty("test.root"), "../..");
44
Path legalPath = Path.of(System.getProperty("test.jdk"), "legal");
45
46
@DataProvider(name = "data")
47
public Object[][] createData() {
48
return new Object[][]{
49
{"src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java",
50
Pattern.compile("// Apache Santuario XML Security for Java, version (?<n>\\S+)"),
51
"src/java.xml.crypto/share/legal/santuario.md",
52
Pattern.compile("## Apache Santuario v(?<n>\\S+)"),
53
"java.xml.crypto/santuario.md"},
54
{"make/data/publicsuffixlist/VERSION",
55
Pattern.compile("list/(?<n>[0-9a-f]+)/public_suffix_list.dat"),
56
"src/java.base/share/legal/public_suffix.md",
57
Pattern.compile("list/(?<n>[0-9a-f]+)/public_suffix_list.dat"),
58
"java.base/public_suffix.md"},
59
{"src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h",
60
Pattern.compile("#define PCSCLITE_VERSION_NUMBER +\"(?<n>[0-9\\.]+)\""),
61
"src/java.smartcardio/unix/legal/pcsclite.md",
62
Pattern.compile("## PC/SC Lite v(?<n>[0-9\\.]+)"),
63
"java.smartcardio/pcsclite.md"}
64
};
65
}
66
67
@Test(dataProvider = "data")
68
public void Test(String src, Pattern sp, String legal, Pattern lp,
69
String legalInBuild) throws IOException {
70
71
Path pSrc = rootPath.resolve(src);
72
Path pLegal = rootPath.resolve(legal);
73
74
Assert.assertEquals(fetch(pSrc, sp), fetch(pLegal, lp));
75
76
Path pLegalInBuild = legalPath.resolve(legalInBuild);
77
if (!Files.exists(pLegalInBuild)) {
78
System.out.println("Not an image build, or file platform dependent");
79
} else {
80
Assert.assertEquals(Files.mismatch(pLegal, pLegalInBuild), -1);
81
}
82
}
83
84
// Find a match in path and return the extracted named group
85
static String fetch(Path path, Pattern pattern)
86
throws IOException {
87
return Files.lines(path)
88
.map(pattern::matcher)
89
.filter(Matcher::find)
90
.findFirst()
91
.map(m -> m.group("n"))
92
.get();
93
}
94
}
95
96