본문 바로가기
728x90

Spring Boot38

HATEOAS HATEOAS? > Hypermedia As Engine Of Application State > resource와 연관있는 정보를 같이 제공(서버)하고 현재 resource와 연결된 링크 정보를 바탕으로 resource에 접근(클라이언트) 참고 : https://docs.spring.io/spring-hateoas/docs/current/reference/html/#reference Spring HATEOAS - Reference Documentation Example 47. Configuring WebTestClient when using Spring Boot @SpringBootTest @AutoConfigureWebTestClient (1) class WebClientBasedTests { @Te.. 2022. 2. 28.
ExceptionHandler 스프링 @MVC에서 예외 처리 방법 @GetMapping("/exception") public String exceptionExample(){ throw new SampleException(); } @ExceptionHandler(SampleException.class) public AppError sampleError(SampleException exception){ return AppError.builder() .message("App error") .reason("na do mola") .build(); } 결과 커스텀 에러 페이지 /static/error 밑에 html페이지 생성 > error code와 같으면 좋음 결과 2022. 2. 28.
문법 1. "${ㄱㄱㄱ.ㄴㄴㄴ:${ㄷㄷㄷ.ㄹㄹㄹ:/error}}" : ㄱㄱㄱ.ㄴㄴㄴ에 해당하는 값이 있다면 사용 없다면 ㄷㄷㄷ.ㄹㄹㄹ에 대한 값 사용 그마저도 없다면 "/error"사용 2022. 2. 28.
HtmlUnit HtmlUnit : html을 단위테스트하기 위한 tool > 웹 클라이언트로 요청을 보내고 결과를 받아서 내용을 HtmlPage를 통해 값을 확인할 수 있음 > 브라우저 타입을 줄 수 있음 > 엘리먼트 값을 가지고와서 값을 확인할 수 있음 예제) Controller, template : 전과 동일 https://developing-countries.tistory.com/64 TestCode @RunWith(SpringRunner.class) @WebMvcTest(SampleController.class) public class SampleControllerTest { @Autowired WebClient webClient; @Test public void hello() throws IOException.. 2022. 2. 28.
728x90