From b659fcdc5434da1788a53415ba5a172545a92b3d Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Thu, 5 Dec 2024 07:16:35 +0000 Subject: [PATCH] feat : upgrade postgres to latest version --- boot-api-archunit-sample/docker/docker-compose.yml | 2 +- .../{Application.java => ArchUnitApplication.java} | 4 ++-- .../com/example/archunit/SchemaValidationTest.java | 4 +++- .../java/com/example/archunit/TestApplication.java | 12 ------------ .../example/archunit/TestArchUnitApplication.java | 14 ++++++++++++++ .../example/archunit/common/ContainersConfig.java | 2 +- .../web/controllers/ClientControllerTest.java | 4 ++-- 7 files changed, 23 insertions(+), 19 deletions(-) rename boot-api-archunit-sample/src/main/java/com/example/archunit/{Application.java => ArchUnitApplication.java} (81%) delete mode 100644 boot-api-archunit-sample/src/test/java/com/example/archunit/TestApplication.java create mode 100644 boot-api-archunit-sample/src/test/java/com/example/archunit/TestArchUnitApplication.java diff --git a/boot-api-archunit-sample/docker/docker-compose.yml b/boot-api-archunit-sample/docker/docker-compose.yml index 044fd99d9..1ffcd3f6f 100644 --- a/boot-api-archunit-sample/docker/docker-compose.yml +++ b/boot-api-archunit-sample/docker/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.8' services: postgresqldb: - image: postgres:16.6-alpine + image: postgres:17.2-alpine environment: - POSTGRES_USER=appuser - POSTGRES_PASSWORD=secret diff --git a/boot-api-archunit-sample/src/main/java/com/example/archunit/Application.java b/boot-api-archunit-sample/src/main/java/com/example/archunit/ArchUnitApplication.java similarity index 81% rename from boot-api-archunit-sample/src/main/java/com/example/archunit/Application.java rename to boot-api-archunit-sample/src/main/java/com/example/archunit/ArchUnitApplication.java index b986540c2..52d7b60df 100644 --- a/boot-api-archunit-sample/src/main/java/com/example/archunit/Application.java +++ b/boot-api-archunit-sample/src/main/java/com/example/archunit/ArchUnitApplication.java @@ -7,9 +7,9 @@ @SpringBootApplication @EnableConfigurationProperties({ApplicationProperties.class}) -public class Application { +public class ArchUnitApplication { public static void main(String[] args) { - SpringApplication.run(Application.class, args); + SpringApplication.run(ArchUnitApplication.class, args); } } diff --git a/boot-api-archunit-sample/src/test/java/com/example/archunit/SchemaValidationTest.java b/boot-api-archunit-sample/src/test/java/com/example/archunit/SchemaValidationTest.java index 0a7e1448d..ecf6d971b 100644 --- a/boot-api-archunit-sample/src/test/java/com/example/archunit/SchemaValidationTest.java +++ b/boot-api-archunit-sample/src/test/java/com/example/archunit/SchemaValidationTest.java @@ -7,11 +7,13 @@ import javax.sql.DataSource; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.Import; -@DataJpaTest(properties = {"spring.jpa.hibernate.ddl-auto=validate", "spring.test.database.replace=none"}) +@DataJpaTest(properties = {"spring.jpa.hibernate.ddl-auto=validate"}) @Import(ContainersConfig.class) +@AutoConfigureTestDatabase class SchemaValidationTest { @Autowired diff --git a/boot-api-archunit-sample/src/test/java/com/example/archunit/TestApplication.java b/boot-api-archunit-sample/src/test/java/com/example/archunit/TestApplication.java deleted file mode 100644 index 061fdbdc6..000000000 --- a/boot-api-archunit-sample/src/test/java/com/example/archunit/TestApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.archunit; - -import com.example.archunit.common.ContainersConfig; -import org.springframework.boot.SpringApplication; - -public class TestApplication { - - public static void main(String[] args) { - System.setProperty("spring.profiles.active", "local"); - SpringApplication.from(Application::main).with(ContainersConfig.class).run(args); - } -} diff --git a/boot-api-archunit-sample/src/test/java/com/example/archunit/TestArchUnitApplication.java b/boot-api-archunit-sample/src/test/java/com/example/archunit/TestArchUnitApplication.java new file mode 100644 index 000000000..67460f880 --- /dev/null +++ b/boot-api-archunit-sample/src/test/java/com/example/archunit/TestArchUnitApplication.java @@ -0,0 +1,14 @@ +package com.example.archunit; + +import com.example.archunit.common.ContainersConfig; +import org.springframework.boot.SpringApplication; + +public class TestArchUnitApplication { + + public static void main(String[] args) { + SpringApplication.from(ArchUnitApplication::main) + .with(ContainersConfig.class) + .withAdditionalProfiles("local") + .run(args); + } +} diff --git a/boot-api-archunit-sample/src/test/java/com/example/archunit/common/ContainersConfig.java b/boot-api-archunit-sample/src/test/java/com/example/archunit/common/ContainersConfig.java index 3d39e0b43..c7db3a55b 100644 --- a/boot-api-archunit-sample/src/test/java/com/example/archunit/common/ContainersConfig.java +++ b/boot-api-archunit-sample/src/test/java/com/example/archunit/common/ContainersConfig.java @@ -12,6 +12,6 @@ public class ContainersConfig { @Bean @ServiceConnection PostgreSQLContainer postgreSQLContainer() { - return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("16.3-alpine")); + return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.2-alpine")); } } diff --git a/boot-api-archunit-sample/src/test/java/com/example/archunit/web/controllers/ClientControllerTest.java b/boot-api-archunit-sample/src/test/java/com/example/archunit/web/controllers/ClientControllerTest.java index fba073c21..88ad11eb0 100644 --- a/boot-api-archunit-sample/src/test/java/com/example/archunit/web/controllers/ClientControllerTest.java +++ b/boot-api-archunit-sample/src/test/java/com/example/archunit/web/controllers/ClientControllerTest.java @@ -31,12 +31,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; @WebMvcTest(controllers = ClientController.class) @@ -46,7 +46,7 @@ class ClientControllerTest { @Autowired private MockMvc mockMvc; - @MockBean + @MockitoBean private ClientService clientService; @Autowired