From 5f7fbc1d4ba3eb0e8ff00668795eefc2fd885fa9 Mon Sep 17 00:00:00 2001 From: dmori Date: Sat, 27 Dec 2025 11:18:37 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20=EC=8A=A4=ED=94=84=EB=A7=81?= =?UTF-8?q?=EB=B6=80=ED=8A=B8=20=EB=B2=84=EC=A0=84=20stable=20=EB=B2=84?= =?UTF-8?q?=EC=A0=84=EC=9D=B8=203.5.9=EB=A1=9C=20=EC=97=85=EA=B7=B8?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EB=93=9C=20=EB=B0=8F=20=EC=8A=A4=ED=94=84?= =?UTF-8?q?=EB=A7=81=EB=B6=80=ED=8A=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 6 +++--- src/test/resources/application-integrationtest.yml | 0 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/application-integrationtest.yml diff --git a/build.gradle b/build.gradle index 5375948..d77a5b1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.5.6' + id 'org.springframework.boot' version '3.5.9' id 'io.spring.dependency-management' version '1.1.7' } @@ -35,8 +35,8 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' - // Testcontainers for integration tests - testImplementation 'org.testcontainers:testcontainers:1.19.3' + // Test Containers + testImplementation 'org.springframework.boot:spring-boot-testcontainers' testImplementation 'org.testcontainers:mysql:1.19.3' testImplementation 'org.testcontainers:junit-jupiter:1.19.3' diff --git a/src/test/resources/application-integrationtest.yml b/src/test/resources/application-integrationtest.yml new file mode 100644 index 0000000..e69de29 From 2c09ea3897be3ad87d3847ce63d4419dbe1d3748 Mon Sep 17 00:00:00 2001 From: dmori Date: Sat, 27 Dec 2025 11:19:42 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20DynamicProperties=20=EB=8C=80?= =?UTF-8?q?=EC=8B=A0=20ServiceConnection=EC=9C=BC=EB=A1=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=A3=BC=EC=9E=85,=20Transactional=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EB=8C=80=EC=8B=A0=20Aft?= =?UTF-8?q?erEach=EB=A1=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PostControllerIntegrationTest.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/techfork/domain/post/controller/PostControllerIntegrationTest.java b/src/test/java/com/techfork/domain/post/controller/PostControllerIntegrationTest.java index 12d02dd..d2b2ad4 100644 --- a/src/test/java/com/techfork/domain/post/controller/PostControllerIntegrationTest.java +++ b/src/test/java/com/techfork/domain/post/controller/PostControllerIntegrationTest.java @@ -6,16 +6,16 @@ import com.techfork.domain.post.repository.PostRepository; import com.techfork.domain.source.entity.TechBlog; import com.techfork.domain.source.repository.TechBlogRepository; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; import org.testcontainers.containers.MySQLContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -37,22 +37,13 @@ */ @SpringBootTest @AutoConfigureMockMvc -@Transactional @Testcontainers +@ActiveProfiles("integrationtest") class PostControllerIntegrationTest { @Container - static MySQLContainer mysql = new MySQLContainer<>("mysql:8.0") - .withDatabaseName("testdb") - .withUsername("test") - .withPassword("test"); - - @DynamicPropertySource - static void configureProperties(DynamicPropertyRegistry registry) { - registry.add("spring.datasource.url", mysql::getJdbcUrl); - registry.add("spring.datasource.username", mysql::getUsername); - registry.add("spring.datasource.password", mysql::getPassword); - } + @ServiceConnection + static MySQLContainer mysql = new MySQLContainer<>("mysql:8.0"); @Autowired private MockMvc mockMvc; @@ -113,6 +104,14 @@ void setUp() { postKeywordRepository.save(keyword3); } + @AfterEach + void tearDown() { + // 테스트 데이터 정리 (외래키 제약조건 순서 고려) + postKeywordRepository.deleteAll(); + postRepository.deleteAll(); + techBlogRepository.deleteAll(); + } + @Test @DisplayName("GET /api/v1/posts/{postId} - 게시글 상세 조회 성공") void getPostDetail_Success() throws Exception { From 18eafaf4970694209dfcc605b4fdd9097d587b83 Mon Sep 17 00:00:00 2001 From: dmori Date: Sat, 27 Dec 2025 11:20:59 +0900 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20=ED=86=B5=ED=95=A9=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A0=84=EC=9A=A9=20yml=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/application-integrationtest.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/test/resources/application-integrationtest.yml b/src/test/resources/application-integrationtest.yml index e69de29..b49f6f6 100644 --- a/src/test/resources/application-integrationtest.yml +++ b/src/test/resources/application-integrationtest.yml @@ -0,0 +1,39 @@ +spring: + jpa: + hibernate: + ddl-auto: create-drop + properties: + hibernate: + format_sql: true + highlight_sql: true + dialect: org.hibernate.dialect.MySQL8Dialect + + batch: + jdbc: + initialize-schema: always + job: + names: '' + + ai: + anthropic: + api-key: test-dummy-key + chat: + options: + model: claude-3-5-haiku-20241022 + temperature: 0.3 + max-tokens: 8192 + openai: + api-key: test-dummy-key + timeout: 60 + chat: + options: + model: gpt-4o-mini + temperature: 0.3 + max-tokens: 8192 + +logging: + level: + com.techfork: DEBUG + org.springframework.batch: INFO + org.hibernate.SQL: DEBUG + org.hibernate.tool.schema: ERROR From 9d996685fca5f19aac0bc6068c739ee3dcc9ae28 Mon Sep 17 00:00:00 2001 From: dmori Date: Sat, 27 Dec 2025 11:21:23 +0900 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EA=B0=80=20=EC=95=84=EB=8B=8C=20=EC=9D=BC=EB=B0=98=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EC=97=90=EC=84=9C=EB=A7=8C=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=82=BD=EC=9E=85=EC=9D=B4=20?= =?UTF-8?q?=EC=9D=BC=EC=96=B4=EB=82=98=EB=8F=84=EB=A1=9D=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/techfork/global/config/InitialDataConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/techfork/global/config/InitialDataConfig.java b/src/main/java/com/techfork/global/config/InitialDataConfig.java index ac3e791..1ac1de0 100644 --- a/src/main/java/com/techfork/global/config/InitialDataConfig.java +++ b/src/main/java/com/techfork/global/config/InitialDataConfig.java @@ -7,12 +7,14 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import java.util.List; @Slf4j @Configuration @RequiredArgsConstructor +@Profile({"local", "local-tunnel", "dev"}) public class InitialDataConfig { private final TechBlogRepository techBlogRepository;