diff --git a/jpa/multitenancy/multidatasource-multitenancy/pom.xml b/jpa/multitenancy/multidatasource-multitenancy/pom.xml index 9c460fd6c..4e49b7a39 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/pom.xml +++ b/jpa/multitenancy/multidatasource-multitenancy/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.6 + 3.2.0 com.example.multitenancy @@ -103,11 +103,6 @@ spring-boot-testcontainers test - - org.awaitility - awaitility - test - org.testcontainers junit-jupiter @@ -120,7 +115,7 @@ org.testcontainers - oracle-xe + oracle-free test diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/AbstractIntegrationTest.java b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/AbstractIntegrationTest.java index b1d20886c..742fd1794 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/AbstractIntegrationTest.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/AbstractIntegrationTest.java @@ -3,6 +3,9 @@ import static com.example.multitenancy.utils.AppConstants.PROFILE_TEST; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; +import com.example.multitenancy.config.multitenant.TenantIdentifierResolver; +import com.example.multitenancy.primary.repositories.PrimaryCustomerRepository; +import com.example.multitenancy.secondary.repositories.SecondaryCustomerRepository; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -18,4 +21,9 @@ public abstract class AbstractIntegrationTest extends DBContainerInitializer { @Autowired protected MockMvc mockMvc; @Autowired protected ObjectMapper objectMapper; + + @Autowired protected PrimaryCustomerRepository primaryCustomerRepository; + @Autowired protected SecondaryCustomerRepository secondaryCustomerRepository; + + @Autowired protected TenantIdentifierResolver tenantIdentifierResolver; } diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/DBContainerInitializer.java b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/DBContainerInitializer.java index ae2f376df..f188cd98b 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/DBContainerInitializer.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/DBContainerInitializer.java @@ -2,10 +2,10 @@ import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; -import org.testcontainers.containers.OracleContainer; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.oracle.OracleContainer; import org.testcontainers.utility.DockerImageName; @Testcontainers(disabledWithoutDocker = true, parallel = true) @@ -13,12 +13,14 @@ public class DBContainerInitializer { @Container private static final PostgreSQLContainer POSTGRE_SQL_CONTAINER = - new PostgreSQLContainer<>("postgres:16.1-alpine"); + new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("16.1-alpine")); @Container private static final OracleContainer ORACLE_CONTAINER = new OracleContainer( - DockerImageName.parse("gvenzl/oracle-xe").withTag("slim-faststart")); + DockerImageName.parse("gvenzl/oracle-free") + .withTag("23-slim-faststart")) + .withReuse(true); @DynamicPropertySource static void addsDynamicProperties(DynamicPropertyRegistry propertyRegistry) { diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/web/controllers/PrimaryCustomerControllerIT.java b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/web/controllers/PrimaryCustomerControllerIT.java index fee3e064d..94ccff726 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/web/controllers/PrimaryCustomerControllerIT.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/web/controllers/PrimaryCustomerControllerIT.java @@ -12,21 +12,15 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.example.multitenancy.common.AbstractIntegrationTest; -import com.example.multitenancy.config.multitenant.TenantIdentifierResolver; import com.example.multitenancy.primary.entities.PrimaryCustomer; -import com.example.multitenancy.primary.repositories.PrimaryCustomerRepository; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; class PrimaryCustomerControllerIT extends AbstractIntegrationTest { - @Autowired private PrimaryCustomerRepository primaryCustomerRepository; - @Autowired private TenantIdentifierResolver tenantIdentifierResolver; - private List primaryCustomerList = null; @BeforeEach diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/web/controllers/SecondaryCustomerControllerIT.java b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/web/controllers/SecondaryCustomerControllerIT.java index a3362baec..4692efd00 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/web/controllers/SecondaryCustomerControllerIT.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/web/controllers/SecondaryCustomerControllerIT.java @@ -7,21 +7,15 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import com.example.multitenancy.common.AbstractIntegrationTest; -import com.example.multitenancy.config.multitenant.TenantIdentifierResolver; import com.example.multitenancy.secondary.entities.SecondaryCustomer; -import com.example.multitenancy.secondary.repositories.SecondaryCustomerRepository; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; class SecondaryCustomerControllerIT extends AbstractIntegrationTest { - @Autowired private SecondaryCustomerRepository secondaryCustomerRepository; - @Autowired private TenantIdentifierResolver tenantIdentifierResolver; - private List secondaryCustomerList = null; @BeforeEach