Using Spring Text Context Caching
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.yam.app;
|
package com.yam.app;
|
||||||
|
|
||||||
|
import static com.tngtech.archunit.base.DescribedPredicate.alwaysTrue;
|
||||||
|
import static com.tngtech.archunit.core.domain.properties.HasName.AndFullName.Predicates.fullNameMatching;
|
||||||
import static com.tngtech.archunit.library.Architectures.layeredArchitecture;
|
import static com.tngtech.archunit.library.Architectures.layeredArchitecture;
|
||||||
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
|
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
|
||||||
|
|
||||||
@@ -12,7 +14,9 @@ final class ArchUnitTests {
|
|||||||
|
|
||||||
@ArchTest
|
@ArchTest
|
||||||
ArchRule cycleCheck = slices().matching("com.yam.app.(*)..")
|
ArchRule cycleCheck = slices().matching("com.yam.app.(*)..")
|
||||||
.should().beFreeOfCycles();
|
.should().beFreeOfCycles()
|
||||||
|
.ignoreDependency(
|
||||||
|
fullNameMatching("com.yam.app.extension.WebApiTestExtension"), alwaysTrue());
|
||||||
|
|
||||||
@ArchTest
|
@ArchTest
|
||||||
ArchRule layerCheck = layeredArchitecture()
|
ArchRule layerCheck = layeredArchitecture()
|
||||||
@@ -28,5 +32,7 @@ final class ArchUnitTests {
|
|||||||
.whereLayer("Domain").mayOnlyBeAccessedByLayers("Application", "Infrastructure", "Adapter")
|
.whereLayer("Domain").mayOnlyBeAccessedByLayers("Application", "Infrastructure", "Adapter")
|
||||||
.whereLayer("Infrastructure").mayOnlyBeAccessedByLayers("Presentation", "Integration")
|
.whereLayer("Infrastructure").mayOnlyBeAccessedByLayers("Presentation", "Integration")
|
||||||
.whereLayer("Adapter").mayNotBeAccessedByAnyLayer()
|
.whereLayer("Adapter").mayNotBeAccessedByAnyLayer()
|
||||||
.whereLayer("Integration").mayNotBeAccessedByAnyLayer();
|
.whereLayer("Integration").mayNotBeAccessedByAnyLayer()
|
||||||
|
.ignoreDependency(
|
||||||
|
fullNameMatching("com.yam.app.extension.WebApiTestExtension"), alwaysTrue());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.yam.app.extension.WebApiTestExtension;
|
||||||
import com.yam.app.account.application.AccountFacade;
|
|
||||||
import org.javaunit.autoparams.AutoSource;
|
import org.javaunit.autoparams.AutoSource;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
@@ -22,34 +21,11 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
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.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.mock.web.MockHttpSession;
|
import org.springframework.mock.web.MockHttpSession;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
|
||||||
import org.springframework.test.web.servlet.ResultActions;
|
|
||||||
|
|
||||||
@DisplayName("Account Command HTTP API")
|
@DisplayName("Account Command HTTP API")
|
||||||
@WebMvcTest(AccountCommandApi.class)
|
final class AccountCommandApiTests extends WebApiTestExtension {
|
||||||
@ActiveProfiles("test")
|
|
||||||
final class AccountCommandApiTests {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MockMvc mockMvc;
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
@MockBean
|
|
||||||
private AccountFacade accountFacade;
|
|
||||||
|
|
||||||
private void assertThatInvalidArgumentError(ResultActions actions) throws Exception {
|
|
||||||
actions
|
|
||||||
.andExpect(status().isBadRequest())
|
|
||||||
.andExpect(jsonPath("$.success").value(false))
|
|
||||||
.andExpect(jsonPath("$.data").doesNotExist())
|
|
||||||
.andExpect(jsonPath("$.message").value("Invalid argument"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@DisplayName("회원 정보 수정 HTTP API")
|
@DisplayName("회원 정보 수정 HTTP API")
|
||||||
|
|||||||
@@ -5,27 +5,15 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import com.yam.app.account.application.AccountFacade;
|
import com.yam.app.extension.WebApiTestExtension;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
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.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.mock.web.MockHttpSession;
|
import org.springframework.mock.web.MockHttpSession;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
|
||||||
|
|
||||||
@DisplayName("Account Query HTTP API")
|
@DisplayName("Account Query HTTP API")
|
||||||
@WebMvcTest(AccountQueryApi.class)
|
class AccountQueryApiTest extends WebApiTestExtension {
|
||||||
@ActiveProfiles("test")
|
|
||||||
class AccountQueryApiTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MockMvc mockMvc;
|
|
||||||
@MockBean
|
|
||||||
private AccountFacade accountFacade;
|
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@DisplayName("사용자 조회 HTTP API")
|
@DisplayName("사용자 조회 HTTP API")
|
||||||
|
|||||||
@@ -5,42 +5,18 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.yam.app.extension.WebApiTestExtension;
|
||||||
import com.yam.app.article.application.ArticleFacade;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.javaunit.autoparams.AutoSource;
|
import org.javaunit.autoparams.AutoSource;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
||||||
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.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.mock.web.MockHttpSession;
|
import org.springframework.mock.web.MockHttpSession;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
|
||||||
import org.springframework.test.web.servlet.ResultActions;
|
|
||||||
|
|
||||||
@DisplayName("Article Command HTTP API")
|
@DisplayName("Article Command HTTP API")
|
||||||
@WebMvcTest(ArticleCommandApi.class)
|
final class ArticleCommandApiTests extends WebApiTestExtension {
|
||||||
@ActiveProfiles("test")
|
|
||||||
final class ArticleCommandApiTests {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MockMvc mockMvc;
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
@MockBean
|
|
||||||
private ArticleFacade articleFacade;
|
|
||||||
|
|
||||||
private void assertThatInvalidArgumentError(ResultActions actions) throws Exception {
|
|
||||||
actions
|
|
||||||
.andExpect(status().isBadRequest())
|
|
||||||
.andExpect(jsonPath("$.success").value(false))
|
|
||||||
.andExpect(jsonPath("$.data").doesNotExist())
|
|
||||||
.andExpect(jsonPath("$.message").value("Invalid argument"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@DisplayName("게시글 작성 HTTP API")
|
@DisplayName("게시글 작성 HTTP API")
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.yam.app.extension.WebApiTestExtension;
|
||||||
import com.yam.app.comment.application.CommentFacade;
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.javaunit.autoparams.AutoSource;
|
import org.javaunit.autoparams.AutoSource;
|
||||||
import org.javaunit.autoparams.customization.Customization;
|
import org.javaunit.autoparams.customization.Customization;
|
||||||
@@ -20,25 +19,11 @@ import org.junit.jupiter.api.Nested;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
||||||
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.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.mock.web.MockHttpSession;
|
import org.springframework.mock.web.MockHttpSession;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
|
||||||
|
|
||||||
@DisplayName("Comment Command HTTP API")
|
@DisplayName("Comment Command HTTP API")
|
||||||
@WebMvcTest(CommentCommandApi.class)
|
final class CommentCommandApiTest extends WebApiTestExtension {
|
||||||
@ActiveProfiles("test")
|
|
||||||
final class CommentCommandApiTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MockMvc mockMvc;
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
@MockBean
|
|
||||||
private CommentFacade commentFacade;
|
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@DisplayName("댓글 작성 HTTP API")
|
@DisplayName("댓글 작성 HTTP API")
|
||||||
|
|||||||
50
src/test/java/com/yam/app/extension/WebApiTestExtension.java
Normal file
50
src/test/java/com/yam/app/extension/WebApiTestExtension.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package com.yam.app.extension;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.yam.app.account.application.AccountFacade;
|
||||||
|
import com.yam.app.account.presentation.AccountCommandApi;
|
||||||
|
import com.yam.app.account.presentation.AccountQueryApi;
|
||||||
|
import com.yam.app.article.application.ArticleFacade;
|
||||||
|
import com.yam.app.article.presentation.ArticleCommandApi;
|
||||||
|
import com.yam.app.comment.application.CommentFacade;
|
||||||
|
import com.yam.app.comment.presentation.CommentCommandApi;
|
||||||
|
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.test.context.ActiveProfiles;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.ResultActions;
|
||||||
|
|
||||||
|
@ActiveProfiles("test")
|
||||||
|
@WebMvcTest(
|
||||||
|
value = {
|
||||||
|
AccountCommandApi.class,
|
||||||
|
AccountQueryApi.class,
|
||||||
|
ArticleCommandApi.class,
|
||||||
|
CommentCommandApi.class
|
||||||
|
}
|
||||||
|
)
|
||||||
|
public class WebApiTestExtension {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected MockMvc mockMvc;
|
||||||
|
@Autowired
|
||||||
|
protected ObjectMapper objectMapper;
|
||||||
|
@MockBean
|
||||||
|
protected AccountFacade accountFacade;
|
||||||
|
@MockBean
|
||||||
|
protected CommentFacade commentFacade;
|
||||||
|
@MockBean
|
||||||
|
protected ArticleFacade articleFacade;
|
||||||
|
|
||||||
|
protected void assertThatInvalidArgumentError(ResultActions actions) throws Exception {
|
||||||
|
actions
|
||||||
|
.andExpect(status().isBadRequest())
|
||||||
|
.andExpect(jsonPath("$.success").value(false))
|
||||||
|
.andExpect(jsonPath("$.data").doesNotExist())
|
||||||
|
.andExpect(jsonPath("$.message").value("Invalid argument"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user