Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/com/ll/wisesaying/util/InputUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.ll.wisesaying.exception.InputException;

public class InputUtil {
public static final BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
public static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
public static final String END = "종료";
public static final String ENROLL = "등록";
public static final String LIST = "목록";
Expand All @@ -25,6 +25,10 @@ public class InputUtil {
public static final String CMD_SEPARATOR = "\\?|id|=";
public static final String SEARCH_SEPARATOR = "\\?|keywordType|&|keyword|page|=";

public static void resetBufferedReader() {
bf = new BufferedReader(new InputStreamReader(System.in));
}

public static String inputMessage() throws IOException {
return bf.readLine();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.ll.wisesaying.service.WiseSayingService;
import com.ll.wisesaying.repository.WiseSayingRepository;
import com.ll.wisesaying.util.InputUtil;
import com.ll.wisesaying.util.TestUtil;

import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -61,6 +62,7 @@ void registerTest() throws IOException {
작자미상
""";
System.setIn(TestUtil.getInputStream(input));
InputUtil.resetBufferedReader();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System.in의 경로를 바꾸면, BufferedReader를 초기화하여 새로 바꾼 경로로 입력을 받아오도록 다시 초기화해주어야 한다.


// When
controller.register();
Expand Down Expand Up @@ -96,6 +98,7 @@ void editTest() throws IOException {
수정된 작가
""";
System.setIn(TestUtil.getInputStream(input));
InputUtil.resetBufferedReader();

controller.register();

Expand All @@ -118,6 +121,8 @@ void buildTest() throws IOException {
작자미상
""";
System.setIn(TestUtil.getInputStream(input));
InputUtil.resetBufferedReader();

controller.register();

// When
Expand Down