-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MVC 미션 1단계] 포이(김보준) 미션 제출합니다. (#361)
* test: 리플렉션 테스트 완료 * test: 서블릿, 필터 학습 테스트 완료 * feat: 어노테이션 기반으로 HandlerMapping을 초기화해주는 기능 추가
- Loading branch information
Showing
9 changed files
with
174 additions
and
48 deletions.
There are no files selected for viewing
10 changes: 9 additions & 1 deletion
10
mvc/src/main/java/web/org/springframework/web/bind/annotation/RequestMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
package web.org.springframework.web.bind.annotation; | ||
|
||
public enum RequestMethod { | ||
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE | ||
GET, | ||
HEAD, | ||
POST, | ||
PUT, | ||
PATCH, | ||
DELETE, | ||
OPTIONS, | ||
TRACE | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
package reflection; | ||
|
||
import java.util.Arrays; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class Junit3TestRunner { | ||
|
||
@Test | ||
void run() throws Exception { | ||
Class<Junit3Test> clazz = Junit3Test.class; | ||
final var clazz = Junit3Test.class; | ||
|
||
// TODO Junit3Test에서 test로 시작하는 메소드 실행 | ||
// Junit3Test에서 test로 시작하는 메소드 실행 | ||
Arrays.stream(clazz.getDeclaredMethods()) | ||
.filter(method -> method.getName().startsWith("test")) | ||
.forEach(method -> { | ||
try { | ||
method.invoke(clazz.getDeclaredConstructor().newInstance()); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
package reflection; | ||
|
||
import static org.reflections.scanners.Scanners.TypesAnnotated; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.reflections.Reflections; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import reflection.annotation.Controller; | ||
import reflection.annotation.Repository; | ||
import reflection.annotation.Service; | ||
|
||
class ReflectionsTest { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(ReflectionsTest.class); | ||
|
||
@Test | ||
void showAnnotationClass() throws Exception { | ||
void showAnnotationClass() { | ||
Reflections reflections = new Reflections("reflection.examples"); | ||
|
||
// TODO 클래스 레벨에 @Controller, @Service, @Repository 애노테이션이 설정되어 모든 클래스 찾아 로그로 출력한다. | ||
// 클래스 레벨에 @Controller, @Service, @Repository 애노테이션이 설정되어있는 모든 클래스 찾아 로그로 출력한다. | ||
reflections.get(TypesAnnotated.of(Controller.class, Service.class, Repository.class)) | ||
.forEach(clazz -> log.info("{}", clazz)); | ||
} | ||
} |
Oops, something went wrong.