source: tmcsimulator/trunk/test/tmcsim/cadsimulator/BOStest.java @ 47

Revision 47, 1.5 KB checked in by jdalbey, 10 years ago (diff)

Merge 305 modifications into trunk.

Line 
1package tmcsim.cadsimulator;
2
3import java.io.ByteArrayOutputStream;
4import java.io.PrintStream;
5import java.rmi.RemoteException;
6import static junit.framework.Assert.assertEquals;
7import org.uispec4j.*;
8import tmcsim.common.SimulationException;
9
10/**
11 * Test of Byte Output Stream and redirection
12 *
13 * @author jdalbey
14 */
15public class BOStest extends UISpecTestCase
16{
17
18    public BOStest(String testName)
19    {
20        super(testName);
21    }
22    /**
23     * Test of main method, of class CADSimulator.
24     */
25    ByteArrayOutputStream bos;
26
27    public void setUp() throws SimulationException, RemoteException
28    {
29        // Declare a stream to the output
30        bos = new ByteArrayOutputStream();
31        PrintStream ps = new PrintStream(bos);
32        // Redirect the standard output
33        System.setOut(ps);
34    }
35
36    @Override
37    public void tearDown() throws java.io.IOException
38    {
39    }
40
41    public void testConstructor()
42    {
43        System.out.println("Mary had a little lamb.");
44        // Convert the output stream into a string we can test.
45        String result = bos.toString();
46        assertEquals(expected1, result);
47
48    }
49
50    public void testLoad() throws RemoteException
51    {
52        System.out.print(expected2);
53        // Convert the output stream into a string we can test.
54        String result = bos.toString();
55        assertEquals(expected2, result);
56
57    }
58    String expected1 = "Mary had a little lamb.\n";
59    String expected2 = "Fleece white as snow.\n";
60}
Note: See TracBrowser for help on using the repository browser.