Eureka Client 의존 추가 시 @SpringBootTest 구동, -> 유레카 서버 안켜져있음! 이라는 메세지가 뜬다.
properties 에 eureka.client.enabled=false 걸어서 꺼놓자.
@SpringBootTest(properties = "eureka.client.enabled=false",webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class PostRepositoryTest {
private static final Logger LOGGER = LoggerFactory.getLogger(PostRepositoryTest.class);
@Autowired
private PostRepository postRepository;
@Autowired
private CommentRepository commentRepository;
@Test
@Rollback(false)
public void test(){
Post post = Post.builder().setTitle("Post Title").setContent("Post Content").build();
Post savedPost = postRepository.save(post);
Optional<Post> selectedPost_opt = postRepository.findById(savedPost.getId());
assertThat(selectedPost_opt).isNotEmpty();
assertThat(selectedPost_opt.get().getTitle()).isEqualTo("Post Title");
assertThat(selectedPost_opt.get().getContent()).isEqualTo("Post Content");
}
@Test
public void commentTest(){
Comment comment = Comment.builder().setTitle("Comment Title").setContent("Comment Content").build();
Comment savedComment = commentRepository.save(comment);
Optional<Comment> selectedComment_opt = commentRepository.findById(savedComment.getId());
assertThat(selectedComment_opt).isNotEmpty();
assertThat(selectedComment_opt.get().getTitle()).isEqualTo("Comment Title");
assertThat(selectedComment_opt.get().getContent()).isEqualTo("Comment Content");
}
}
'Exception' 카테고리의 다른 글
MongoDB 인덱스 안태워질때 (0) | 2021.01.08 |
---|---|
@ControllerAdvice 에서 HttpRequest 파라미터를 받지 못합니다. (0) | 2020.12.16 |
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed (0) | 2020.12.11 |
java.lang.IllegalArgumentException: No converter found for return value of type (0) | 2020.12.09 |
엑셀 파일 로딩시 형변환에러 발생 Safe하게 하기 (0) | 2020.10.14 |