diff --git a/ci/smoke-tests.yml b/ci/smoke-tests.yml index bc12bab7..99fd55fb 100644 --- a/ci/smoke-tests.yml +++ b/ci/smoke-tests.yml @@ -30,6 +30,7 @@ smoke_tests: - event-listener - flyway - freemarker-webflux + - freemarker-webmvc - hateoas - jdbc - liquibase diff --git a/freemarker-webmvc/README.adoc b/freemarker-webmvc/README.adoc new file mode 100644 index 00000000..f4f5eb2b --- /dev/null +++ b/freemarker-webmvc/README.adoc @@ -0,0 +1 @@ +Tests if Freemarker view rendering works with WebMVC diff --git a/freemarker-webmvc/build.gradle b/freemarker-webmvc/build.gradle new file mode 100644 index 00000000..efa55e38 --- /dev/null +++ b/freemarker-webmvc/build.gradle @@ -0,0 +1,21 @@ +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-web") + implementation("org.springframework.boot:spring-boot-starter-freemarker") + + testImplementation("org.springframework.boot:spring-boot-starter-test") + + aotTestImplementation(project(":aot-smoke-test-support")) + aotTestImplementation("org.awaitility:awaitility:4.2.0") +} + +aotSmokeTest { + webApplication = true +} diff --git a/freemarker-webmvc/src/aotTest/java/com/example/freemarker/webmvc/FreemarkerWebMvcApplicationAotTests.java b/freemarker-webmvc/src/aotTest/java/com/example/freemarker/webmvc/FreemarkerWebMvcApplicationAotTests.java new file mode 100644 index 00000000..10c384b1 --- /dev/null +++ b/freemarker-webmvc/src/aotTest/java/com/example/freemarker/webmvc/FreemarkerWebMvcApplicationAotTests.java @@ -0,0 +1,26 @@ +package com.example.freemarker.webmvc; + +import org.junit.jupiter.api.Test; + +import org.springframework.aot.smoketest.support.junit.AotSmokeTest; +import org.springframework.test.web.reactive.server.WebTestClient; + +import static org.assertj.core.api.Assertions.assertThat; + +@AotSmokeTest +class FreemarkerWebMvcApplicationAotTests { + + @Test + void greetingIsRendered(WebTestClient client) { + client.get().uri("/greeting").exchange().expectStatus().isOk().expectBody().consumeWith( + (result) -> assertThat(new String(result.getResponseBodyContent())).contains("Hello world")); + } + + @Test + void authorListIsRendered(WebTestClient client) { + client.get().uri("/authors").exchange().expectStatus().isOk().expectBody() + .consumeWith((result) -> assertThat(new String(result.getResponseBodyContent())) + .contains("
+ ${model.greeting()} ${model.name()} +
+ + + + diff --git a/freemarker-webmvc/src/test/java/com/example/freemarker/webmvc/FreemarkerWebMvcApplicationTests.java b/freemarker-webmvc/src/test/java/com/example/freemarker/webmvc/FreemarkerWebMvcApplicationTests.java new file mode 100644 index 00000000..7979eb81 --- /dev/null +++ b/freemarker-webmvc/src/test/java/com/example/freemarker/webmvc/FreemarkerWebMvcApplicationTests.java @@ -0,0 +1,14 @@ +package com.example.freemarker.webmvc; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class FreemarkerWebMvcApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/settings.gradle b/settings.gradle index 3a49f68e..e3e30fa6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -58,6 +58,7 @@ include "data-rest-mongodb" include "event-listener" include "flyway" include "freemarker-webflux" +include "freemarker-webmvc" include "hateoas" include "jdbc" include "liquibase"