fork download
  1. @Test
  2. public void EnsureFileCheckExists() {
  3. final String DNE = "Does not exist";
  4. final InputStream oldIn = System.in;
  5. final PrintStream oldOut = System.out;
  6. final InputStream mockIn = context.mock(InputStream.class);
  7. final PrintStream mockOut = context.mock(PrintStream.class);
  8. final InputStreamReader mockReader = context.mock(InputStreamReader.class);
  9. final BufferedReader mockBufReader = context.mock(BufferedReader.class);
  10. System.setOut(mockOut);
  11. System.setIn(mockIn);
  12. Expectations exp;
  13. try {
  14. exp = new Expectations() {{
  15. one(mn).main(null);
  16. //one(mn).promptStringOrFile(); will(returnValue(true)); //use parameter here
  17. one(mockOut).println("Do you want to process standard (I)nput, or a (F)ile? I/F");
  18. one(mn).grabConfig(); will(returnValue(new String[] {"-1", "1"}));
  19. one(mockOut).println("How many results would you like to see? (-1 for all)");
  20. one(mn).readInput(); will(returnValue("-1"));
  21. one(mockBufReader).readLine(); will(returnValue("-1"));
  22. one(mn).readInput(); will(returnValue(DNE));
  23. one(mn).ensureFileExists(DNE); will(returnValue(false));
  24. }};
  25. context.checking(exp);
  26. context.assertIsSatisfied();
  27. } catch (IOException e) {
  28. e.printStackTrace();
  29. }
  30. //mn.main(null);
  31. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout

Standard output is empty