Reduce visibility of test methods

See gh-19294
See gh-19287
This commit is contained in:
dreis2211 2019-12-05 11:44:52 +01:00 committed by Andy Wilkinson
parent 47b47c28a0
commit ded476b5ec
7 changed files with 69 additions and 73 deletions

View File

@ -32,11 +32,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
public class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests { class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
@ParameterizedTest(name = "{0}") @ParameterizedTest(name = "{0}")
@MethodSource("parameters") @MethodSource("parameters")
public void addARequestMappingToAnExistingController(ApplicationLauncher applicationLauncher) throws Exception { void addARequestMappingToAnExistingController(ApplicationLauncher applicationLauncher) throws Exception {
launchApplication(applicationLauncher); launchApplication(applicationLauncher);
TestRestTemplate template = new TestRestTemplate(); TestRestTemplate template = new TestRestTemplate();
String urlBase = "http://localhost:" + awaitServerPort(); String urlBase = "http://localhost:" + awaitServerPort();
@ -51,8 +51,7 @@ public class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
@ParameterizedTest(name = "{0}") @ParameterizedTest(name = "{0}")
@MethodSource("parameters") @MethodSource("parameters")
public void removeARequestMappingFromAnExistingController(ApplicationLauncher applicationLauncher) void removeARequestMappingFromAnExistingController(ApplicationLauncher applicationLauncher) throws Exception {
throws Exception {
launchApplication(applicationLauncher); launchApplication(applicationLauncher);
TestRestTemplate template = new TestRestTemplate(); TestRestTemplate template = new TestRestTemplate();
String urlBase = "http://localhost:" + awaitServerPort(); String urlBase = "http://localhost:" + awaitServerPort();
@ -65,7 +64,7 @@ public class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
@ParameterizedTest(name = "{0}") @ParameterizedTest(name = "{0}")
@MethodSource("parameters") @MethodSource("parameters")
public void createAController(ApplicationLauncher applicationLauncher) throws Exception { void createAController(ApplicationLauncher applicationLauncher) throws Exception {
launchApplication(applicationLauncher); launchApplication(applicationLauncher);
TestRestTemplate template = new TestRestTemplate(); TestRestTemplate template = new TestRestTemplate();
String urlBase = "http://localhost:" + awaitServerPort(); String urlBase = "http://localhost:" + awaitServerPort();
@ -81,7 +80,7 @@ public class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
@ParameterizedTest(name = "{0}") @ParameterizedTest(name = "{0}")
@MethodSource("parameters") @MethodSource("parameters")
public void createAControllerAndThenAddARequestMapping(ApplicationLauncher applicationLauncher) throws Exception { void createAControllerAndThenAddARequestMapping(ApplicationLauncher applicationLauncher) throws Exception {
launchApplication(applicationLauncher); launchApplication(applicationLauncher);
TestRestTemplate template = new TestRestTemplate(); TestRestTemplate template = new TestRestTemplate();
String urlBase = "http://localhost:" + awaitServerPort(); String urlBase = "http://localhost:" + awaitServerPort();
@ -99,8 +98,8 @@ public class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
@ParameterizedTest(name = "{0}") @ParameterizedTest(name = "{0}")
@MethodSource("parameters") @MethodSource("parameters")
public void createAControllerAndThenAddARequestMappingToAnExistingController( void createAControllerAndThenAddARequestMappingToAnExistingController(ApplicationLauncher applicationLauncher)
ApplicationLauncher applicationLauncher) throws Exception { throws Exception {
launchApplication(applicationLauncher); launchApplication(applicationLauncher);
TestRestTemplate template = new TestRestTemplate(); TestRestTemplate template = new TestRestTemplate();
String urlBase = "http://localhost:" + awaitServerPort(); String urlBase = "http://localhost:" + awaitServerPort();
@ -120,7 +119,7 @@ public class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
@ParameterizedTest(name = "{0}") @ParameterizedTest(name = "{0}")
@MethodSource("parameters") @MethodSource("parameters")
public void deleteAController(ApplicationLauncher applicationLauncher) throws Exception { void deleteAController(ApplicationLauncher applicationLauncher) throws Exception {
launchApplication(applicationLauncher); launchApplication(applicationLauncher);
TestRestTemplate template = new TestRestTemplate(); TestRestTemplate template = new TestRestTemplate();
String urlBase = "http://localhost:" + awaitServerPort(); String urlBase = "http://localhost:" + awaitServerPort();
@ -135,7 +134,7 @@ public class DevToolsIntegrationTests extends AbstractDevToolsIntegrationTests {
@ParameterizedTest(name = "{0}") @ParameterizedTest(name = "{0}")
@MethodSource("parameters") @MethodSource("parameters")
public void createAControllerAndThenDeleteIt(ApplicationLauncher applicationLauncher) throws Exception { void createAControllerAndThenDeleteIt(ApplicationLauncher applicationLauncher) throws Exception {
launchApplication(applicationLauncher); launchApplication(applicationLauncher);
TestRestTemplate template = new TestRestTemplate(); TestRestTemplate template = new TestRestTemplate();
String urlBase = "http://localhost:" + awaitServerPort(); String urlBase = "http://localhost:" + awaitServerPort();

View File

@ -31,11 +31,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Madhura Bhave * @author Madhura Bhave
*/ */
public class DevToolsWithLazyInitializationIntegrationTests extends AbstractDevToolsIntegrationTests { class DevToolsWithLazyInitializationIntegrationTests extends AbstractDevToolsIntegrationTests {
@ParameterizedTest(name = "{0}") @ParameterizedTest(name = "{0}")
@MethodSource("parameters") @MethodSource("parameters")
public void addARequestMappingToAnExistingControllerWhenLazyInit(ApplicationLauncher applicationLauncher) void addARequestMappingToAnExistingControllerWhenLazyInit(ApplicationLauncher applicationLauncher)
throws Exception { throws Exception {
launchApplication(applicationLauncher, "--spring.main.lazy-initialization=true"); launchApplication(applicationLauncher, "--spring.main.lazy-initialization=true");
TestRestTemplate template = new TestRestTemplate(); TestRestTemplate template = new TestRestTemplate();

View File

@ -61,7 +61,7 @@ import static org.hamcrest.Matchers.containsString;
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Ali Shahbour * @author Ali Shahbour
*/ */
public class SysVinitLaunchScriptIT { class SysVinitLaunchScriptIT {
private final SpringBootDockerCmdExecFactory commandExecFactory = new SpringBootDockerCmdExecFactory(); private final SpringBootDockerCmdExecFactory commandExecFactory = new SpringBootDockerCmdExecFactory();
@ -69,7 +69,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void statusWhenStopped(String os, String version) throws Exception { void statusWhenStopped(String os, String version) throws Exception {
String output = doTest(os, version, "status-when-stopped.sh"); String output = doTest(os, version, "status-when-stopped.sh");
assertThat(output).contains("Status: 3"); assertThat(output).contains("Status: 3");
assertThat(output).has(coloredString(AnsiColor.RED, "Not running")); assertThat(output).has(coloredString(AnsiColor.RED, "Not running"));
@ -77,7 +77,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void statusWhenStarted(String os, String version) throws Exception { void statusWhenStarted(String os, String version) throws Exception {
String output = doTest(os, version, "status-when-started.sh"); String output = doTest(os, version, "status-when-started.sh");
assertThat(output).contains("Status: 0"); assertThat(output).contains("Status: 0");
assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
@ -85,7 +85,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void statusWhenKilled(String os, String version) throws Exception { void statusWhenKilled(String os, String version) throws Exception {
String output = doTest(os, version, "status-when-killed.sh"); String output = doTest(os, version, "status-when-killed.sh");
assertThat(output).contains("Status: 1"); assertThat(output).contains("Status: 1");
assertThat(output) assertThat(output)
@ -94,7 +94,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void stopWhenStopped(String os, String version) throws Exception { void stopWhenStopped(String os, String version) throws Exception {
String output = doTest(os, version, "stop-when-stopped.sh"); String output = doTest(os, version, "stop-when-stopped.sh");
assertThat(output).contains("Status: 0"); assertThat(output).contains("Status: 0");
assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
@ -102,7 +102,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void forceStopWhenStopped(String os, String version) throws Exception { void forceStopWhenStopped(String os, String version) throws Exception {
String output = doTest(os, version, "force-stop-when-stopped.sh"); String output = doTest(os, version, "force-stop-when-stopped.sh");
assertThat(output).contains("Status: 0"); assertThat(output).contains("Status: 0");
assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
@ -110,7 +110,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void startWhenStarted(String os, String version) throws Exception { void startWhenStarted(String os, String version) throws Exception {
String output = doTest(os, version, "start-when-started.sh"); String output = doTest(os, version, "start-when-started.sh");
assertThat(output).contains("Status: 0"); assertThat(output).contains("Status: 0");
assertThat(output).has(coloredString(AnsiColor.YELLOW, "Already running [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Already running [" + extractPid(output) + "]"));
@ -118,7 +118,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void restartWhenStopped(String os, String version) throws Exception { void restartWhenStopped(String os, String version) throws Exception {
String output = doTest(os, version, "restart-when-stopped.sh"); String output = doTest(os, version, "restart-when-stopped.sh");
assertThat(output).contains("Status: 0"); assertThat(output).contains("Status: 0");
assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
@ -127,7 +127,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void restartWhenStarted(String os, String version) throws Exception { void restartWhenStarted(String os, String version) throws Exception {
String output = doTest(os, version, "restart-when-started.sh"); String output = doTest(os, version, "restart-when-started.sh");
assertThat(output).contains("Status: 0"); assertThat(output).contains("Status: 0");
assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extract("PID1", output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extract("PID1", output) + "]"));
@ -137,7 +137,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void startWhenStopped(String os, String version) throws Exception { void startWhenStopped(String os, String version) throws Exception {
String output = doTest(os, version, "start-when-stopped.sh"); String output = doTest(os, version, "start-when-stopped.sh");
assertThat(output).contains("Status: 0"); assertThat(output).contains("Status: 0");
assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
@ -145,14 +145,14 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void basicLaunch(String os, String version) throws Exception { void basicLaunch(String os, String version) throws Exception {
String output = doTest(os, version, "basic-launch.sh"); String output = doTest(os, version, "basic-launch.sh");
assertThat(output).doesNotContain("PID_FOLDER"); assertThat(output).doesNotContain("PID_FOLDER");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithMissingLogFolderGeneratesAWarning(String os, String version) throws Exception { void launchWithMissingLogFolderGeneratesAWarning(String os, String version) throws Exception {
String output = doTest(os, version, "launch-with-missing-log-folder.sh"); String output = doTest(os, version, "launch-with-missing-log-folder.sh");
assertThat(output).has( assertThat(output).has(
coloredString(AnsiColor.YELLOW, "LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp")); coloredString(AnsiColor.YELLOW, "LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
@ -160,7 +160,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithMissingPidFolderGeneratesAWarning(String os, String version) throws Exception { void launchWithMissingPidFolderGeneratesAWarning(String os, String version) throws Exception {
String output = doTest(os, version, "launch-with-missing-pid-folder.sh"); String output = doTest(os, version, "launch-with-missing-pid-folder.sh");
assertThat(output).has( assertThat(output).has(
coloredString(AnsiColor.YELLOW, "PID_FOLDER /does/not/exist does not exist. Falling back to /tmp")); coloredString(AnsiColor.YELLOW, "PID_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
@ -168,49 +168,49 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithSingleCommandLineArgument(String os, String version) throws Exception { void launchWithSingleCommandLineArgument(String os, String version) throws Exception {
doLaunch(os, version, "launch-with-single-command-line-argument.sh"); doLaunch(os, version, "launch-with-single-command-line-argument.sh");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithMultipleCommandLineArguments(String os, String version) throws Exception { void launchWithMultipleCommandLineArguments(String os, String version) throws Exception {
doLaunch(os, version, "launch-with-multiple-command-line-arguments.sh"); doLaunch(os, version, "launch-with-multiple-command-line-arguments.sh");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithSingleRunArg(String os, String version) throws Exception { void launchWithSingleRunArg(String os, String version) throws Exception {
doLaunch(os, version, "launch-with-single-run-arg.sh"); doLaunch(os, version, "launch-with-single-run-arg.sh");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithMultipleRunArgs(String os, String version) throws Exception { void launchWithMultipleRunArgs(String os, String version) throws Exception {
doLaunch(os, version, "launch-with-multiple-run-args.sh"); doLaunch(os, version, "launch-with-multiple-run-args.sh");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithSingleJavaOpt(String os, String version) throws Exception { void launchWithSingleJavaOpt(String os, String version) throws Exception {
doLaunch(os, version, "launch-with-single-java-opt.sh"); doLaunch(os, version, "launch-with-single-java-opt.sh");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithDoubleLinkSingleJavaOpt(String os, String version) throws Exception { void launchWithDoubleLinkSingleJavaOpt(String os, String version) throws Exception {
doLaunch(os, version, "launch-with-double-link-single-java-opt.sh"); doLaunch(os, version, "launch-with-double-link-single-java-opt.sh");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithMultipleJavaOpts(String os, String version) throws Exception { void launchWithMultipleJavaOpts(String os, String version) throws Exception {
doLaunch(os, version, "launch-with-multiple-java-opts.sh"); doLaunch(os, version, "launch-with-multiple-java-opts.sh");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithUseOfStartStopDaemonDisabled(String os, String version) throws Exception { void launchWithUseOfStartStopDaemonDisabled(String os, String version) throws Exception {
// CentOS doesn't have start-stop-daemon // CentOS doesn't have start-stop-daemon
Assumptions.assumeFalse(os.equals("CentOS")); Assumptions.assumeFalse(os.equals("CentOS"));
doLaunch(os, version, "launch-with-use-of-start-stop-daemon-disabled.sh"); doLaunch(os, version, "launch-with-use-of-start-stop-daemon-disabled.sh");
@ -218,7 +218,7 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithRelativePidFolder(String os, String version) throws Exception { void launchWithRelativePidFolder(String os, String version) throws Exception {
String output = doTest(os, version, "launch-with-relative-pid-folder.sh"); String output = doTest(os, version, "launch-with-relative-pid-folder.sh");
assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
assertThat(output).has(coloredString(AnsiColor.GREEN, "Running [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Running [" + extractPid(output) + "]"));
@ -227,56 +227,56 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void pidFolderOwnership(String os, String version) throws Exception { void pidFolderOwnership(String os, String version) throws Exception {
String output = doTest(os, version, "pid-folder-ownership.sh"); String output = doTest(os, version, "pid-folder-ownership.sh");
assertThat(output).contains("phil root"); assertThat(output).contains("phil root");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void pidFileOwnership(String os, String version) throws Exception { void pidFileOwnership(String os, String version) throws Exception {
String output = doTest(os, version, "pid-file-ownership.sh"); String output = doTest(os, version, "pid-file-ownership.sh");
assertThat(output).contains("phil root"); assertThat(output).contains("phil root");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void logFileOwnership(String os, String version) throws Exception { void logFileOwnership(String os, String version) throws Exception {
String output = doTest(os, version, "log-file-ownership.sh"); String output = doTest(os, version, "log-file-ownership.sh");
assertThat(output).contains("phil root"); assertThat(output).contains("phil root");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void logFileOwnershipIsChangedWhenCreated(String os, String version) throws Exception { void logFileOwnershipIsChangedWhenCreated(String os, String version) throws Exception {
String output = doTest(os, version, "log-file-ownership-is-changed-when-created.sh"); String output = doTest(os, version, "log-file-ownership-is-changed-when-created.sh");
assertThat(output).contains("andy root"); assertThat(output).contains("andy root");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void logFileOwnershipIsUnchangedWhenExists(String os, String version) throws Exception { void logFileOwnershipIsUnchangedWhenExists(String os, String version) throws Exception {
String output = doTest(os, version, "log-file-ownership-is-unchanged-when-exists.sh"); String output = doTest(os, version, "log-file-ownership-is-unchanged-when-exists.sh");
assertThat(output).contains("root root"); assertThat(output).contains("root root");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithRelativeLogFolder(String os, String version) throws Exception { void launchWithRelativeLogFolder(String os, String version) throws Exception {
String output = doTest(os, version, "launch-with-relative-log-folder.sh"); String output = doTest(os, version, "launch-with-relative-log-folder.sh");
assertThat(output).contains("Log written"); assertThat(output).contains("Log written");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void launchWithRunAsUser(String os, String version) throws Exception { void launchWithRunAsUser(String os, String version) throws Exception {
String output = doTest(os, version, "launch-with-run-as-user.sh"); String output = doTest(os, version, "launch-with-run-as-user.sh");
assertThat(output).contains("wagner root"); assertThat(output).contains("wagner root");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void whenRunAsUserDoesNotExistLaunchFailsWithInvalidArgument(String os, String version) throws Exception { void whenRunAsUserDoesNotExistLaunchFailsWithInvalidArgument(String os, String version) throws Exception {
String output = doTest(os, version, "launch-with-run-as-invalid-user.sh"); String output = doTest(os, version, "launch-with-run-as-invalid-user.sh");
assertThat(output).contains("Status: 2"); assertThat(output).contains("Status: 2");
assertThat(output).has(coloredString(AnsiColor.RED, "Cannot run as 'johndoe': no such user")); assertThat(output).has(coloredString(AnsiColor.RED, "Cannot run as 'johndoe': no such user"));
@ -284,15 +284,14 @@ public class SysVinitLaunchScriptIT {
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void whenJarOwnerAndRunAsUserAreBothSpecifiedRunAsUserTakesPrecedence(String os, String version) void whenJarOwnerAndRunAsUserAreBothSpecifiedRunAsUserTakesPrecedence(String os, String version) throws Exception {
throws Exception {
String output = doTest(os, version, "launch-with-run-as-user-preferred-to-jar-owner.sh"); String output = doTest(os, version, "launch-with-run-as-user-preferred-to-jar-owner.sh");
assertThat(output).contains("wagner root"); assertThat(output).contains("wagner root");
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
public void whenLaunchedUsingNonRootUserWithRunAsUserSpecifiedLaunchFailsWithInsufficientPrivilege(String os, void whenLaunchedUsingNonRootUserWithRunAsUserSpecifiedLaunchFailsWithInsufficientPrivilege(String os,
String version) throws Exception { String version) throws Exception {
String output = doTest(os, version, "launch-with-run-as-user-root-required.sh"); String output = doTest(os, version, "launch-with-run-as-user-root-required.sh");
assertThat(output).contains("Status: 4"); assertThat(output).contains("Status: 4");

View File

@ -34,18 +34,17 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@EmbeddedServletContainerTest(packaging = "jar", @EmbeddedServletContainerTest(packaging = "jar",
launchers = { BootRunApplicationLauncher.class, IdeApplicationLauncher.class }) launchers = { BootRunApplicationLauncher.class, IdeApplicationLauncher.class })
public class EmbeddedServletContainerJarDevelopmentIntegrationTests { class EmbeddedServletContainerJarDevelopmentIntegrationTests {
@TestTemplate @TestTemplate
public void metaInfResourceFromDependencyIsAvailableViaHttp(RestTemplate rest) { void metaInfResourceFromDependencyIsAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class); ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
@DisabledOnOs(OS.WINDOWS) @DisabledOnOs(OS.WINDOWS)
public void metaInfResourceFromDependencyWithNameThatContainsReservedCharactersIsAvailableViaHttp( void metaInfResourceFromDependencyWithNameThatContainsReservedCharactersIsAvailableViaHttp(RestTemplate rest) {
RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity( ResponseEntity<String> entity = rest.getForEntity(
"/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt", "/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt",
String.class); String.class);
@ -54,7 +53,7 @@ public class EmbeddedServletContainerJarDevelopmentIntegrationTests {
} }
@TestTemplate @TestTemplate
public void metaInfResourceFromDependencyIsAvailableViaServletContext(RestTemplate rest) { void metaInfResourceFromDependencyIsAvailableViaServletContext(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt", ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);

View File

@ -34,17 +34,17 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@EmbeddedServletContainerTest(packaging = "jar", @EmbeddedServletContainerTest(packaging = "jar",
launchers = { PackagedApplicationLauncher.class, ExplodedApplicationLauncher.class }) launchers = { PackagedApplicationLauncher.class, ExplodedApplicationLauncher.class })
public class EmbeddedServletContainerJarPackagingIntegrationTests { class EmbeddedServletContainerJarPackagingIntegrationTests {
@TestTemplate @TestTemplate
public void nestedMetaInfResourceIsAvailableViaHttp(RestTemplate rest) { void nestedMetaInfResourceIsAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class); ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
@DisabledOnOs(OS.WINDOWS) @DisabledOnOs(OS.WINDOWS)
public void nestedMetaInfResourceWithNameThatContainsReservedCharactersIsAvailableViaHttp(RestTemplate rest) { void nestedMetaInfResourceWithNameThatContainsReservedCharactersIsAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity( ResponseEntity<String> entity = rest.getForEntity(
"/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt", "/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt",
String.class); String.class);
@ -53,27 +53,27 @@ public class EmbeddedServletContainerJarPackagingIntegrationTests {
} }
@TestTemplate @TestTemplate
public void nestedMetaInfResourceIsAvailableViaServletContext(RestTemplate rest) { void nestedMetaInfResourceIsAvailableViaServletContext(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt", ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
public void nestedJarIsNotAvailableViaHttp(RestTemplate rest) { void nestedJarIsNotAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/BOOT-INF/lib/resources-1.0.jar", String.class); ResponseEntity<String> entity = rest.getForEntity("/BOOT-INF/lib/resources-1.0.jar", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
} }
@TestTemplate @TestTemplate
public void applicationClassesAreNotAvailableViaHttp(RestTemplate rest) { void applicationClassesAreNotAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest ResponseEntity<String> entity = rest
.getForEntity("/BOOT-INF/classes/com/example/ResourceHandlingApplication.class", String.class); .getForEntity("/BOOT-INF/classes/com/example/ResourceHandlingApplication.class", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
} }
@TestTemplate @TestTemplate
public void launcherIsNotAvailableViaHttp(RestTemplate rest) { void launcherIsNotAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/org/springframework/boot/loader/Launcher.class", ResponseEntity<String> entity = rest.getForEntity("/org/springframework/boot/loader/Launcher.class",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);

View File

@ -41,18 +41,17 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@EmbeddedServletContainerTest(packaging = "war", @EmbeddedServletContainerTest(packaging = "war",
launchers = { BootRunApplicationLauncher.class, IdeApplicationLauncher.class }) launchers = { BootRunApplicationLauncher.class, IdeApplicationLauncher.class })
public class EmbeddedServletContainerWarDevelopmentIntegrationTests { class EmbeddedServletContainerWarDevelopmentIntegrationTests {
@TestTemplate @TestTemplate
public void metaInfResourceFromDependencyIsAvailableViaHttp(RestTemplate rest) { void metaInfResourceFromDependencyIsAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class); ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
@DisabledOnOs(OS.WINDOWS) @DisabledOnOs(OS.WINDOWS)
public void metaInfResourceFromDependencyWithNameThatContainsReservedCharactersIsAvailableViaHttp( void metaInfResourceFromDependencyWithNameThatContainsReservedCharactersIsAvailableViaHttp(RestTemplate rest) {
RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity( ResponseEntity<String> entity = rest.getForEntity(
"/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt", "/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt",
String.class); String.class);
@ -61,20 +60,20 @@ public class EmbeddedServletContainerWarDevelopmentIntegrationTests {
} }
@TestTemplate @TestTemplate
public void metaInfResourceFromDependencyIsAvailableViaServletContext(RestTemplate rest) { void metaInfResourceFromDependencyIsAvailableViaServletContext(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt", ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
public void webappResourcesAreAvailableViaHttp(RestTemplate rest) { void webappResourcesAreAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/webapp-resource.txt", String.class); ResponseEntity<String> entity = rest.getForEntity("/webapp-resource.txt", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
public void loaderClassesAreNotAvailableViaResourcePaths(RestTemplate rest) { void loaderClassesAreNotAvailableViaResourcePaths(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/resourcePaths", String.class); ResponseEntity<String> entity = rest.getForEntity("/resourcePaths", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(readLines(entity.getBody())) assertThat(readLines(entity.getBody()))

View File

@ -41,17 +41,17 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@EmbeddedServletContainerTest(packaging = "war", @EmbeddedServletContainerTest(packaging = "war",
launchers = { PackagedApplicationLauncher.class, ExplodedApplicationLauncher.class }) launchers = { PackagedApplicationLauncher.class, ExplodedApplicationLauncher.class })
public class EmbeddedServletContainerWarPackagingIntegrationTests { class EmbeddedServletContainerWarPackagingIntegrationTests {
@TestTemplate @TestTemplate
public void nestedMetaInfResourceIsAvailableViaHttp(RestTemplate rest) { void nestedMetaInfResourceIsAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class); ResponseEntity<String> entity = rest.getForEntity("/nested-meta-inf-resource.txt", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
@DisabledOnOs(OS.WINDOWS) @DisabledOnOs(OS.WINDOWS)
public void nestedMetaInfResourceWithNameThatContainsReservedCharactersIsAvailableViaHttp(RestTemplate rest) { void nestedMetaInfResourceWithNameThatContainsReservedCharactersIsAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity( ResponseEntity<String> entity = rest.getForEntity(
"/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt", "/nested-reserved-%21%23%24%25%26%28%29%2A%2B%2C%3A%3D%3F%40%5B%5D-meta-inf-resource.txt",
String.class); String.class);
@ -60,33 +60,33 @@ public class EmbeddedServletContainerWarPackagingIntegrationTests {
} }
@TestTemplate @TestTemplate
public void nestedMetaInfResourceIsAvailableViaServletContext(RestTemplate rest) { void nestedMetaInfResourceIsAvailableViaServletContext(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt", ResponseEntity<String> entity = rest.getForEntity("/servletContext?/nested-meta-inf-resource.txt",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
public void nestedJarIsNotAvailableViaHttp(RestTemplate rest) { void nestedJarIsNotAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/WEB-INF/lib/resources-1.0.jar", String.class); ResponseEntity<String> entity = rest.getForEntity("/WEB-INF/lib/resources-1.0.jar", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
} }
@TestTemplate @TestTemplate
public void applicationClassesAreNotAvailableViaHttp(RestTemplate rest) { void applicationClassesAreNotAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest ResponseEntity<String> entity = rest
.getForEntity("/WEB-INF/classes/com/example/ResourceHandlingApplication.class", String.class); .getForEntity("/WEB-INF/classes/com/example/ResourceHandlingApplication.class", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
} }
@TestTemplate @TestTemplate
public void webappResourcesAreAvailableViaHttp(RestTemplate rest) { void webappResourcesAreAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/webapp-resource.txt", String.class); ResponseEntity<String> entity = rest.getForEntity("/webapp-resource.txt", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@TestTemplate @TestTemplate
public void loaderClassesAreNotAvailableViaHttp(RestTemplate rest) { void loaderClassesAreNotAvailableViaHttp(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/org/springframework/boot/loader/Launcher.class", ResponseEntity<String> entity = rest.getForEntity("/org/springframework/boot/loader/Launcher.class",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
@ -95,7 +95,7 @@ public class EmbeddedServletContainerWarPackagingIntegrationTests {
} }
@TestTemplate @TestTemplate
public void loaderClassesAreNotAvailableViaResourcePaths(RestTemplate rest) { void loaderClassesAreNotAvailableViaResourcePaths(RestTemplate rest) {
ResponseEntity<String> entity = rest.getForEntity("/resourcePaths", String.class); ResponseEntity<String> entity = rest.getForEntity("/resourcePaths", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(readLines(entity.getBody())) assertThat(readLines(entity.getBody()))