diff --git a/jpa/boot-hibernate2ndlevelcache-sample/pom.xml b/jpa/boot-hibernate2ndlevelcache-sample/pom.xml index f508ee5a6..f51293dc8 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/pom.xml +++ b/jpa/boot-hibernate2ndlevelcache-sample/pom.xml @@ -135,6 +135,11 @@ spring-boot-starter-test test + + org.springframework.boot + spring-boot-testcontainers + test + org.awaitility awaitility diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java new file mode 100644 index 000000000..fdf1bf3fd --- /dev/null +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java @@ -0,0 +1,15 @@ +package com.example.hibernatecache; + +import com.example.hibernatecache.common.TestContainersConfig; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.testcontainers.context.ImportTestcontainers; + +@TestConfiguration(proxyBeanMethods = false) +@ImportTestcontainers(TestContainersConfig.class) +class TestApplication { + + public static void main(String[] args) { + SpringApplication.from(Application::main).with(TestApplication.class).run(args); + } +} diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/common/TestContainersConfig.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/common/TestContainersConfig.java new file mode 100644 index 000000000..e60b39a7b --- /dev/null +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/common/TestContainersConfig.java @@ -0,0 +1,10 @@ +package com.example.hibernatecache.common; + +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.testcontainers.containers.PostgreSQLContainer; + +public interface TestContainersConfig { + + @ServiceConnection + PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer<>("postgres:16.0-alpine"); +} diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/OrderControllerIT.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/OrderControllerIT.java index 4e3ca6b44..45a2a0b52 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/OrderControllerIT.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/OrderControllerIT.java @@ -122,7 +122,10 @@ void shouldReturn400WhenCreateNewOrderWithoutName() throws Exception { .andExpect(jsonPath("$.violations[0].field", is("name"))) .andExpect(jsonPath("$.violations[0].message", is("Name cannot be blank"))) .andExpect(jsonPath("$.violations[1].field", is("price"))) - .andExpect(jsonPath("$.violations[1].message", is("Value must be greater than or equal to 0.01"))) + .andExpect( + jsonPath( + "$.violations[1].message", + is("Value must be greater than or equal to 0.01"))) .andReturn(); }