StreamProgressMonitor implements ProgressMonitor { public void endTask() { if (done) return; stream.println(DONE); done = true; } StreamProgressMonitor(PrintStream stream); void start(int totalTasks); void beginTask(String title, int totalWork); void update(int completed); void endTask(); boolean isCancelled(); static final String DONE; }
@Test public void endTask() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); StreamProgressMonitor monitor = new StreamProgressMonitor( new PrintStream(stream)); monitor.beginTask("test task", 1); monitor.endTask(); assertEquals("test task: 1 " + StreamProgressMonitor.DONE + SEPARATOR, stream.toString()); }