8221801: Update src/java.base/share/legal/public_suffix.md

Reviewed-by: xuelei
This commit is contained in:
Weijun Wang 2019-04-02 11:05:08 +08:00
parent e0f37c15e4
commit ae32136711
2 changed files with 82 additions and 1 deletions

View File

@ -11,7 +11,7 @@ If you do not wish to use the Public Suffix List, you may remove the
The Source Code of this file is available under the
Mozilla Public License, v. 2.0 and is located at
https://raw.githubusercontent.com/publicsuffix/list/2225db8d9f4a2a27ec697c883360632fa0c16261/public_suffix_list.dat.
https://raw.githubusercontent.com/publicsuffix/list/ce0d1a5fba657e55adea3abde4b7f1e50636ff10/public_suffix_list.dat.
If a copy of the MPL was not distributed with this file, you can obtain one
at https://mozilla.org/MPL/2.0/.

View File

@ -0,0 +1,81 @@
/*
* Copyright (c) 2019, 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.
*/
/*
* @test
* @bug 8221801
* @library /test/lib
* @summary Update src/java.base/share/legal/public_suffix.md
*/
import jdk.test.lib.Asserts;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Versions {
public static void main(String[] args) throws Exception {
Path root = Path.of(System.getProperty("test.root"));
Path jdk = Path.of(System.getProperty("test.jdk"));
Path version = root.resolve("../../make/data/publicsuffixlist/VERSION");
Path mdSrc = root.resolve("../../src/java.base/share/legal/public_suffix.md");
Path mdImage = jdk.resolve("legal/java.base/public_suffix.md");
// Files in src should either both exist or not
if (!Files.exists(version) && !Files.exists(mdSrc)) {
System.out.println("Source not available. Cannot proceed.");
return;
}
String s1 = findURL(version);
String s2 = findURL(mdSrc);
Asserts.assertEQ(s1, s2);
String s3 = findURL(mdImage);
Asserts.assertEQ(s2, s3);
}
static Pattern URL_PATTERN = Pattern.compile(
"(https://raw.githubusercontent.com.*?public_suffix_list.dat)");
static String findURL(Path p) throws IOException {
return Files.lines(p)
.map(Versions::matchURL)
.filter(Objects::nonNull)
.findFirst()
.orElseThrow();
}
static String matchURL(String input) {
Matcher m = URL_PATTERN.matcher(input);
return m.find() ? m.group(1) : null;
}
}