diff --git a/boot/command-line-runner/src/main/java/com/example/commandlinerunner/CommandlinerunnerApplication.java b/boot/command-line-runner/src/main/java/com/example/commandlinerunner/CommandlinerunnerApplication.java index c94f7021..4e274970 100644 --- a/boot/command-line-runner/src/main/java/com/example/commandlinerunner/CommandlinerunnerApplication.java +++ b/boot/command-line-runner/src/main/java/com/example/commandlinerunner/CommandlinerunnerApplication.java @@ -7,9 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; public class CommandlinerunnerApplication { public static void main(String[] args) { - SpringApplication application = new SpringApplication(CommandlinerunnerApplication.class); - System.setProperty("main.ran", "true"); - application.run(args); + SpringApplication.run(CommandlinerunnerApplication.class, args); } } diff --git a/boot/tcf/README.adoc b/boot/tcf/README.adoc new file mode 100644 index 00000000..7988695a --- /dev/null +++ b/boot/tcf/README.adoc @@ -0,0 +1 @@ +Tests if Spring Boot's TestContext Framework is working diff --git a/boot/tcf/build.gradle b/boot/tcf/build.gradle new file mode 100644 index 00000000..f0ae4d37 --- /dev/null +++ b/boot/tcf/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'java' + id 'org.springframework.boot' + id 'org.springframework.aot.smoke-test' + id 'org.graalvm.buildtools.native' +} + +dependencies { + implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)) + implementation("org.springframework.boot:spring-boot-starter") + + testImplementation("org.springframework.boot:spring-boot-starter-test") + + appTestImplementation(project(":aot-smoke-test-support")) + appTestImplementation("org.awaitility:awaitility:4.2.0") +} diff --git a/boot/tcf/src/main/java/com/example/boot/tcf/BootTcfApplication.java b/boot/tcf/src/main/java/com/example/boot/tcf/BootTcfApplication.java new file mode 100644 index 00000000..4a61409b --- /dev/null +++ b/boot/tcf/src/main/java/com/example/boot/tcf/BootTcfApplication.java @@ -0,0 +1,15 @@ +package com.example.boot.tcf; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BootTcfApplication { + + public static void main(String[] args) { + SpringApplication application = new SpringApplication(BootTcfApplication.class); + System.setProperty("main.ran", "true"); + application.run(args); + } + +} diff --git a/boot/command-line-runner/src/test/java/com/example/commandlinerunner/CommandlinerunnerApplicationTests.java b/boot/tcf/src/test/java/com/example/boot/tcf/ArgsTest.java similarity index 58% rename from boot/command-line-runner/src/test/java/com/example/commandlinerunner/CommandlinerunnerApplicationTests.java rename to boot/tcf/src/test/java/com/example/boot/tcf/ArgsTest.java index d31b56cf..6b5c8277 100644 --- a/boot/command-line-runner/src/test/java/com/example/commandlinerunner/CommandlinerunnerApplicationTests.java +++ b/boot/tcf/src/test/java/com/example/boot/tcf/ArgsTest.java @@ -1,4 +1,4 @@ -package com.example.commandlinerunner; +package com.example.boot.tcf; import java.util.List; @@ -7,19 +7,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.UseMainMethod; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import static org.assertj.core.api.Assertions.assertThat; -@SpringBootTest(webEnvironment = WebEnvironment.NONE, useMainMethod = UseMainMethod.ALWAYS, args = "--test.args=1") -class CommandlinerunnerApplicationTests { - - @Test - void mainShouldRun() { - String property = System.getProperty("main.ran", "false"); - assertThat(property).isEqualTo("true"); - } +@SpringBootTest(webEnvironment = WebEnvironment.NONE, args = "--test.args=1") +class ArgsTest { @Test void shouldPassArgs(@Autowired ApplicationArguments applicationArguments) { diff --git a/boot/tcf/src/test/java/com/example/boot/tcf/MainMethodTests.java b/boot/tcf/src/test/java/com/example/boot/tcf/MainMethodTests.java new file mode 100644 index 00000000..bd4f986f --- /dev/null +++ b/boot/tcf/src/test/java/com/example/boot/tcf/MainMethodTests.java @@ -0,0 +1,20 @@ +package com.example.boot.tcf; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.UseMainMethod; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest(webEnvironment = WebEnvironment.NONE, useMainMethod = UseMainMethod.ALWAYS) +class MainMethodTests { + + @Test + void mainShouldRun() { + String property = System.getProperty("main.ran", "false"); + assertThat(property).isEqualTo("true"); + } + +} diff --git a/boot/command-line-runner/src/test/java/com/example/commandlinerunner/OutputCaptureTests.java b/boot/tcf/src/test/java/com/example/boot/tcf/OutputCaptureTests.java similarity index 92% rename from boot/command-line-runner/src/test/java/com/example/commandlinerunner/OutputCaptureTests.java rename to boot/tcf/src/test/java/com/example/boot/tcf/OutputCaptureTests.java index e0a2e565..e7e367af 100644 --- a/boot/command-line-runner/src/test/java/com/example/commandlinerunner/OutputCaptureTests.java +++ b/boot/tcf/src/test/java/com/example/boot/tcf/OutputCaptureTests.java @@ -1,4 +1,4 @@ -package com.example.commandlinerunner; +package com.example.boot.tcf; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/boot/command-line-runner/src/test/java/com/example/commandlinerunner/PropertiesTests.java b/boot/tcf/src/test/java/com/example/boot/tcf/PropertiesTests.java similarity index 94% rename from boot/command-line-runner/src/test/java/com/example/commandlinerunner/PropertiesTests.java rename to boot/tcf/src/test/java/com/example/boot/tcf/PropertiesTests.java index 54773695..dd37b441 100644 --- a/boot/command-line-runner/src/test/java/com/example/commandlinerunner/PropertiesTests.java +++ b/boot/tcf/src/test/java/com/example/boot/tcf/PropertiesTests.java @@ -1,4 +1,4 @@ -package com.example.commandlinerunner; +package com.example.boot.tcf; import org.junit.jupiter.api.Test;