Skip to content

Commit 6b9a895

Browse files
committed
Completed task 2
1 parent 42bf3ef commit 6b9a895

File tree

5 files changed

+508
-26
lines changed

5 files changed

+508
-26
lines changed

examples/spring-boot-demo/implementation/README-DEV.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
./mvnw clean package
1818

1919
# Run integration tests
20-
./mvnw verify
20+
./mvnw clean verify
2121

2222
# Check for dependency updates
2323
./mvnw versions:display-property-updates

examples/spring-boot-demo/implementation/src/test/java/com/example/demo/DemoApplicationTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
package com.example.demo;
22

3+
import org.springframework.test.context.DynamicPropertyRegistry;
4+
import org.springframework.test.context.DynamicPropertySource;
5+
import org.testcontainers.containers.PostgreSQLContainer;
6+
import org.testcontainers.junit.jupiter.Container;
7+
import org.testcontainers.junit.jupiter.Testcontainers;
38
import org.junit.jupiter.api.Test;
49
import org.springframework.boot.test.context.SpringBootTest;
510
import org.springframework.test.context.ActiveProfiles;
611

712
@SpringBootTest
13+
@Testcontainers
814
@ActiveProfiles("test")
915
class DemoApplicationTests {
1016

17+
@Container
18+
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15")
19+
.withDatabaseName("sakila")
20+
.withUsername("sakila")
21+
.withPassword("sakila");
22+
// Note: Database schema and init script will be added in subsequent tasks (2.2, 2.9)
23+
24+
@DynamicPropertySource
25+
static void configureProperties(DynamicPropertyRegistry registry) {
26+
registry.add("spring.datasource.url", postgres::getJdbcUrl);
27+
registry.add("spring.datasource.username", postgres::getUsername);
28+
registry.add("spring.datasource.password", postgres::getPassword);
29+
}
30+
1131
@Test
1232
void contextLoads() {
1333
// This test will load the Spring context without requiring database connection

0 commit comments

Comments
 (0)