PrinterListenerTest.java :  » Testing » jumble » com » reeltwo » jumble » ui » Java Open Source

Java Open Source » Testing » jumble 
jumble » com » reeltwo » jumble » ui » PrinterListenerTest.java
package com.reeltwo.jumble.ui;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import com.reeltwo.jumble.fast.MutationResult;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * Tests the corresponding class.
 * 
 * @author Tin Pavlinic
 * @version $Revision 1.0 $
 */
public class PrinterListenerTest extends TestCase {
  public void testLineWrapping() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrinterListener listener = new PrinterListener(new PrintStream(baos));
    StringBuffer expected = new StringBuffer();

    for (int i = 0; i < 50; i++) {
      expected.append(".");
      listener.finishedMutation(new MutationResult(MutationResult.PASS, "dummyClass", i, "dummy description"));
    }
    expected.append(System.getProperty("line.separator"));
    for (int i = 0; i < 25; i++) {
      expected.append("T");
      listener.finishedMutation(new MutationResult(MutationResult.TIMEOUT, "dummyClass", i + 50, "dummy description"));
    }

    assertEquals(baos.toString(), expected.toString());
  }

  public static Test suite() {
    return new TestSuite(PrinterListenerTest.class);
  }

  public static void main(String[] args) {
    junit.textui.TestRunner.run(suite());
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.