토비의 스프링 스터디를 진행하며 2장에서 더 알아보고 싶은 내용으로 위와 같은 주제를 정했다.
이제부터 자세히 알아보자!
@BeforeEach public void setUp() throws Exception { this.webRequest = new ServletWebRequest(new MockHttpServletRequest()); this.attributeStore = new DefaultSessionAttributeStore(); this.attributeHandler = new SessionAttributesHandler(TestController.class, this.attributeStore); this.controller = new TestController(); this.mavContainer = new ModelAndViewContainer(); }
@BeforeEach void setUp() { when(eventLoop.inEventLoop()).thenReturn(true); doAnswer((Answer<Void>) invocation -> { invocation.<Runnable>getArgument(0).run(); return null; }).when(eventLoop).execute(any()); ctx = ServiceRequestContext.builder(HttpRequest.of(HttpMethod.GET, "/")) .eventLoop(eventLoop) .build(); }
@BeforeEach public void setUp() { this.context.setForceQuote(false); this.sqlGenerator = createSqlGenerator(DummyEntity.class); }
참고링크
[자바와 JUnit을 활용한 실용주의 단위 테스트]
https://junit.org/junit5/docs/current/user-guide/
https://jojoldu.tistory.com/611
https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java
https://github.com/line/armeria/blob/master/core/src/test/java/com/linecorp/armeria/client/BlockingWebClientTest.java
https://github.com/naver/spring-jdbc-plus/blob/master/spring-data-jdbc-plus-sql/src/test/java/com/navercorp/spring/data/jdbc/plus/sql/convert/SqlGeneratorEmbeddedTest.java