Skip to content

Commit

Permalink
Backport 2bb4b9398d65e3f37f34e45476c969ff0afb1540
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Lu authored and sendaoYan committed Jun 21, 2024
1 parent 20ee52e commit d4a1e7f
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 159 deletions.
36 changes: 20 additions & 16 deletions test/jdk/java/util/Calendar/SupplementalJapaneseEraTestRun.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, 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
Expand Down Expand Up @@ -34,10 +34,15 @@
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import static java.util.Calendar.*;
import java.util.stream.Stream;

import static java.util.Calendar.DAY_OF_YEAR;
import static java.util.Calendar.ERA;
import static java.util.Calendar.FEBRUARY;
import static java.util.Calendar.LONG;
import static java.util.Calendar.YEAR;

import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Utils;

import org.testng.annotations.DataProvider;
Expand Down Expand Up @@ -91,19 +96,18 @@ public void InvalidPropertyValuesTest(String prop)
}

private static void testRun(String property, List<String> javaParam)
throws Throwable{
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASS_PATH)
.addToolArg("-Djdk.calendar.japanese.supplemental.era=" + property)
.addToolArg("SupplementalJapaneseEraTest");
for (String para: javaParam) {
launcher.addToolArg(para);
}
int exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
throws Throwable {
List<String> params = List.of(
"-ea", "-esa",
"-cp", Utils.TEST_CLASS_PATH,
"-Djdk.calendar.japanese.supplemental.era=" + property,
"SupplementalJapaneseEraTest");
// Build process (with VM flags)
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Stream.concat(params.stream(), javaParam.stream()).toList());
// Evaluate process status
int exitCode = ProcessTools.executeCommand(pb).getExitValue();

System.out.println(property + ":pass");
if (exitCode != 0) {
System.out.println(property + ":fail");
Expand Down
31 changes: 13 additions & 18 deletions test/jdk/java/util/Locale/LocaleProvidersRun.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, 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
Expand Down Expand Up @@ -39,7 +39,6 @@

import java.util.Locale;

import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.Utils;

Expand Down Expand Up @@ -178,22 +177,18 @@ public static void main(String[] args) throws Throwable {
}

private static void testRun(String prefList, String methodName,
String param1, String param2, String param3) throws Throwable{
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASS_PATH)
.addToolArg("-Djava.util.logging.config.class=LocaleProviders$LogConfig")
.addToolArg("-Djava.locale.providers=" + prefList)
.addToolArg("--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED")
.addToolArg("LocaleProviders")
.addToolArg(methodName)
.addToolArg(param1)
.addToolArg(param2)
.addToolArg(param3);
int exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
String param1, String param2, String param3) throws Throwable {

// Build process (with VM flags)
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
"-ea", "-esa",
"-cp", Utils.TEST_CLASS_PATH,
"-Djava.util.logging.config.class=LocaleProviders$LogConfig",
"-Djava.locale.providers=" + prefList,
"--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED",
"LocaleProviders", methodName, param1, param2, param3);
// Evaluate process status
int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Unexpected exit code: " + exitCode);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2023, 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
Expand Down Expand Up @@ -84,15 +84,13 @@ private static void runCmd() throws Throwable {
// UnreadableRB.properties is in current directory
String cp = Utils.TEST_CLASSES + File.pathSeparator + Utils.TEST_SRC
+ File.pathSeparator + ".";
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-cp")
.addToolArg(cp)
.addToolArg("MissingResourceCauseTest");

int exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
// Build process (with VM flags)
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
"-ea", "-esa",
"-cp", cp,
"MissingResourceCauseTest");
// Evaluate process status
int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test failed. "
+ "Unexpected exit code: " + exitCode);
Expand Down
66 changes: 31 additions & 35 deletions test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, 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
Expand Down Expand Up @@ -29,6 +29,7 @@
import java.util.stream.Stream;

import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Utils;
import jdk.test.lib.compiler.CompilerUtils;
import jdk.test.lib.process.ProcessTools;

Expand Down Expand Up @@ -133,17 +134,15 @@ public static void copyResFiles(Path src, Path dest, String mn,
*/
public static void runModule(String mp, String mn, List<String> localeList)
throws Throwable {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-p")
.addToolArg(mp)
.addToolArg("-m")
.addToolArg(mn);
localeList.forEach(launcher::addToolArg);

int exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
List<String> args = List.of(
"-ea", "-esa",
"-p", mp,
"-m", mn);
// Build process (with VM flags)
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Stream.concat(args.stream(), localeList.stream()).toList());
// Evaluate process status
int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test failed. "
+ "Unexpected exit code: " + exitCode);
Expand All @@ -161,19 +160,17 @@ public static void runModule(String mp, String mn, List<String> localeList)
*/
public static void runModuleWithCp(String cp, String mp, String mn,
List<String> localeList, boolean expected) throws Throwable {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-cp")
.addToolArg(cp)
.addToolArg("-p")
.addToolArg(mp)
.addToolArg("-m")
.addToolArg(mn);
localeList.forEach(launcher::addToolArg);
List<String> args = List.of(
"-ea", "-esa",
"-cp", cp,
"-p", mp,
"-m", mn);
// Build process (with VM flags)
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Stream.concat(args.stream(), localeList.stream()).toList());
// Evaluate process status
int exitCode = ProcessTools.executeCommand(pb).getExitValue();

int exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
if (expected) {
if (exitCode != 0) {
throw new RuntimeException("Execution of the test loads bundles "
Expand All @@ -198,18 +195,17 @@ public static void runModuleWithCp(String cp, String mp, String mn,
*/
public static void runModuleWithLegacyCode(String mp, String mn, List<String> localeList)
throws Throwable {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-Djava.locale.useOldISOCodes=true")
.addToolArg("-p")
.addToolArg(mp)
.addToolArg("-m")
.addToolArg(mn);
localeList.forEach(launcher::addToolArg);
List<String> args = List.of(
"-ea", "-esa",
"-Djava.locale.useOldISOCodes=true",
"-p", mp,
"-m", mn);
// Build process (with VM flags)
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Stream.concat(args.stream(), localeList.stream()).toList());
// Evaluate process status
int exitCode = ProcessTools.executeCommand(pb).getExitValue();

int exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test failed. "
+ "Unexpected exit code: " + exitCode);
Expand Down
19 changes: 8 additions & 11 deletions test/jdk/java/util/ResourceBundle/modules/layer/LayerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, 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
Expand Down Expand Up @@ -71,16 +71,13 @@ private static void compileCmd() throws Throwable {
}

private static void runCmd() throws Throwable {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASSES)
.addToolArg("Main")
.addToolArg(Utils.TEST_CLASSES);

int exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
// Build process (with VM flags)
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
"-ea", "-esa",
"-cp", Utils.TEST_CLASSES,
"Main", Utils.TEST_CLASSES);
// Evaluate process status
int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test failed. "
+ "Unexpected exit code: " + exitCode);
Expand Down
53 changes: 23 additions & 30 deletions test/jdk/java/util/ResourceBundle/modules/unnamed/UnNamedTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
Expand Down Expand Up @@ -39,6 +39,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Stream;

import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Utils;
Expand Down Expand Up @@ -73,42 +74,34 @@ private static void compileCmd() throws Throwable {

private static void runCmd() throws Throwable {
// access resource bundles that are exported private unconditionally.
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASSES)
.addToolArg("--module-path")
.addToolArg(MODS_DIR.toString())
.addToolArg("--add-modules")
.addToolArg("bundles")
.addToolArg("Main");
LOCALE_LIST.forEach(launcher::addToolArg);

int exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
List<String> args = List.of(
"-ea", "-esa",
"-cp", Utils.TEST_CLASSES,
"--module-path", MODS_DIR.toString(),
"--add-modules", "bundles",
"Main");
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Stream.concat(args.stream(), LOCALE_LIST.stream()).toList());
// Evaluate process status
int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test1 failed. "
+ "Unexpected exit code: " + exitCode);
}

// --add-exports can't open resources
launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa")
.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASSES)
.addToolArg("--module-path")
.addToolArg(MODS_DIR.toString())
.addToolArg("--add-modules")
.addToolArg("bundles")
.addToolArg("--add-opens")
.addToolArg("bundles/jdk.test.internal.resources=ALL-UNNAMED")
.addToolArg("Main");
LOCALE_LIST.forEach(launcher::addToolArg);
List<String> argsWithOpens = List.of(
"-ea", "-esa",
"-cp", Utils.TEST_CLASSES,
"--module-path", MODS_DIR.toString(),
"--add-modules", "bundles",
"--add-opens", "bundles/jdk.test.internal.resources=ALL-UNNAMED",
"Main");
pb = ProcessTools.createTestJavaProcessBuilder(
Stream.concat(argsWithOpens.stream(), LOCALE_LIST.stream()).toList());

exitCode = ProcessTools.executeCommand(launcher.getCommand())
.getExitValue();
// Evaluate process status
exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test2 failed. "
+ "Unexpected exit code: " + exitCode);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
Expand Down Expand Up @@ -39,10 +39,12 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Stream;

import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Utils;
import jdk.test.lib.process.ProcessTools;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -328,11 +330,10 @@ public void RunWithPkgRes(List<String> argsList) throws Throwable {
}

private int runCmd(List<String> argsList) throws Throwable {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
launcher.addToolArg("-ea")
.addToolArg("-esa");
argsList.forEach(launcher::addToolArg);

return ProcessTools.executeCommand(launcher.getCommand()).getExitValue();
// Build process (with VM flags)
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Stream.concat(Stream.of("-ea", "-esa"), argsList.stream()).toList());
// Evaluate process status
return ProcessTools.executeCommand(pb).getExitValue();
}
}
}
Loading

0 comments on commit d4a1e7f

Please sign in to comment.