Commit e60a7ea8 authored by Scott Frederick's avatar Scott Frederick

Fix Maven plugins tests on Windows

This commit fixes problems with file path separators and command
line argument quoting in Maven plug integration tests when run on
Windows.

Fixes gh-20244
parent 06d98c6b
...@@ -85,14 +85,14 @@ class RunIntegrationTests { ...@@ -85,14 +85,14 @@ class RunIntegrationTests {
@TestTemplate @TestTemplate
void whenCommandLineSpecifiesJvmArgumentsTheyAreAvailableToTheApplication(MavenBuild mavenBuild) { void whenCommandLineSpecifiesJvmArgumentsTheyAreAvailableToTheApplication(MavenBuild mavenBuild) {
mavenBuild.project("run-jvmargs-commandline").goals("spring-boot:run") mavenBuild.project("run-jvmargs-commandline").goals("spring-boot:run")
.systemProperty("spring-boot.run.jvmArguments", "\"-Dfoo=value1\" \"-Dbar=value2\"") .systemProperty("spring-boot.run.jvmArguments", "-Dfoo=value-from-cmd")
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run")); .execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
} }
@TestTemplate @TestTemplate
void whenPomAndCommandLineSpecifyJvmArgumentsThenPomOverrides(MavenBuild mavenBuild) { void whenPomAndCommandLineSpecifyJvmArgumentsThenPomOverrides(MavenBuild mavenBuild) {
mavenBuild.project("run-jvmargs").goals("spring-boot:run") mavenBuild.project("run-jvmargs").goals("spring-boot:run")
.systemProperty("spring-boot.run.jvmArguments", "\"-Dfoo=value-from-cmd\"") .systemProperty("spring-boot.run.jvmArguments", "-Dfoo=value-from-cmd")
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run")); .execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
} }
...@@ -117,7 +117,7 @@ class RunIntegrationTests { ...@@ -117,7 +117,7 @@ class RunIntegrationTests {
@TestTemplate @TestTemplate
void whenAWorkingDirectoryIsConfiguredTheApplicationIsRunFromThatDirectory(MavenBuild mavenBuild) { void whenAWorkingDirectoryIsConfiguredTheApplicationIsRunFromThatDirectory(MavenBuild mavenBuild) {
mavenBuild.project("run-working-directory").goals("spring-boot:run").execute( mavenBuild.project("run-working-directory").goals("spring-boot:run").execute(
(project) -> assertThat(buildLog(project)).containsPattern("I haz been run from.*/src/main/java")); (project) -> assertThat(buildLog(project)).containsPattern("I haz been run from.*src.main.java"));
} }
@TestTemplate @TestTemplate
......
...@@ -20,13 +20,9 @@ public class SampleApplication { ...@@ -20,13 +20,9 @@ public class SampleApplication {
public static void main(String[] args) { public static void main(String[] args) {
String foo = System.getProperty("foo"); String foo = System.getProperty("foo");
if (!"value1".equals(foo)) { if (!"value-from-cmd".equals(foo)) {
throw new IllegalStateException("foo system property mismatch (got [" + foo + "]"); throw new IllegalStateException("foo system property mismatch (got [" + foo + "]");
} }
String bar = System.getProperty("bar");
if (!"value2".equals(bar)) {
throw new IllegalStateException("bar system property mismatch (got [" + bar + "]");
}
System.out.println("I haz been run"); System.out.println("I haz been run");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment