11/*
2- * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,7 @@ public class CommandLinePositiveTest {
5050
5151 static final String JAVA_VERSION = System .getProperty ("java.version" );
5252 static final Path JAVA_HOME = Path .of (System .getProperty ("java.home" ));
53+ static final String LOCALE_OPT = "-Duser.language=en -Duser.country=US" ;
5354 static final String JAVA = getJava (JAVA_HOME );
5455 static final Path CWD = Path .of ("." ).toAbsolutePath ().normalize ();
5556 static final Path TEST_DIR = CWD .resolve ("CommandLinePositiveTest" );
@@ -84,7 +85,7 @@ static int normalExitCode() {
8485 @ Test (dataProvider = "directoryOptions" )
8586 public void testDirectory (String opt ) throws Throwable {
8687 out .println ("\n --- testDirectory, opt=\" %s\" " .formatted (opt ));
87- simpleserver (JAVA , "-m" , "jdk.httpserver" , "-p" , "0" , opt , TEST_DIR_STR )
88+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , "-p" , "0" , opt , TEST_DIR_STR )
8889 .shouldHaveExitValue (NORMAL_EXIT_CODE )
8990 .shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
9091 .shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
@@ -97,7 +98,7 @@ public void testDirectory(String opt) throws Throwable {
9798 @ Test (dataProvider = "portOptions" )
9899 public void testPort (String opt ) throws Throwable {
99100 out .println ("\n --- testPort, opt=\" %s\" " .formatted (opt ));
100- simpleserver (JAVA , "-m" , "jdk.httpserver" , opt , "0" )
101+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , opt , "0" )
101102 .shouldHaveExitValue (NORMAL_EXIT_CODE )
102103 .shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
103104 .shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
@@ -128,7 +129,7 @@ public void testHelp(String opt) throws Throwable {
128129 out .println ("\n --- testHelp, opt=\" %s\" " .formatted (opt ));
129130 simpleserver (WaitForLine .HELP_STARTUP_LINE ,
130131 false , // do not explicitly destroy the process
131- JAVA , "-m" , "jdk.httpserver" , opt )
132+ JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , opt )
132133 .shouldHaveExitValue (0 )
133134 .shouldContain (USAGE_TEXT )
134135 .shouldContain (OPTIONS_TEXT );
@@ -142,7 +143,7 @@ public void testVersion(String opt) throws Throwable {
142143 out .println ("\n --- testVersion, opt=\" %s\" " .formatted (opt ));
143144 simpleserver (WaitForLine .VERSION_STARTUP_LINE ,
144145 false , // do not explicitly destroy the process
145- JAVA , "-m" , "jdk.httpserver" , opt )
146+ JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , opt )
146147 .shouldHaveExitValue (0 );
147148 }
148149
@@ -152,12 +153,12 @@ public void testVersion(String opt) throws Throwable {
152153 @ Test (dataProvider = "bindOptions" )
153154 public void testBindAllInterfaces (String opt ) throws Throwable {
154155 out .println ("\n --- testBindAllInterfaces, opt=\" %s\" " .formatted (opt ));
155- simpleserver (JAVA , "-m" , "jdk.httpserver" , "-p" , "0" , opt , "0.0.0.0" )
156+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , "-p" , "0" , opt , "0.0.0.0" )
156157 .shouldHaveExitValue (NORMAL_EXIT_CODE )
157158 .shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on 0.0.0.0 (all interfaces) port" )
158159 .shouldContain ("URL http://" + InetAddress .getLocalHost ().getHostAddress ());
159160 if (IPSupport .hasIPv6 ()) {
160- simpleserver (JAVA , "-m" , "jdk.httpserver" , opt , "::0" )
161+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , opt , "::0" )
161162 .shouldHaveExitValue (NORMAL_EXIT_CODE )
162163 .shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on 0.0.0.0 (all interfaces) port" )
163164 .shouldContain ("URL http://" + InetAddress .getLocalHost ().getHostAddress ());
@@ -167,7 +168,7 @@ public void testBindAllInterfaces(String opt) throws Throwable {
167168 @ Test (dataProvider = "bindOptions" )
168169 public void testLastOneWinsBindAddress (String opt ) throws Throwable {
169170 out .println ("\n --- testLastOneWinsBindAddress, opt=\" %s\" " .formatted (opt ));
170- simpleserver (JAVA , "-m" , "jdk.httpserver" , "-p" , "0" , opt , "123.4.5.6" , opt , LOOPBACK_ADDR )
171+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , "-p" , "0" , opt , "123.4.5.6" , opt , LOOPBACK_ADDR )
171172 .shouldHaveExitValue (NORMAL_EXIT_CODE )
172173 .shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
173174 .shouldContain ("URL http://" + LOOPBACK_ADDR );
@@ -177,7 +178,7 @@ public void testLastOneWinsBindAddress(String opt) throws Throwable {
177178 @ Test (dataProvider = "directoryOptions" )
178179 public void testLastOneWinsDirectory (String opt ) throws Throwable {
179180 out .println ("\n --- testLastOneWinsDirectory, opt=\" %s\" " .formatted (opt ));
180- simpleserver (JAVA , "-m" , "jdk.httpserver" , "-p" , "0" , opt , TEST_DIR_STR , opt , TEST_DIR_STR )
181+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , "-p" , "0" , opt , TEST_DIR_STR , opt , TEST_DIR_STR )
181182 .shouldHaveExitValue (NORMAL_EXIT_CODE )
182183 .shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
183184 .shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
@@ -190,7 +191,7 @@ public void testLastOneWinsDirectory(String opt) throws Throwable {
190191 @ Test (dataProvider = "outputOptions" )
191192 public void testLastOneWinsOutput (String opt ) throws Throwable {
192193 out .println ("\n --- testLastOneWinsOutput, opt=\" %s\" " .formatted (opt ));
193- simpleserver (JAVA , "-m" , "jdk.httpserver" , "-p" , "0" , opt , "none" , opt , "verbose" )
194+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , "-p" , "0" , opt , "none" , opt , "verbose" )
194195 .shouldHaveExitValue (NORMAL_EXIT_CODE )
195196 .shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
196197 .shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
@@ -200,7 +201,7 @@ public void testLastOneWinsOutput(String opt) throws Throwable {
200201 @ Test (dataProvider = "portOptions" )
201202 public void testLastOneWinsPort (String opt ) throws Throwable {
202203 out .println ("\n --- testLastOneWinsPort, opt=\" %s\" " .formatted (opt ));
203- simpleserver (JAVA , "-m" , "jdk.httpserver" , opt , "-999" , opt , "0" )
204+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , opt , "-999" , opt , "0" )
204205 .shouldHaveExitValue (NORMAL_EXIT_CODE )
205206 .shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
206207 .shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
0 commit comments