1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,7 @@ public class CommandLinePositiveTest {
50
50
51
51
static final String JAVA_VERSION = System .getProperty ("java.version" );
52
52
static final Path JAVA_HOME = Path .of (System .getProperty ("java.home" ));
53
+ static final String LOCALE_OPT = "-Duser.language=en -Duser.country=US" ;
53
54
static final String JAVA = getJava (JAVA_HOME );
54
55
static final Path CWD = Path .of ("." ).toAbsolutePath ().normalize ();
55
56
static final Path TEST_DIR = CWD .resolve ("CommandLinePositiveTest" );
@@ -84,7 +85,7 @@ static int normalExitCode() {
84
85
@ Test (dataProvider = "directoryOptions" )
85
86
public void testDirectory (String opt ) throws Throwable {
86
87
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 )
88
89
.shouldHaveExitValue (NORMAL_EXIT_CODE )
89
90
.shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
90
91
.shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
@@ -97,7 +98,7 @@ public void testDirectory(String opt) throws Throwable {
97
98
@ Test (dataProvider = "portOptions" )
98
99
public void testPort (String opt ) throws Throwable {
99
100
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" )
101
102
.shouldHaveExitValue (NORMAL_EXIT_CODE )
102
103
.shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
103
104
.shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
@@ -128,7 +129,7 @@ public void testHelp(String opt) throws Throwable {
128
129
out .println ("\n --- testHelp, opt=\" %s\" " .formatted (opt ));
129
130
simpleserver (WaitForLine .HELP_STARTUP_LINE ,
130
131
false , // do not explicitly destroy the process
131
- JAVA , "-m" , "jdk.httpserver" , opt )
132
+ JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , opt )
132
133
.shouldHaveExitValue (0 )
133
134
.shouldContain (USAGE_TEXT )
134
135
.shouldContain (OPTIONS_TEXT );
@@ -142,7 +143,7 @@ public void testVersion(String opt) throws Throwable {
142
143
out .println ("\n --- testVersion, opt=\" %s\" " .formatted (opt ));
143
144
simpleserver (WaitForLine .VERSION_STARTUP_LINE ,
144
145
false , // do not explicitly destroy the process
145
- JAVA , "-m" , "jdk.httpserver" , opt )
146
+ JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , opt )
146
147
.shouldHaveExitValue (0 );
147
148
}
148
149
@@ -152,12 +153,12 @@ public void testVersion(String opt) throws Throwable {
152
153
@ Test (dataProvider = "bindOptions" )
153
154
public void testBindAllInterfaces (String opt ) throws Throwable {
154
155
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" )
156
157
.shouldHaveExitValue (NORMAL_EXIT_CODE )
157
158
.shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on 0.0.0.0 (all interfaces) port" )
158
159
.shouldContain ("URL http://" + InetAddress .getLocalHost ().getHostAddress ());
159
160
if (IPSupport .hasIPv6 ()) {
160
- simpleserver (JAVA , "-m" , "jdk.httpserver" , opt , "::0" )
161
+ simpleserver (JAVA , LOCALE_OPT , "-m" , "jdk.httpserver" , opt , "::0" )
161
162
.shouldHaveExitValue (NORMAL_EXIT_CODE )
162
163
.shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on 0.0.0.0 (all interfaces) port" )
163
164
.shouldContain ("URL http://" + InetAddress .getLocalHost ().getHostAddress ());
@@ -167,7 +168,7 @@ public void testBindAllInterfaces(String opt) throws Throwable {
167
168
@ Test (dataProvider = "bindOptions" )
168
169
public void testLastOneWinsBindAddress (String opt ) throws Throwable {
169
170
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 )
171
172
.shouldHaveExitValue (NORMAL_EXIT_CODE )
172
173
.shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
173
174
.shouldContain ("URL http://" + LOOPBACK_ADDR );
@@ -177,7 +178,7 @@ public void testLastOneWinsBindAddress(String opt) throws Throwable {
177
178
@ Test (dataProvider = "directoryOptions" )
178
179
public void testLastOneWinsDirectory (String opt ) throws Throwable {
179
180
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 )
181
182
.shouldHaveExitValue (NORMAL_EXIT_CODE )
182
183
.shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
183
184
.shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
@@ -190,7 +191,7 @@ public void testLastOneWinsDirectory(String opt) throws Throwable {
190
191
@ Test (dataProvider = "outputOptions" )
191
192
public void testLastOneWinsOutput (String opt ) throws Throwable {
192
193
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" )
194
195
.shouldHaveExitValue (NORMAL_EXIT_CODE )
195
196
.shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
196
197
.shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
@@ -200,7 +201,7 @@ public void testLastOneWinsOutput(String opt) throws Throwable {
200
201
@ Test (dataProvider = "portOptions" )
201
202
public void testLastOneWinsPort (String opt ) throws Throwable {
202
203
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" )
204
205
.shouldHaveExitValue (NORMAL_EXIT_CODE )
205
206
.shouldContain ("Binding to loopback by default. For all interfaces use \" -b 0.0.0.0\" or \" -b ::\" ." )
206
207
.shouldContain ("Serving " + TEST_DIR_STR + " and subdirectories on " + LOOPBACK_ADDR + " port" )
0 commit comments