I'm new to JUnit tests and I've written code to redirect a file as an input, but I'm not sure how to test it. What's the best way to test the code?
private static String request;
public static void main(String[] args) {
readFile();
}
public static void readFile() {
try {
/* BufferedReader to read text from an input stream */
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
/* While loop to read each line of the file. request - each line is a different client request */
while ((request = input.readLine()) != null) {
System.out.println("Client request: " + request);
}
/* Closes input */
input.close();
}
catch (Exception e) {
e.printStackTrace();
}
}