@@ -0,0 +1,2617 @@
+package proof.util;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.fail;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.PrintStream;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0A%0A/**%0A * Tests for %7B@link ProgressLogger%7D.%0A *%0A * @author Tilo Wiedera%0A */%0A@RunWith(Parameterized.class)%0Apublic class ProgressLoggerTest %7B%0A  private final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();%0A  private final boolean verbose;%0A  private final PrintStream printStream = new PrintStream(byteStream);%0A  private final ProgressLogger logger;%0A  private final int MAX_PROGRESS = 42;%0A%0A%0A  @Parameterized.Parameters(name = %22verbose=%7B0%7D%22)%0A  public static Boolean%5B%5D getParameters() %7B%0A    Boolean%5B%5D result = %7Btrue, false%7D;%0A    return result;%0A  %7D%0A%0A  public ProgressLoggerTest(boolean verbose) %7B%0A    this.verbose = verbose;%0A    logger = new ProgressLogger(printStream, verbose);%0A  %7D%0A%0A  @Before%0A  public void setUp() throws IOException %7B%0A    logger.reset(MAX_PROGRESS);%0A    printStream.flush();%0A    byteStream.reset();%0A  %7D%0A%0A  @Test%0A  public void testReset() %7B%0A    logger.reset(MAX_PROGRESS);%0A  %7D%0A%0A  @Test%0A  public void testReset_progress() %7B%0A    for (int i = 0; i %3C MAX_PROGRESS; i++) %7B%0A      logger.progress();%0A    %7D%0A%0A    try %7B%0A      logger.progress();%0A      fail(%22Progress should never exceed the maximum value of %22 + MAX_PROGRESS + %22.%22);%0A    %7D catch (IllegalArgumentException expected) %7B%0A      // this is supposed to happen%0A    %7D%0A  %7D%0A%0A  @Test(expected = IllegalArgumentException.class)%0A  public void testReset_invalidSizeZero() %7B%0A    logger.reset(0);%0A  %7D%0A%0A  @Test(expected = IllegalArgumentException.class)%0A  public void testReset_invalidSizeNegative() %7B%0A    logger.reset(-MAX_PROGRESS);%0A  %7D%0A%0A  @Test%0A  public void testProgress() %7B%0A    for (int i = 0; i %3C MAX_PROGRESS; i++) %7B%0A      logger.progress(%22foobar%22);%0A    %7D%0A%0A    assertEquals(verbose ? MAX_PROGRESS : 1, getOutput().length);%0A  %7D%0A%0A  @Test%0A  public void testPrint() %7B%0A    logger.println(%22stet clita kasd gubergren%22);%0A%0A    for (int i = 0; i %3C 3; i++) %7B%0A      logger.print(%22sed diam voluptua%22);%0A    %7D%0A%0A    assertEquals(verbose ? 4 : 2, getOutput().length);%0A  %7D%0A%0A  @Test%0A  public void testPrintln() %7B%0A    for (int i = 0; i %3C 3; i++) %7B%0A      logger.println(%22dolor sit amet%22);%0A    %7D%0A%0A    for (int i = 0; i %3C MAX_PROGRESS; i++) %7B%0A      logger.progress();%0A    %7D%0A%0A    assertEquals(verbose ? 3 : 4, getOutput().length);%0A  %7D%0A%0A  private String%5B%5D getOutput() %7B%0A    printStream.flush();%0A    return byteStream.toString().split(%22%5C%5Cr?%5C%5Cn%22);%0A  %7D%0A%7D%0A

Add Logger Test