< prev index next >

test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java

Print this page

  1 /*
  2  * Copyright (c) 2015, 2025, 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  */

 26  * @bug 8044767 8139067 8210408 8263202
 27  * @summary Basic tests for ResourceBundle with modules:
 28  *          1) Named module "test" contains resource bundles for root and en,
 29  *          and separate named modules "eubundles" and "asiabundles" contain
 30  *          other resource bundles.
 31  *          2) ResourceBundle.getBundle caller is in named module "test",
 32  *          resource bundles are grouped in main (module "mainbundles"),
 33  *          EU (module "eubundles"), and Asia (module "asiabundles").
 34  *          3) ResourceBundle.getBundle caller is in named module "test" and all
 35  *          resource bundles are in single named module "bundles".
 36  *          4) ResourceBundle.getBundle caller is in named module "test" and all
 37  *          resource bundles in xml format are in single named module "bundles".
 38  *          5) Resource bundles in a local named module with no ResourceBundleProviders.
 39  * @library /test/lib
 40  *          ..
 41  * @build jdk.test.lib.JDKToolLauncher
 42  *        jdk.test.lib.Utils
 43  *        jdk.test.lib.compiler.CompilerUtils
 44  *        jdk.test.lib.process.ProcessTools
 45  *        ModuleTestUtil
 46  * @run junit BasicTest
 47  */
 48 
 49 import java.nio.file.Path;
 50 import java.nio.file.Paths;
 51 import java.util.List;
 52 
 53 import jdk.test.lib.JDKToolLauncher;
 54 import jdk.test.lib.Utils;
 55 import jdk.test.lib.compiler.CompilerUtils;
 56 import jdk.test.lib.process.ProcessTools;
 57 
 58 import static jdk.test.lib.Asserts.assertEquals;
 59 import static org.junit.jupiter.api.Assertions.assertTrue;
 60 import org.junit.jupiter.api.Test;
 61 import org.junit.jupiter.api.TestInstance;
 62 import org.junit.jupiter.params.ParameterizedTest;
 63 import org.junit.jupiter.params.provider.MethodSource;
 64 
 65 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 66 public class BasicTest {

189                 + "Unexpected exit code: " + exitCode);
190     }
191 
192     /**
193      * Create extra_modlocal.jar to be added to the class path. Expected
194      * properties files are picked up from the class path.
195      */
196     private static void jarModLocal(Path srcPath, Path jarPath) throws Throwable {
197         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jar");
198         launcher.addToolArg("-cf")
199                 .addToolArg(jarPath.toString())
200                 .addToolArg("-C")
201                 .addToolArg(srcPath.resolve("extra").toString())
202                 .addToolArg("jdk/test/resources");
203 
204         int exitCode = ProcessTools.executeCommand(launcher.getCommand())
205                 .getExitValue();
206         assertEquals(exitCode, 0, "Create extra_modlocal.jar failed. "
207                 + "Unexpected exit code: " + exitCode);
208     }
209 }

  1 /*
  2  * Copyright (c) 2015, 2026, 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  */

 26  * @bug 8044767 8139067 8210408 8263202
 27  * @summary Basic tests for ResourceBundle with modules:
 28  *          1) Named module "test" contains resource bundles for root and en,
 29  *          and separate named modules "eubundles" and "asiabundles" contain
 30  *          other resource bundles.
 31  *          2) ResourceBundle.getBundle caller is in named module "test",
 32  *          resource bundles are grouped in main (module "mainbundles"),
 33  *          EU (module "eubundles"), and Asia (module "asiabundles").
 34  *          3) ResourceBundle.getBundle caller is in named module "test" and all
 35  *          resource bundles are in single named module "bundles".
 36  *          4) ResourceBundle.getBundle caller is in named module "test" and all
 37  *          resource bundles in xml format are in single named module "bundles".
 38  *          5) Resource bundles in a local named module with no ResourceBundleProviders.
 39  * @library /test/lib
 40  *          ..
 41  * @build jdk.test.lib.JDKToolLauncher
 42  *        jdk.test.lib.Utils
 43  *        jdk.test.lib.compiler.CompilerUtils
 44  *        jdk.test.lib.process.ProcessTools
 45  *        ModuleTestUtil
 46  * @run junit/timeout=200 BasicTest
 47  */
 48 
 49 import java.nio.file.Path;
 50 import java.nio.file.Paths;
 51 import java.util.List;
 52 
 53 import jdk.test.lib.JDKToolLauncher;
 54 import jdk.test.lib.Utils;
 55 import jdk.test.lib.compiler.CompilerUtils;
 56 import jdk.test.lib.process.ProcessTools;
 57 
 58 import static jdk.test.lib.Asserts.assertEquals;
 59 import static org.junit.jupiter.api.Assertions.assertTrue;
 60 import org.junit.jupiter.api.Test;
 61 import org.junit.jupiter.api.TestInstance;
 62 import org.junit.jupiter.params.ParameterizedTest;
 63 import org.junit.jupiter.params.provider.MethodSource;
 64 
 65 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 66 public class BasicTest {

189                 + "Unexpected exit code: " + exitCode);
190     }
191 
192     /**
193      * Create extra_modlocal.jar to be added to the class path. Expected
194      * properties files are picked up from the class path.
195      */
196     private static void jarModLocal(Path srcPath, Path jarPath) throws Throwable {
197         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jar");
198         launcher.addToolArg("-cf")
199                 .addToolArg(jarPath.toString())
200                 .addToolArg("-C")
201                 .addToolArg(srcPath.resolve("extra").toString())
202                 .addToolArg("jdk/test/resources");
203 
204         int exitCode = ProcessTools.executeCommand(launcher.getCommand())
205                 .getExitValue();
206         assertEquals(exitCode, 0, "Create extra_modlocal.jar failed. "
207                 + "Unexpected exit code: " + exitCode);
208     }
209 }
< prev index next >