package tmcsim.cadsimulator; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.rmi.RemoteException; import static junit.framework.Assert.assertEquals; import org.uispec4j.*; import tmcsim.common.SimulationException; /** * Test of Byte Output Stream and redirection * * @author jdalbey */ public class BOStest extends UISpecTestCase { public BOStest(String testName) { super(testName); } /** * Test of main method, of class CADSimulator. */ ByteArrayOutputStream bos; public void setUp() throws SimulationException, RemoteException { // Declare a stream to the output bos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(bos); // Redirect the standard output System.setOut(ps); } @Override public void tearDown() throws java.io.IOException { } public void testConstructor() { System.out.println("Mary had a little lamb."); // Convert the output stream into a string we can test. String result = bos.toString(); assertEquals(expected1, result); } public void testLoad() throws RemoteException { System.out.print(expected2); // Convert the output stream into a string we can test. String result = bos.toString(); assertEquals(expected2, result); } String expected1 = "Mary had a little lamb.\n"; String expected2 = "Fleece white as snow.\n"; }