Skip to content

Commit

Permalink
test: 테스트 케이스 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
BGuga committed Sep 12, 2023
1 parent 529d97e commit c2b6eab
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mvc/src/test/java/duplicate/case1/TestController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package duplicate.case1;

import context.org.springframework.stereotype.Controller;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import web.org.springframework.web.bind.annotation.RequestMapping;
import web.org.springframework.web.bind.annotation.RequestMethod;
import webmvc.org.springframework.web.servlet.ModelAndView;

@Controller
public class TestController {

private static final Logger log = LoggerFactory.getLogger(samples.TestController.class);

@RequestMapping(value = "/get-test", method = RequestMethod.GET)
public ModelAndView duplicatedMethod(final HttpServletRequest request,
final HttpServletResponse response) {
return null;
}
}
28 changes: 28 additions & 0 deletions mvc/src/test/java/duplicate/case2/TestController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package duplicate.case2;

import context.org.springframework.stereotype.Controller;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import web.org.springframework.web.bind.annotation.RequestMapping;
import web.org.springframework.web.bind.annotation.RequestMethod;
import webmvc.org.springframework.web.servlet.ModelAndView;

@Controller
public class TestController {

private static final Logger log = LoggerFactory.getLogger(samples.TestController.class);

@RequestMapping(value = "/get-test", method = RequestMethod.GET)
public ModelAndView duplicatedMethod1(final HttpServletRequest request,
final HttpServletResponse response) {
return null;
}

@RequestMapping(value = "/get-test", method = RequestMethod.GET)
public ModelAndView duplicatedMethod2(final HttpServletRequest request,
final HttpServletResponse response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -19,6 +20,27 @@ void setUp() {
handlerMapping.initialize();
}

@Test
void methodDuplicationException_case1() {
// given & when & then
AnnotationHandlerMapping duplicatedHandlerMapping = new AnnotationHandlerMapping(
"samples",
"duplicate.case1");
assertThatThrownBy(() -> duplicatedHandlerMapping.initialize())
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Duplicated HandlerKey");
}

@Test
void methodDuplicationException_case2() {
// given & when & then
AnnotationHandlerMapping duplicatedHandlerMapping = new AnnotationHandlerMapping(
"duplicate.case2");
assertThatThrownBy(() -> duplicatedHandlerMapping.initialize())
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Duplicated HandlerKey");
}

@Test
void get() throws Exception {
final var request = mock(HttpServletRequest.class);
Expand Down

0 comments on commit c2b6eab

Please sign in to comment.