From 5c94a139129912b317cb8d84d9097d31336c504f Mon Sep 17 00:00:00 2001 From: mperor Date: Fri, 21 Feb 2025 11:52:49 +0100 Subject: [PATCH] Setup project for Spring Web Lab & verify actuator --- README.md | 1 + pom.xml | 1 + spring-web-lab/README.md | 5 +++ spring-web-lab/pom.xml | 35 +++++++++++++++++++ .../lab/spring/SpringWebLabApplication.java | 13 +++++++ .../src/main/resources/application.yml | 9 +++++ .../spring/SpringWebLabApplicationTest.java | 30 ++++++++++++++++ 7 files changed, 94 insertions(+) create mode 100644 spring-web-lab/README.md create mode 100644 spring-web-lab/pom.xml create mode 100644 spring-web-lab/src/main/java/pl/mperor/lab/spring/SpringWebLabApplication.java create mode 100644 spring-web-lab/src/main/resources/application.yml create mode 100644 spring-web-lab/src/test/java/pl/mperor/lab/spring/SpringWebLabApplicationTest.java diff --git a/README.md b/README.md index b62dfd2..6ea1d1a 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ ## Modules 🗂️ - **[spring-core-lab](spring-core-lab): Spring Core 🌱** +- **[spring-web-lab](spring-web-lab): Spring Web 🌐** - **[spring-data-jpa-lab](spring-data-jpa-lab): Spring Data JPA 💾** - **[spring-security-lab](spring-security-lab): Spring Security 🔐** diff --git a/pom.xml b/pom.xml index 02ff438..cff70b8 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ spring-core-lab spring-data-jpa-lab spring-security-lab + spring-web-lab diff --git a/spring-web-lab/README.md b/spring-web-lab/README.md new file mode 100644 index 0000000..45022aa --- /dev/null +++ b/spring-web-lab/README.md @@ -0,0 +1,5 @@ +# Spring Web Lab 🌐 + +## Sources 🔗 + +* [Java Senior Quiz 🧩](https://youtube.com/playlist?list=PLO5muTI694A5yRrEDNY1czqEUVbYHG_AH&si=KteWFowVcOSTQ8F-) \ No newline at end of file diff --git a/spring-web-lab/pom.xml b/spring-web-lab/pom.xml new file mode 100644 index 0000000..c38cda5 --- /dev/null +++ b/spring-web-lab/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + pl.mperor.lab.spring + spring-lab + 0.0.1-SNAPSHOT + + + spring-web-lab + + + 23 + 23 + UTF-8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-webflux + + + + \ No newline at end of file diff --git a/spring-web-lab/src/main/java/pl/mperor/lab/spring/SpringWebLabApplication.java b/spring-web-lab/src/main/java/pl/mperor/lab/spring/SpringWebLabApplication.java new file mode 100644 index 0000000..d01df30 --- /dev/null +++ b/spring-web-lab/src/main/java/pl/mperor/lab/spring/SpringWebLabApplication.java @@ -0,0 +1,13 @@ +package pl.mperor.lab.spring; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringWebLabApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringWebLabApplication.class, args); + } + +} diff --git a/spring-web-lab/src/main/resources/application.yml b/spring-web-lab/src/main/resources/application.yml new file mode 100644 index 0000000..ec0d75f --- /dev/null +++ b/spring-web-lab/src/main/resources/application.yml @@ -0,0 +1,9 @@ +#management: +# endpoints: +# web: +# exposure: +# include: "*" + +#logging: +# level: +# org.springframework.boot.actuate: DEBUG \ No newline at end of file diff --git a/spring-web-lab/src/test/java/pl/mperor/lab/spring/SpringWebLabApplicationTest.java b/spring-web-lab/src/test/java/pl/mperor/lab/spring/SpringWebLabApplicationTest.java new file mode 100644 index 0000000..c1d4648 --- /dev/null +++ b/spring-web-lab/src/test/java/pl/mperor/lab/spring/SpringWebLabApplicationTest.java @@ -0,0 +1,30 @@ +package pl.mperor.lab.spring; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpStatus; +import org.springframework.test.web.reactive.server.WebTestClient; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureWebTestClient +public class SpringWebLabApplicationTest { + + @Autowired + private WebTestClient client; + + @Test + public void contextLoads() { + } + + @Test + public void shouldReturnHealthStatusUp() { + client.get().uri("/actuator/health") + .exchange() + .expectStatus().isEqualTo(HttpStatus.OK) + .expectBody() + .jsonPath("$.status").isEqualTo("UP"); + } + +} \ No newline at end of file