-
Notifications
You must be signed in to change notification settings - Fork 237
refactor: MVC Response 학습테스트 실패환경 구성 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
26c56ec
refactor: MVC Response 학습테스트 실패환경 구성
Choi-JJunho d180f4b
Merge branch 'main' of https://github.com/cho-log/spring-learning-tes…
Choi-JJunho 7bb5ce9
refactor: 반환값 String으로 수정
Choi-JJunho 980d853
refactor: /template 테스트 추가
Choi-JJunho f04d2b6
docs: 마지막 줄 개행 추가
Choi-JJunho 1423775
refactor: template 학습테스트 수정
Choi-JJunho 0fbb44b
resolve conflict
Choi-JJunho 6256da4
refactor: complete 구성
Choi-JJunho 8c11091
refactor: 테스트 실패환경 구성
Choi-JJunho 72ab5f9
refactor: 문서 변경에 따른 코드 반영
Choi-JJunho caa6bf4
docs: 문서 수정
Choi-JJunho 7e6a834
refactor: 코드 통일
Choi-JJunho 11d1749
test: 수정된 내용에 맞춰 테스트 변경
Choi-JJunho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -7,4 +7,4 @@ | |
| <body> | ||
| Hello World! | ||
| </body> | ||
| </html> | ||
| </html> | ||
File renamed without changes.
15 changes: 7 additions & 8 deletions
15
spring-mvc-1/complete/src/test/java/cholog/ResponseJsonTest.java
This file contains hidden or 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,25 +1,24 @@ | ||
| package cholog; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import io.restassured.RestAssured; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) | ||
| public class ResponseJsonTest { | ||
| class ResponseJsonTest { | ||
|
|
||
| @Test | ||
| void responseJson() { | ||
| var response = RestAssured | ||
| .given().log().all() | ||
| .when().get("/person") | ||
| .then().log().all().extract(); | ||
| .given().log().all() | ||
| .when().get("/json") | ||
| .then().log().all().extract(); | ||
|
|
||
| assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value()); | ||
| assertThat(response.as(Person.class).getName()).isEqualTo("Brown"); | ||
| assertThat(response.as(Person.class).getName()).isEqualTo("brown"); | ||
| assertThat(response.as(Person.class).getAge()).isEqualTo(20); | ||
| } | ||
|
|
||
| } |
18 changes: 9 additions & 9 deletions
18
spring-mvc-1/complete/src/test/java/cholog/ResponseStaticTest.java
This file contains hidden or 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
14 changes: 7 additions & 7 deletions
14
spring-mvc-1/complete/src/test/java/cholog/ResponseTemplatesTest.java
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -2,9 +2,9 @@ | |
|
|
||
| <br> | ||
|
|
||
| 스프링 부트는 정적 페이지와 템플릿 시작 페이지를 모두 지원합니다. | ||
| 먼저 구성된 정적 콘텐츠 위치에서 index.html 파일을 찾습니다. | ||
| 하나라도 없으면 index 템플릿을 찾습니다. | ||
| 스프링 부트는 정적 페이지와 템플릿 시작 페이지를 모두 지원합니다. | ||
| 먼저 구성된 정적 콘텐츠 위치에서 index.html 파일을 찾습니다. | ||
| 하나라도 없으면 index 템플릿을 찾습니다. | ||
| 둘 중 하나라도 찾으면 자동으로 응용 프로그램 시작 페이지로 사용됩니다. | ||
|
|
||
| <br> | ||
|
|
@@ -43,7 +43,7 @@ welcome page 설정을 연습하는 학습 테스트 입니다. | |
|
|
||
| <br> | ||
|
|
||
| resources/static 아래의 경로에 위치한 파일은 접근이 가능합니다. | ||
| resources/static 아래의 경로에 위치한 파일은 접근이 가능합니다. | ||
| 서비스에서 필요한 정적 자원들을 해당 경로에 위치시킨 후 활용할 수 있습니다. | ||
|
|
||
| <br> | ||
|
|
@@ -52,7 +52,7 @@ resources/static 아래의 경로에 위치한 파일은 접근이 가능합니 | |
| 정적 페이지 설정을 연습하는 학습 테스트 입니다. | ||
| - 테스트 메서드: `cholog.ResponseStaticTest.responseStaticPage` | ||
| - 수행 방법 | ||
| - `resources/templates/hello.html` 을 이용하여 학습 테스트를 성공시키세요. | ||
| - `resources/templates/static.html` 을 이용하여 학습 테스트를 성공시키세요. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| - 정적 페이지 설정을 위해 적절한 위치에 이동을 하거나 파일명을 변경해보세요. | ||
|
|
||
| <br> | ||
|
|
@@ -78,7 +78,7 @@ Model 객체는 컨트롤러 메서드의 파라미터로 주입 받을 수 있 | |
| - 테스트 메서드: `cholog.ResponseTemplatesTest.responseTemplatesPage` | ||
| - 수행 방법 | ||
| - `cholog.MemberController.world` 메서드를 작성하여 학습 테스트를 성공시키세요. | ||
| - `/hello` 요청 시 `resources/templates/hello.html` 페이지가 응답할 수 있도록 설정하세요. | ||
| - `/hello` 요청 시 `resources/templates/hello.html` 페이지가 응답할 수 있도록 설정하세요. | ||
|
|
||
| <br> | ||
|
|
||
|
|
@@ -108,4 +108,4 @@ Model 객체는 컨트롤러 메서드의 파라미터로 주입 받을 수 있 | |
|
|
||
| ### 참고자료 | ||
| - [Spring - @ResponseBody](https://docs.spring.io/spring-framework/reference/web/webmvc/mvc-controller/ann-methods/responsebody.html#page-title) | ||
| - [Spring - Return Values > Other return values](https://docs.spring.io/spring-framework/reference/web/webmvc/mvc-controller/ann-methods/return-types.html) | ||
| - [Spring - Return Values > Other return values](https://docs.spring.io/spring-framework/reference/web/webmvc/mvc-controller/ann-methods/return-types.html) | ||
18 changes: 18 additions & 0 deletions
18
spring-mvc-1/initial/src/main/java/cholog/MemberController.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package cholog; | ||
|
|
||
| import org.springframework.stereotype.Controller; | ||
|
|
||
| @Controller | ||
| public class MemberController { | ||
|
|
||
| public String world() { | ||
| // TODO: /hello 요청 시 resources/templates/static.html 페이지가 응답할 수 있도록 설정하세요. | ||
| // TODO: 쿼리 파라미터로 name 요청이 들어왔을 때 해당 값을 hello.html에서 사용할 수 있도록 하세요. | ||
| return null; | ||
| } | ||
|
|
||
| public Person json() { | ||
| // TODO: /json 요청 시 {"name": "brown", "age": 20} 데이터를 응답할 수 있도록 설정하세요. | ||
| return null; | ||
| } | ||
| } |
22 changes: 0 additions & 22 deletions
22
spring-mvc-1/initial/src/main/java/cholog/ResponseController.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -7,4 +7,4 @@ | |
| <body> | ||
| Welcome! | ||
| </body> | ||
| </html> | ||
| </html> | ||
File renamed without changes.
File renamed without changes.
15 changes: 7 additions & 8 deletions
15
spring-mvc-1/initial/src/test/java/cholog/ResponseJsonTest.java
This file contains hidden or 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,25 +1,24 @@ | ||
| package cholog; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import io.restassured.RestAssured; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) | ||
| public class ResponseJsonTest { | ||
| class ResponseJsonTest { | ||
|
|
||
| @Test | ||
| void responseJson() { | ||
| var response = RestAssured | ||
| .given().log().all() | ||
| .when().get("/person") | ||
| .then().log().all().extract(); | ||
| .given().log().all() | ||
| .when().get("/json") | ||
| .then().log().all().extract(); | ||
|
|
||
| assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value()); | ||
| assertThat(response.as(Person.class).getName()).isEqualTo("Brown"); | ||
| assertThat(response.as(Person.class).getName()).isEqualTo("brown"); | ||
| assertThat(response.as(Person.class).getAge()).isEqualTo(20); | ||
| } | ||
|
|
||
| } |
18 changes: 9 additions & 9 deletions
18
spring-mvc-1/initial/src/test/java/cholog/ResponseStaticTest.java
This file contains hidden or 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
14 changes: 7 additions & 7 deletions
14
spring-mvc-1/initial/src/test/java/cholog/ResponseTemplatesTest.java
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍