Skip to content

Commit dc8edde

Browse files
committed
Merge pull request #19294
* gh-19294: Reduce visibility of test methods Closes gh-19294 See gh-19287
2 parents 47b47c2 + ded476b commit dc8edde

File tree

7 files changed

+69
-73
lines changed

7 files changed

+69
-73
lines changed

spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
*
3333
* @author Andy Wilkinson
3434
*/
35-
public class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
35+
class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
3636

3737
@ParameterizedTest(name = "{0}")
3838
@MethodSource("parameters")
39-
public void addARequestMappingToAnExistingController(ApplicationLauncher applicationLauncher) throws Exception {
39+
void addARequestMappingToAnExistingController(ApplicationLauncher applicationLauncher) throws Exception {
4040
launchApplication(applicationLauncher);
4141
TestRestTemplate template = new TestRestTemplate();
4242
String urlBase = "http://localhost:" + awaitServerPort();
@@ -51,8 +51,7 @@ public void addARequestMappingToAnExistingController(ApplicationLauncher applica
5151

5252
@ParameterizedTest(name = "{0}")
5353
@MethodSource("parameters")
54-
public void removeARequestMappingFromAnExistingController(ApplicationLauncher applicationLauncher)
55-
throws Exception {
54+
void removeARequestMappingFromAnExistingController(ApplicationLauncher applicationLauncher) throws Exception {
5655
launchApplication(applicationLauncher);
5756
TestRestTemplate template = new TestRestTemplate();
5857
String urlBase = "http://localhost:" + awaitServerPort();
@@ -65,7 +64,7 @@ public void removeARequestMappingFromAnExistingController(ApplicationLauncher ap
6564

6665
@ParameterizedTest(name = "{0}")
6766
@MethodSource("parameters")
68-
public void createAController(ApplicationLauncher applicationLauncher) throws Exception {
67+
void createAController(ApplicationLauncher applicationLauncher) throws Exception {
6968
launchApplication(applicationLauncher);
7069
TestRestTemplate template = new TestRestTemplate();
7170
String urlBase = "http://localhost:" + awaitServerPort();
@@ -81,7 +80,7 @@ public void createAController(ApplicationLauncher applicationLauncher) throws Ex
8180

8281
@ParameterizedTest(name = "{0}")
8382
@MethodSource("parameters")
84-
public void createAControllerAndThenAddARequestMapping(ApplicationLauncher applicationLauncher) throws Exception {
83+
void createAControllerAndThenAddARequestMapping(ApplicationLauncher applicationLauncher) throws Exception {
8584
launchApplication(applicationLauncher);
8685
TestRestTemplate template = new TestRestTemplate();
8786
String urlBase = "http://localhost:" + awaitServerPort();
@@ -99,8 +98,8 @@ public void createAControllerAndThenAddARequestMapping(ApplicationLauncher appli
9998

10099
@ParameterizedTest(name = "{0}")
101100
@MethodSource("parameters")
102-
public void createAControllerAndThenAddARequestMappingToAnExistingController(
103-
ApplicationLauncher applicationLauncher) throws Exception {
101+
void createAControllerAndThenAddARequestMappingToAnExistingController(ApplicationLauncher applicationLauncher)
102+
throws Exception {
104103
launchApplication(applicationLauncher);
105104
TestRestTemplate template = new TestRestTemplate();
106105
String urlBase = "http://localhost:" + awaitServerPort();
@@ -120,7 +119,7 @@ public void createAControllerAndThenAddARequestMappingToAnExistingController(
120119

121120
@ParameterizedTest(name = "{0}")
122121
@MethodSource("parameters")
123-
public void deleteAController(ApplicationLauncher applicationLauncher) throws Exception {
122+
void deleteAController(ApplicationLauncher applicationLauncher) throws Exception {
124123
launchApplication(applicationLauncher);
125124
TestRestTemplate template = new TestRestTemplate();
126125
String urlBase = "http://localhost:" + awaitServerPort();
@@ -135,7 +134,7 @@ public void deleteAController(ApplicationLauncher applicationLauncher) throws Ex
135134

136135
@ParameterizedTest(name = "{0}")
137136
@MethodSource("parameters")
138-
public void createAControllerAndThenDeleteIt(ApplicationLauncher applicationLauncher) throws Exception {
137+
void createAControllerAndThenDeleteIt(ApplicationLauncher applicationLauncher) throws Exception {
139138
launchApplication(applicationLauncher);
140139
TestRestTemplate template = new TestRestTemplate();
141140
String urlBase = "http://localhost:" + awaitServerPort();

spring-boot-tests/spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsWithLazyInitializationIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
*
3232
* @author Madhura Bhave
3333
*/
34-
public class DevToolsWithLazyInitializationIntegrationTests extends AbstractDevToolsIntegrationTests {
34+
class DevToolsWithLazyInitializationIntegrationTests extends AbstractDevToolsIntegrationTests {
3535

3636
@ParameterizedTest(name = "{0}")
3737
@MethodSource("parameters")
38-
public void addARequestMappingToAnExistingControllerWhenLazyInit(ApplicationLauncher applicationLauncher)
38+
void addARequestMappingToAnExistingControllerWhenLazyInit(ApplicationLauncher applicationLauncher)
3939
throws Exception {
4040
launchApplication(applicationLauncher, "--spring.main.lazy-initialization=true");
4141
TestRestTemplate template = new TestRestTemplate();

spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,31 @@
6161
* @author Andy Wilkinson
6262
* @author Ali Shahbour
6363
*/
64-
public class SysVinitLaunchScriptIT {
64+
class SysVinitLaunchScriptIT {
6565

6666
private final SpringBootDockerCmdExecFactory commandExecFactory = new SpringBootDockerCmdExecFactory();
6767

6868
private static final char ESC = 27;
6969

7070
@ParameterizedTest(name = "{0} {1}")
7171
@MethodSource("parameters")
72-
public void statusWhenStopped(String os, String version) throws Exception {
72+
void statusWhenStopped(String os, String version) throws Exception {
7373
String output = doTest(os, version, "status-when-stopped.sh");
7474
assertThat(output).contains("Status: 3");
7575
assertThat(output).has(coloredString(AnsiColor.RED, "Not running"));
7676
}
7777

7878
@ParameterizedTest(name = "{0} {1}")
7979
@MethodSource("parameters")
80-
public void statusWhenStarted(String os, String version) throws Exception {
80+
void statusWhenStarted(String os, String version) throws Exception {
8181
String output = doTest(os, version, "status-when-started.sh");
8282
assertThat(output).contains("Status: 0");
8383
assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
8484
}
8585

8686
@ParameterizedTest(name = "{0} {1}")
8787
@MethodSource("parameters")
88-
public void statusWhenKilled(String os, String version) throws Exception {
88+
void statusWhenKilled(String os, String version) throws Exception {
8989
String output = doTest(os, version, "status-when-killed.sh");
9090
assertThat(output).contains("Status: 1");
9191
assertThat(output)
@@ -94,31 +94,31 @@ public void statusWhenKilled(String os, String version) throws Exception {
9494

9595
@ParameterizedTest(name = "{0} {1}")
9696
@MethodSource("parameters")
97-
public void stopWhenStopped(String os, String version) throws Exception {
97+
void stopWhenStopped(String os, String version) throws Exception {
9898
String output = doTest(os, version, "stop-when-stopped.sh");
9999
assertThat(output).contains("Status: 0");
100100
assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
101101
}
102102

103103
@ParameterizedTest(name = "{0} {1}")
104104
@MethodSource("parameters")
105-
public void forceStopWhenStopped(String os, String version) throws Exception {
105+
void forceStopWhenStopped(String os, String version) throws Exception {
106106
String output = doTest(os, version, "force-stop-when-stopped.sh");
107107
assertThat(output).contains("Status: 0");
108108
assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
109109
}
110110

111111
@ParameterizedTest(name = "{0} {1}")
112112
@MethodSource("parameters")
113-
public void startWhenStarted(String os, String version) throws Exception {
113+
void startWhenStarted(String os, String version) throws Exception {
114114
String output = doTest(os, version, "start-when-started.sh");
115115
assertThat(output).contains("Status: 0");
116116
assertThat(output).has(coloredString(AnsiColor.YELLOW, "Already running [" + extractPid(output) + "]"));
117117
}
118118

119119
@ParameterizedTest(name = "{0} {1}")
120120
@MethodSource("parameters")
121-
public void restartWhenStopped(String os, String version) throws Exception {
121+
void restartWhenStopped(String os, String version) throws Exception {
122122
String output = doTest(os, version, "restart-when-stopped.sh");
123123
assertThat(output).contains("Status: 0");
124124
assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
@@ -127,7 +127,7 @@ public void restartWhenStopped(String os, String version) throws Exception {
127127

128128
@ParameterizedTest(name = "{0} {1}")
129129
@MethodSource("parameters")
130-
public void restartWhenStarted(String os, String version) throws Exception {
130+
void restartWhenStarted(String os, String version) throws Exception {
131131
String output = doTest(os, version, "restart-when-started.sh");
132132
assertThat(output).contains("Status: 0");
133133
assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extract("PID1", output) + "]"));
@@ -137,88 +137,88 @@ public void restartWhenStarted(String os, String version) throws Exception {
137137

138138
@ParameterizedTest(name = "{0} {1}")
139139
@MethodSource("parameters")
140-
public void startWhenStopped(String os, String version) throws Exception {
140+
void startWhenStopped(String os, String version) throws Exception {
141141
String output = doTest(os, version, "start-when-stopped.sh");
142142
assertThat(output).contains("Status: 0");
143143
assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
144144
}
145145

146146
@ParameterizedTest(name = "{0} {1}")
147147
@MethodSource("parameters")
148-
public void basicLaunch(String os, String version) throws Exception {
148+
void basicLaunch(String os, String version) throws Exception {
149149
String output = doTest(os, version, "basic-launch.sh");
150150
assertThat(output).doesNotContain("PID_FOLDER");
151151
}
152152

153153
@ParameterizedTest(name = "{0} {1}")
154154
@MethodSource("parameters")
155-
public void launchWithMissingLogFolderGeneratesAWarning(String os, String version) throws Exception {
155+
void launchWithMissingLogFolderGeneratesAWarning(String os, String version) throws Exception {
156156
String output = doTest(os, version, "launch-with-missing-log-folder.sh");
157157
assertThat(output).has(
158158
coloredString(AnsiColor.YELLOW, "LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
159159
}
160160

161161
@ParameterizedTest(name = "{0} {1}")
162162
@MethodSource("parameters")
163-
public void launchWithMissingPidFolderGeneratesAWarning(String os, String version) throws Exception {
163+
void launchWithMissingPidFolderGeneratesAWarning(String os, String version) throws Exception {
164164
String output = doTest(os, version, "launch-with-missing-pid-folder.sh");
165165
assertThat(output).has(
166166
coloredString(AnsiColor.YELLOW, "PID_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
167167
}
168168

169169
@ParameterizedTest(name = "{0} {1}")
170170
@MethodSource("parameters")
171-
public void launchWithSingleCommandLineArgument(String os, String version) throws Exception {
171+
void launchWithSingleCommandLineArgument(String os, String version) throws Exception {
172172
doLaunch(os, version, "launch-with-single-command-line-argument.sh");
173173
}
174174

175175
@ParameterizedTest(name = "{0} {1}")
176176
@MethodSource("parameters")
177-
public void launchWithMultipleCommandLineArguments(String os, String version) throws Exception {
177+
void launchWithMultipleCommandLineArguments(String os, String version) throws Exception {
178178
doLaunch(os, version, "launch-with-multiple-command-line-arguments.sh");
179179
}
180180

181181
@ParameterizedTest(name = "{0} {1}")
182182
@MethodSource("parameters")
183-
public void launchWithSingleRunArg(String os, String version) throws Exception {
183+
void launchWithSingleRunArg(String os, String version) throws Exception {
184184
doLaunch(os, version, "launch-with-single-run-arg.sh");
185185
}
186186

187187
@ParameterizedTest(name = "{0} {1}")
188188
@MethodSource("parameters")
189-
public void launchWithMultipleRunArgs(String os, String version) throws Exception {
189+
void launchWithMultipleRunArgs(String os, String version) throws Exception {
190190
doLaunch(os, version, "launch-with-multiple-run-args.sh");
191191
}
192192

193193
@ParameterizedTest(name = "{0} {1}")
194194
@MethodSource("parameters")
195-
public void launchWithSingleJavaOpt(String os, String version) throws Exception {
195+
void launchWithSingleJavaOpt(String os, String version) throws Exception {
196196
doLaunch(os, version, "launch-with-single-java-opt.sh");
197197
}
198198

199199
@ParameterizedTest(name = "{0} {1}")
200200
@MethodSource("parameters")
201-
public void launchWithDoubleLinkSingleJavaOpt(String os, String version) throws Exception {
201+
void launchWithDoubleLinkSingleJavaOpt(String os, String version) throws Exception {
202202
doLaunch(os, version, "launch-with-double-link-single-java-opt.sh");
203203
}
204204

205205
@ParameterizedTest(name = "{0} {1}")
206206
@MethodSource("parameters")
207-
public void launchWithMultipleJavaOpts(String os, String version) throws Exception {
207+
void launchWithMultipleJavaOpts(String os, String version) throws Exception {
208208
doLaunch(os, version, "launch-with-multiple-java-opts.sh");
209209
}
210210

211211
@ParameterizedTest(name = "{0} {1}")
212212
@MethodSource("parameters")
213-
public void launchWithUseOfStartStopDaemonDisabled(String os, String version) throws Exception {
213+
void launchWithUseOfStartStopDaemonDisabled(String os, String version) throws Exception {
214214
// CentOS doesn't have start-stop-daemon
215215
Assumptions.assumeFalse(os.equals("CentOS"));
216216
doLaunch(os, version, "launch-with-use-of-start-stop-daemon-disabled.sh");
217217
}
218218

219219
@ParameterizedTest(name = "{0} {1}")
220220
@MethodSource("parameters")
221-
public void launchWithRelativePidFolder(String os, String version) throws Exception {
221+
void launchWithRelativePidFolder(String os, String version) throws Exception {
222222
String output = doTest(os, version, "launch-with-relative-pid-folder.sh");
223223
assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
224224
assertThat(output).has(coloredString(AnsiColor.GREEN, "Running [" + extractPid(output) + "]"));
@@ -227,72 +227,71 @@ public void launchWithRelativePidFolder(String os, String version) throws Except
227227

228228
@ParameterizedTest(name = "{0} {1}")
229229
@MethodSource("parameters")
230-
public void pidFolderOwnership(String os, String version) throws Exception {
230+
void pidFolderOwnership(String os, String version) throws Exception {
231231
String output = doTest(os, version, "pid-folder-ownership.sh");
232232
assertThat(output).contains("phil root");
233233
}
234234

235235
@ParameterizedTest(name = "{0} {1}")
236236
@MethodSource("parameters")
237-
public void pidFileOwnership(String os, String version) throws Exception {
237+
void pidFileOwnership(String os, String version) throws Exception {
238238
String output = doTest(os, version, "pid-file-ownership.sh");
239239
assertThat(output).contains("phil root");
240240
}
241241

242242
@ParameterizedTest(name = "{0} {1}")
243243
@MethodSource("parameters")
244-
public void logFileOwnership(String os, String version) throws Exception {
244+
void logFileOwnership(String os, String version) throws Exception {
245245
String output = doTest(os, version, "log-file-ownership.sh");
246246
assertThat(output).contains("phil root");
247247
}
248248

249249
@ParameterizedTest(name = "{0} {1}")
250250
@MethodSource("parameters")
251-
public void logFileOwnershipIsChangedWhenCreated(String os, String version) throws Exception {
251+
void logFileOwnershipIsChangedWhenCreated(String os, String version) throws Exception {
252252
String output = doTest(os, version, "log-file-ownership-is-changed-when-created.sh");
253253
assertThat(output).contains("andy root");
254254
}
255255

256256
@ParameterizedTest(name = "{0} {1}")
257257
@MethodSource("parameters")
258-
public void logFileOwnershipIsUnchangedWhenExists(String os, String version) throws Exception {
258+
void logFileOwnershipIsUnchangedWhenExists(String os, String version) throws Exception {
259259
String output = doTest(os, version, "log-file-ownership-is-unchanged-when-exists.sh");
260260
assertThat(output).contains("root root");
261261
}
262262

263263
@ParameterizedTest(name = "{0} {1}")
264264
@MethodSource("parameters")
265-
public void launchWithRelativeLogFolder(String os, String version) throws Exception {
265+
void launchWithRelativeLogFolder(String os, String version) throws Exception {
266266
String output = doTest(os, version, "launch-with-relative-log-folder.sh");
267267
assertThat(output).contains("Log written");
268268
}
269269

270270
@ParameterizedTest(name = "{0} {1}")
271271
@MethodSource("parameters")
272-
public void launchWithRunAsUser(String os, String version) throws Exception {
272+
void launchWithRunAsUser(String os, String version) throws Exception {
273273
String output = doTest(os, version, "launch-with-run-as-user.sh");
274274
assertThat(output).contains("wagner root");
275275
}
276276

277277
@ParameterizedTest(name = "{0} {1}")
278278
@MethodSource("parameters")
279-
public void whenRunAsUserDoesNotExistLaunchFailsWithInvalidArgument(String os, String version) throws Exception {
279+
void whenRunAsUserDoesNotExistLaunchFailsWithInvalidArgument(String os, String version) throws Exception {
280280
String output = doTest(os, version, "launch-with-run-as-invalid-user.sh");
281281
assertThat(output).contains("Status: 2");
282282
assertThat(output).has(coloredString(AnsiColor.RED, "Cannot run as 'johndoe': no such user"));
283283
}
284284

285285
@ParameterizedTest(name = "{0} {1}")
286286
@MethodSource("parameters")
287-
public void whenJarOwnerAndRunAsUserAreBothSpecifiedRunAsUserTakesPrecedence(String os, String version)
288-
throws Exception {
287+
void whenJarOwnerAndRunAsUserAreBothSpecifiedRunAsUserTakesPrecedence(String os, String version) throws Exception {
289288
String output = doTest(os, version, "launch-with-run-as-user-preferred-to-jar-owner.sh");
290289
assertThat(output).contains("wagner root");
291290
}
292291

293292
@ParameterizedTest(name = "{0} {1}")
294293
@MethodSource("parameters")
295-
public void whenLaunchedUsingNonRootUserWithRunAsUserSpecifiedLaunchFailsWithInsufficientPrivilege(String os,
294+
void whenLaunchedUsingNonRootUserWithRunAsUserSpecifiedLaunchFailsWithInsufficientPrivilege(String os,
296295
String version) throws Exception {
297296
String output = doTest(os, version, "launch-with-run-as-user-root-required.sh");
298297
assertThat(output).contains("Status: 4");

spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerJarDevelopmentIntegrationTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,17 @@
3434
*/
3535
@EmbeddedServletContainerTest(packaging = "jar",
3636
launchers = { BootRunApplicationLauncher.class, IdeApplicationLauncher.class })
37-
public class EmbeddedServletContainerJarDevelopmentIntegrationTests {
37+
class EmbeddedServletContainerJarDevelopmentIntegrationTests {
3838

3939
@TestTemplate
40-
public void metaInfResourceFromDependencyIsAvailableViaHttp(RestTemplate rest) {
40+
void metaInfResourceFromDependencyIsAvailableViaHttp(RestTemplate rest) {
4141
ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class);
4242
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
4343
}
4444

4545
@TestTemplate
4646
@DisabledOnOs(OS.WINDOWS)
47-
public void metaInfResourceFromDependencyWithNameThatContainsReservedCharactersIsAvailableViaHttp(
48-
RestTemplate rest) {
47+
void metaInfResourceFromDependencyWithNameThatContainsReservedCharactersIsAvailableViaHttp(RestTemplate rest) {
4948
ResponseEntity<String> entity = rest.getForEntity(
5049
"/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt",
5150
String.class);
@@ -54,7 +53,7 @@ public void metaInfResourceFromDependencyWithNameThatContainsReservedCharactersI
5453
}
5554

5655
@TestTemplate
57-
public void metaInfResourceFromDependencyIsAvailableViaServletContext(RestTemplate rest) {
56+
void metaInfResourceFromDependencyIsAvailableViaServletContext(RestTemplate rest) {
5857
ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt",
5958
String.class);
6059
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);

0 commit comments

Comments
 (0)