Index: trunk/test/tmcsim/simulationmanager/IncidentHistoryPanelDriver.java
===================================================================
--- trunk/test/tmcsim/simulationmanager/IncidentHistoryPanelDriver.java	(revision 47)
+++ trunk/test/tmcsim/simulationmanager/IncidentHistoryPanelDriver.java	(revision 47)
@@ -0,0 +1,47 @@
+package tmcsim.simulationmanager;
+
+import java.awt.BorderLayout;
+import java.util.Vector;
+import javax.swing.JFrame;
+import tmcsim.cadmodels.*;
+import tmcsim.client.cadclientgui.data.IncidentEvent;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class IncidentHistoryPanelDriver
+{
+
+    public static void main(String[] args)
+    {
+        // Create an IncidentEvent
+        Vector dummy = new Vector();
+        IncidentInquiryHeader hdr = new IncidentInquiryHeader();
+        // The incident type is a 4-digit string (Use MMYY for month and year of your birth)
+        hdr.type = "1179";
+        // The incident location is the name of your home town
+        hdr.fullLocation = "San Luis Obispo";
+        IncidentInquiryModel_obj mo = new IncidentInquiryModel_obj();
+        mo.setHeader(hdr);
+        // The incident details is a parade on the main street (provide street name for your home town)
+        IncidentInquiryDetails det = new IncidentInquiryDetails("1", "Parade on Higuera", false);
+        mo.addDetail(det);
+        IncidentEvent event = new IncidentEvent(10, mo, "", 4, dummy, dummy);
+        // Create an IncidentHistoryPanel
+        IncidentHistoryPanel ihPanel = new IncidentHistoryPanel();
+        // Add the event to the panel
+        ihPanel.updateIncidentHistory(event);
+
+        // Create the frame.
+        JFrame frame = new JFrame("Incident Panel Demo");
+        // Specify closing behavior
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        // Add component to the frame.
+        frame.getContentPane().add(ihPanel, BorderLayout.CENTER);
+        // Size the frame.
+        frame.pack();
+        // Show it.
+        frame.setVisible(true);
+    }
+}
Index: trunk/test/tmcsim/simulationmanager/model/AppliedDiversionTableItemTest.java
===================================================================
--- trunk/test/tmcsim/simulationmanager/model/AppliedDiversionTableItemTest.java	(revision 47)
+++ trunk/test/tmcsim/simulationmanager/model/AppliedDiversionTableItemTest.java	(revision 47)
@@ -0,0 +1,26 @@
+package tmcsim.simulationmanager.model;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class AppliedDiversionTableItemTest extends TestCase
+{
+
+    public AppliedDiversionTableItemTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void testCompareTo()
+    {
+        System.out.println("compareTo");
+        AppliedDiversionTableItem arg = new AppliedDiversionTableItem("1", "o", "n", 1, 1L);
+        AppliedDiversionTableItem instance = new AppliedDiversionTableItem("1", "o", "n", 1, 1L);
+        int expResult = 0;
+        int result = instance.compareTo(arg);
+        assertEquals(expResult, result);
+    }
+}
Index: trunk/test/tmcsim/paramicslog/ParamicsLogRMITestSkeleton.java
===================================================================
--- trunk/test/tmcsim/paramicslog/ParamicsLogRMITestSkeleton.java	(revision 47)
+++ trunk/test/tmcsim/paramicslog/ParamicsLogRMITestSkeleton.java	(revision 47)
@@ -0,0 +1,94 @@
+package tmcsim.paramicslog;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+import junit.framework.TestCase;
+import tmcsim.cadsimulator.CADSimulator;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class ParamicsLogRMITestSkeleton extends TestCase
+{
+
+    public ParamicsLogRMITestSkeleton(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+    String propsfile = "config/paramics_communicator_logging.properties";
+
+    /**
+     * Test of getInstance method, of class ParamicsLog.
+     */
+    public void testGetInstance() throws ScriptException, SimulationException, RemoteException, FileNotFoundException, IOException
+    {
+        System.out.println("getInstance");
+        try
+        {
+            CADSimulator engine = new CADSimulator("config/testConfig/cad_simulator_console_config.properties");
+        } catch (Exception e)
+        {
+            fail("Couldn't launch CADSimulator");
+        }
+        try
+        {
+            Thread.sleep(2000);
+        } catch (InterruptedException ex)
+        {
+        }
+        // This seems to fail because the ParamicsLog static initializer gets
+        // run before the CADSimulator is created, so no RMI connection can be made.
+        ParamicsLog plog = ParamicsLog.getInstance();
+        Properties paramicsLogProp = new Properties();
+        paramicsLogProp.load(new FileInputStream(propsfile));
+        String logFilename = paramicsLogProp.getProperty("LogFile");
+        File logFile = new File(logFilename);
+        assertTrue("log file doesn't exist", logFile.exists());
+
+        plog.writeToLog("Hello friendly log.");
+        String expected = "\n<!-- Time written to file: ? -->\nHello friendly log.\n";
+        String actual = plog.getLog();
+        assertEquals("log written incorrectly", expected, actual);
+    }
+
+    public void testFormatEasyTime()
+    {
+        ParamicsLog plog = ParamicsLog.getInstance();
+        String expected = "00:01:02";
+        String actual = plog.formatTime(62l);
+        assertEquals("time format wrong", expected, actual);
+
+        expected = "1:00:01";
+        actual = plog.formatTime(3601l);
+        assertEquals("time format wrong", expected, actual);
+    }
+
+    public void testFormatDate() throws ParseException
+    {
+        ParamicsLog plog = ParamicsLog.getInstance();
+        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
+        String expected = "01:01:01";
+        Date one = formatter.parse(expected);
+        long millis = one.getTime();
+        String actual = plog.formatTime(millis);
+        assertEquals("time format wrong", expected, actual);
+    }
+}
Index: trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java
===================================================================
--- trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java	(revision 47)
+++ trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java	(revision 47)
@@ -0,0 +1,56 @@
+package tmcsim.paramicslog;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.Properties;
+import java.util.logging.Logger;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import junit.framework.TestCase;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class ParamicsLogFileHandlerTest extends TestCase
+{
+
+    public ParamicsLogFileHandlerTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+    String propsfile = "config/paramics_communicator_logging.properties";
+
+    /**
+     * Test of getInstance method, of class ParamicsLog.
+     */
+    public void testGetInstance() throws ScriptException, SimulationException, RemoteException, FileNotFoundException, IOException
+    {
+        System.out.println("getInstance");
+        //ParamicsLog plog = ParamicsLog.getInstance();
+        Properties paramicsLogProp = new Properties();
+        paramicsLogProp.load(new FileInputStream(propsfile));
+        String logFilename = paramicsLogProp.getProperty("LogFile");
+        // This test assumes there is NO CADSimulator running.
+        Logger logger = Logger.getLogger("tmcsim.parmicsLog");
+        ParamicsLogFileHandler fh = ParamicsLogFileHandler.getInstance();
+        logger.addHandler(fh);
+        logger.info("Hello friendly log.");
+        File logFile = new File(logFilename);
+        assertTrue("log file doesn't exist", logFile.exists());
+        String expected = "\n<!-- Time written to file: ? -->\nHello friendly log.\n";
+        String actual = fh.getLog();
+        assertEquals("log written incorrectly", expected, actual);
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleDriver.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleDriver.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleDriver.java	(revision 47)
@@ -0,0 +1,191 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import static org.mockito.Mockito.mock;
+import static tmcsim.cadsimulator.CADSimulatorFixture.writedata;
+import tmcsim.common.CADEnums;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.interfaces.CADClientInterface;
+import tmcsim.interfaces.SimulationManagerInterface;
+
+/**
+ * Driver for CADSimulator Console - output to stdout.
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorConsoleDriver extends TestCase
+{
+
+    static CADSimulator app;
+    static final String configData =
+            "CADClientPort          = 4444 \n"
+            + "CoordinatorRMIPort     = 4445 \n"
+            + "CADRmiPort             = 4446 \n"
+            + "UserInterface          = tmcsim.cadsimulator.viewer.CADConsoleViewer\n"
+            + "ParamicsProperties     = pconfig.txt\n"
+            + "ATMSProperties         = empty.txt\n"
+            + "MediaProperties        = empty.txt\n";
+    static final String paramicsData = "ParamicsCommHost       = 192.168.251.45\n"
+            + "ParamicsCommPort       = 4450\n"
+            + "IncidentUpdateInterval = 30\n"
+            + "IncidentUpdateFile     = exchange.xml\n"
+            + "ParamicsStatusInterval = 15\n"
+            + "ParamicsStatusFile     = paramics_status.xml\n"
+            + "CameraStatusInterval   = 30\n"
+            + "CameraStatusFile       = camera_status.xml\n";
+    /*
+     * Creating instance of app must be done only once or you get registry
+     * bind problems, and code Written in Constructor is Executed
+     * before each Test Method
+     */
+
+    public static void main(String[] args) throws IOException, SimulationException, ScriptException
+    {
+        writedata("config.txt", configData);
+        writedata("pconfig.txt", paramicsData);
+        writedata("empty.txt", "");
+        CADSimulatorFixture.writeScriptfiles();
+        CADSimulatorFixture.startCADSim();
+        (new CADSimulatorConsoleDriver()).testAll();
+        System.exit(0);
+    }
+    // Write the test data to a file
+
+    private void testAll() throws java.io.IOException, SimulationException, ScriptException
+    {
+
+        CADClientInterface ci = mock(CADClientInterface.class); //new tmcsim.cadsimulator.CADSimulatorDriver.FakeClient();
+        app.theCoordinator.registerForCallback(ci);
+        // Convert the output stream into a string we can test.
+
+        app.theCoordinator.registerForCallback(ci);
+
+        SimulationManagerInterface si = mock(SimulationManagerInterface.class);
+
+        app.theCoordinator.registerForCallback(si);
+
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
+
+        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
+        CADSimulatorFixture.pause(500);
+
+        // Show loaded, and ALSO update the current network id
+        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+        CADSimulatorFixture.pause(500);
+
+        app.theCoordinator.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING);
+        CADSimulatorFixture.pause(500);
+
+        cadSimLogger.logp(Level.SEVERE, "Someclass", "Somemethod", "Something bad happened.");
+
+        // Load a script file
+        String autoloadScriptname = "scripts/one-incident.xml";
+        app.theCoordinator.loadScriptFile(new File(autoloadScriptname));
+        // The status should now say Ready
+
+
+//        ParamicsSimulationManager psm = mock(ParamicsSimulationManager.class);
+//        when(psm.isConnected()).thenReturn(Boolean.TRUE, Boolean.FALSE);
+//        app.theParamicsSimMgr = psm;
+//        app.theCoordinator.connectToParamics();
+//        app.theCoordinator.loadParamicsNetwork(1);
+//        CADSimulatorFixture.pause(500);
+//        app.theCoordinator.disconnectFromParamics();
+//        CADSimulatorFixture.pause(500);
+
+        app.theCoordinator.startSimulation();
+        CADSimulatorFixture.pause(1500);
+        app.theCoordinator.pauseSimulation();
+        app = null;
+        cleanup();
+    }
+
+    private void cleanup()
+    {
+        File removeMe = new File("config.txt");
+        removeMe.delete();
+        removeMe = new File("pconfig.txt");
+        removeMe.delete();
+        removeMe = new File("empty.txt");
+        removeMe.delete();
+    }
+    String expected1 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 0\n"
+            + "Simulation Manager Connected: No\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n\n"
+            + "-- Error Messages --\n\n";
+    String expected2 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 1\n"
+            + "Simulation Manager Connected: No\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n\n"
+            + "-- Error Messages --\n\n";
+    String expected3 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: No\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n\n"
+            + "-- Error Messages --\n\n";
+    String expected4 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: Yes\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n\n"
+            + "-- Error Messages --\n\n";
+    String expected5 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: Yes\n"
+            + "Connected to Paramics       : No\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n"
+            + ". = Sample Info Message.\n"
+            + "-- Error Messages --\n\n";
+    String expected6 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: Yes\n"
+            + "Connected to Paramics       : Yes\n"
+            + "Network Loaded              : \n"
+            + "-- Info Messages --\n"
+            + ". = Sample Info Message.\n"
+            + "-- Error Messages --\n\n";
+    String expected7 =
+            "--- CAD Simulator ---\n"
+            + "Elapsed Simulation Time     : 0:00:00\n"
+            + "Status                      : No Script\n"
+            + "Connected CAD Terminals     : 2\n"
+            + "Simulation Manager Connected: Yes\n"
+            + "Connected to Paramics       : Yes\n"
+            + "Network Loaded              : 3\n"
+            + "-- Info Messages --\n"
+            + ". = Sample Info Message.\n"
+            + "-- Error Messages --\n\n";
+}
Index: trunk/test/tmcsim/cadsimulator/SystemConsoleTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/SystemConsoleTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/SystemConsoleTest.java	(revision 47)
@@ -0,0 +1,226 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.rmi.RemoteException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import org.uispec4j.*;
+import org.uispec4j.interception.WindowInterceptor;
+import tmcsim.cadsimulator.managers.ATMSManager;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.paramicscommunicator.PComm;
+import tmcsim.paramicscommunicator.gui.ParamicsCommunicatorGUI;
+import tmcsim.simulationmanager.SimulationManager;
+
+/**
+ * Note, this is just like VisibleSystemTest except it starts it's own
+ * CADSimulator running on the console.
+ *
+ * @author jdalbey
+ */
+public class SystemConsoleTest extends UISpecTestCase
+{
+
+    SimulationManager simMgrApp;
+    CADSimulator engine;
+
+    public SystemConsoleTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * Test of run method, of class ParamicsCommunicator.
+     */
+    public void testRun() throws ScriptException, SimulationException, RemoteException
+    {
+        System.out.println("System Console Test");
+
+        try
+        {
+            engine = new CADSimulator("config/testConfig/cad_simulator_console_config.properties");
+        } catch (Exception e)
+        {
+            fail("Couldn't launch CADSimulator");
+        }
+
+        PComm pc = null;
+        pc = new PComm("config/testConfig/paramics_communicator_config.properties");
+        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI();
+        pc.setGUI(theGUI);
+        // Note: Can't set visible ANY windows during UISpec test
+
+        // expect pcomm to say "sleeping"
+
+        Window simMgrWindow = null;
+        simMgrWindow = WindowInterceptor.run(new Trigger()
+        {
+            public void run()
+            {
+                try
+                {
+                    simMgrApp = new SimulationManager("config/sim_manager_systest_config.properties");
+                } catch (Exception ex)
+                {
+                    fail("Couldn't launch Simulation Manager");
+                }
+            }
+        });
+
+        // TODO: Check that the Sim Mgr GUI appears without a script loaded yet
+
+        Panel contentPanel = simMgrWindow.getPanel("contentPane");
+        TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText");
+        assertEquals("No Script", txtSimStatus.getText());
+        TextBox txtParamStatus = contentPanel.getTextBox("paramicsStatusInfoLabel");
+        assertEquals("Unknown", txtParamStatus.getText());
+        Button loadNetworkBtn = simMgrWindow.getButton("Load Network");
+        assertFalse(loadNetworkBtn.isEnabled());
+
+        Button paramicsBtn = simMgrWindow.getButton("Connect to Paramics");
+        paramicsBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Disconnect from Paramics", paramicsBtn.getLabel());
+
+        assertEquals("Connected", txtParamStatus.getText());
+        pc.startReading();
+
+        loadNetworkBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Sending Network ID", txtParamStatus.getText());
+        System.out.println("Sending Network ID");
+        assertFalse(loadNetworkBtn.isEnabled());
+        String warmingXML = "<Paramics>\n"
+                + "<Network_Status>WARMING</Network_Status>\n"
+                + "<Network_ID>1</Network_ID>\n"
+                + "</Paramics>";
+        writedata("paramics_status.xml", warmingXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Warming Up", txtParamStatus.getText());
+        System.out.println("Warming Up Passed");
+
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        String loadedXML = "<Paramics>\n"
+                + "<Network_Status>LOADED</Network_Status>"
+                + "<Network_ID>1</Network_ID>"
+                + "</Paramics>";
+        writedata("paramics_status.xml", loadedXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Network 1 Loaded", txtParamStatus.getText());
+        System.out.println("Network Loaded Passed");
+
+        // Load a script file
+        String autoloadScriptname = "scripts/audio_systest.xml";
+        simMgrApp.loadScript(new File(autoloadScriptname));
+        try
+        {
+            Thread.sleep(500);
+        } catch (Exception ex)
+        {
+        }
+
+        // The status should now say Ready
+        assertEquals("Ready", txtSimStatus.getText());
+
+        // Mock out the ATMS manager in CADSimulator
+        ATMSManager atm = mock(ATMSManager.class);
+        try
+        {
+            when(atm.getCurrentTime()).thenReturn(29000L);
+        } catch (Exception ex)
+        {
+            Logger.getLogger(SystemConsoleTest.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        engine.theATMSMgr = atm;
+
+        // Click "Start"
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+        assertEquals("Running", txtSimStatus.getText());
+        System.out.println("Running Passed");
+        try
+        {
+            Thread.sleep(9000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        simMgrWindow.getMenuBar().getMenu("File").getSubMenu("Exit").click();
+        System.out.println("Exiting.");
+
+
+    }
+
+    // Write the test data to a file
+    public static void writedata(String filename, String data)
+    {
+        PrintWriter writer = null;
+        try
+        {
+            writer = new PrintWriter(new FileWriter(filename));
+            writer.println(data);
+            writer.close();
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java	(revision 47)
@@ -0,0 +1,601 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import static org.mockito.Mockito.mock;
+import tmcsim.cadsimulator.viewer.CADConsoleViewer;
+import tmcsim.common.CADEnums;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.interfaces.CADClientInterface;
+import tmcsim.interfaces.SimulationManagerInterface;
+
+/**
+ * Test of CADSimulator Console
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorConsoleTest extends TestCase
+{
+
+    private static CADSimulator app = null;
+    private CADConsoleViewer console;
+    private StringWriter sw;
+
+    public CADSimulatorConsoleTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        writeConfigData();
+        // Since CADSimulator has registry, we musn't instantiate it more than once
+        if (app == null)
+        {
+            try
+            {
+                app = new CADSimulator("config.txt");
+            } catch (Exception ex)
+            {
+                fail("Couldn't launch CADSimulator");
+            }
+        }
+        console = (CADConsoleViewer) app.theViewer;
+        sw = new StringWriter();
+        console.setWriter(sw);
+    }
+
+    @Override
+    public void tearDown() throws java.io.IOException
+    {
+        File removeMe = new File("config.txt");
+        removeMe.delete();
+        removeMe = new File("pconfig.txt");
+        removeMe.delete();
+        removeMe = new File("empty.txt");
+        removeMe.delete();
+    }
+
+    /**
+     * compare StringWriter contents against expected
+     */
+    private void verify(String msg, String expect)
+    {
+        String result = sw.toString().trim();
+        result = result.replaceAll("\n", ",");
+        String fullExpect = expect.trim();
+        fullExpect = fullExpect.replaceAll("\n", ",");
+//        System.out.println(fullExpect);
+//        System.out.println(result.substring(result.length() - fullExpect.length(), result.length()));
+//        String diff = StringUtils.difference(fullExpect, result);
+        boolean match = result.endsWith(fullExpect);
+        assertTrue(msg + ": " + result, match);
+    }
+
+    public static void pause(int millis)
+    {
+        try
+        {
+            Thread.sleep(millis);
+        } catch (InterruptedException ex)
+        {
+        }
+    }
+
+    /**
+     * The tests must be all run in one method, because the order matters. As
+     * separate methods, we couldn't control which is executed first.
+     *
+     * @throws java.io.IOException
+     * @throws SimulationException
+     * @throws ScriptException
+     */
+    public void testAll() throws java.io.IOException, SimulationException, ScriptException
+    {
+        CADConsoleViewer console = (CADConsoleViewer) app.theViewer;
+        String expected1 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --";
+        System.out.println("setVisible");
+        console.setVisible(true);
+        verify("Initial output incorrect: ", expected1);
+        String expected2 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 1\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+
+        System.out.println("connect one");
+        CADClientInterface ci = mock(CADClientInterface.class);
+        app.theCoordinator.registerForCallback(ci);
+        verify("connected 1 terminal output incorrect: ", expected2);
+        String expected3 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 2\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        System.out.println("connect two");
+        app.theCoordinator.registerForCallback(ci);
+        verify("connected 2 terminals output incorrect: ", expected3);
+        System.out.println("disconnect");
+        app.theCoordinator.unregisterForCallback(ci);
+        verify("disconnect terminal output incorrect: ", expected2);
+        app.theCoordinator.unregisterForCallback(ci);
+        String expected4 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        System.out.println("sim mgr connect");
+        SimulationManagerInterface si = mock(SimulationManagerInterface.class);
+        app.theCoordinator.registerForCallback(si);
+        verify("sim mgr connected output incorrect: ", expected4);
+        String expected5 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n\n";
+        System.out.println("Info msg");
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Console Info Message.");
+        verify("Info message output incorrect: ", expected5);
+        String expected7 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        System.out.println("Error msg");
+        cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.SEVERE, "Someclass", "Somemethod", "Something bad happened.");
+        verify("Error message output incorrect: ", expected7);
+        String expected6 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : Yes\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        System.out.println("Paramics connect");
+        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
+        pause(500);
+        pause(500);
+        verify("paramics connected should be yes", expected6);
+        String expected8 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : Ready\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : Yes\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        String expected9 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:01\n"
+                + "Status                      : Running\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : Yes\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        System.out.println("Sim status");
+        // Load a script file - to put status at Ready
+        String autoloadScriptname = "scripts/one-incident.xml";
+        app.theCoordinator.loadScriptFile(new File(autoloadScriptname));
+        pause(500);
+        verify("Status should be 'ready'", expected8);
+        // startSimulation to put status at Running
+        app.theCoordinator.startSimulation();
+        pause(500);
+        verify("Status should be 'running', time should be 0:01", expected9);
+    }
+//    public void testNetworkID()
+//    {
+//        String expected10 =
+//                "--- CAD Simulator ---\n"
+//                + "Elapsed Simulation Time     : 0:00:00\n"
+//                + "Status                      : No Script\n"
+//                + "Connected CAD Terminals     : 0\n"
+//                + "Simulation Manager Connected: No\n"
+//                + "Connected to Paramics       : No\n"
+//                + "Network Loaded              : 17\n"
+//                + "-- Info Messages --\n\n"
+//                + "-- Error Messages --\n\n";
+//        // this will tell the model it has a new network ID
+//        cadmodel.setParamicsNetworkLoaded("17");
+//        cadmodel.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+//        pause(500);
+//        verify("network id should be 17", expected10);
+//    }
+//    ByteArrayOutputStream bos;
+//    PrintStream ps;
+    static final String configData =
+            "CADClientPort          = 4444 \n"
+            + "CoordinatorRMIPort     = 4445 \n"
+            + "CADRmiPort             = 4446 \n"
+            + "UserInterface          = tmcsim.cadsimulator.viewer.CADConsoleViewer\n"
+            + "ParamicsProperties     = pconfig.txt\n"
+            + "ATMSProperties         = empty.txt\n"
+            + "MediaProperties        = empty.txt\n";
+    static final String paramicsData = "ParamicsCommHost = 127.0.0.1\n"
+            + "ParamicsCommPort       = 4450\n"
+            + "IncidentUpdateInterval = 30\n"
+            + "IncidentUpdateFile     = exchange.xml\n"
+            + "ParamicsStatusInterval = 15\n"
+            + "ParamicsStatusFile     = paramics_status.xml\n"
+            + "CameraStatusInterval   = 30\n"
+            + "CameraStatusFile       = camera_status.xml\n";
+    static final String cardfileURL = "http://pastebin.com/raw/Yr26nfp7";
+    static final String smallXMLURL = "http://pastebin.com/raw/Eqj2N5qD";
+    /*
+     * Creating instance of app must be done only once or you get registry
+     * bind problems, and code Written in Constructor is Executed
+     * before each Test Method
+     */
+
+    private void writeConfigData()
+    {
+        // Declare a stream to the output
+//        bos = new ByteArrayOutputStream();
+//        ps = new PrintStream(bos);
+        // Redirect the standard output
+//        System.setOut(ps);
+        writedata("config.txt", configData);
+        writedata("pconfig.txt", paramicsData);
+        writedata("empty.txt", "");
+        writeScriptfiles();
+    }
+
+    private void writeScriptfiles()
+    {
+        new File("scripts").mkdir();
+        writedata("scripts/Cardfile.xml", cardfileData);
+        writedata("scripts/one-incident.xml", oneincidentXML);
+    }
+
+    // Write the test data to a file
+    private void writedata(String filename, String data)
+    {
+        File cardFile = new File(filename);
+        // If a cardfile exists, leave it
+        if (!cardFile.exists())
+        {
+            PrintWriter writer = null;
+            try
+            {
+                writer = new PrintWriter(new FileWriter(filename));
+                writer.println(data);
+                writer.close();
+            } catch (Exception ex)
+            {
+                ex.printStackTrace();
+            }
+        }
+    }
+    private static final String cardfileData =
+            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+            + "<!--Please do not modify titles. Note that these titles are not"
+            + "sent into the actual screen. If titles are to be modified,"
+            + "they need to be changed in CardfileHandler.java  -->"
+            + ""
+            + ""
+            + ""
+            + "<CARDFILE> "
+            + "	<TAB title = \"Coastal Division Units\">"
+            + "		<CARDFILE_OBJ name = \"Name\" >"
+            + "			<ADDRESS>Address</ADDRESS>"
+            + "			<CITY>City</CITY>"
+            + "			<STATE>State</STATE>"
+            + "			<ZIP>Zip</ZIP>"
+            + "			<PHONE1>Phone1</PHONE1>"
+            + "			<PHONE2>Phone2</PHONE2>"
+            + "			<FAX>Fax</FAX>"
+            + "		</CARDFILE_OBJ>"
+            + "		"
+            + "		<CARDFILE_OBJ  name = \"Name2\" >"
+            + "			<ADDRESS>Address2</ADDRESS>"
+            + "			<CITY>City2</CITY>"
+            + "			<STATE>State2</STATE>"
+            + "			<ZIP>Zip2</ZIP>"
+            + "			<PHONE1>Phone12</PHONE1>"
+            + "			<PHONE2>Phone22</PHONE2>"
+            + "			<FAX>Fax2</FAX>"
+            + "		</CARDFILE_OBJ>"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Police/Sheriff/Coroner\">"
+            + "	"
+            + "		<CARDFILE_OBJ  name = \"Name\" >"
+            + "			<ADDRESS>Address</ADDRESS>"
+            + "			<CITY>City</CITY>"
+            + "			<STATE>State</STATE>"
+            + "			<ZIP>Zip</ZIP>"
+            + "			<PHONE1>Phone1</PHONE1>"
+            + "			<PHONE2>Phone2</PHONE2>"
+            + "			<FAX>Fax</FAX>"
+            + "		</CARDFILE_OBJ>"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Courts\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Public Transportation\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"GG Other\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"MY Misc\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"SL Misc\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"VT Misc\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"CHP Offices\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"State Agencies/Facilities\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Government Officials\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Federal Agencies\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Fire/EMS\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Jails\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Hospitals/Med Centers\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Tow Companies\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"CalTrans\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"County Roads\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Utilities\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Animal Control\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Airports\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Credit Cards\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"GG Crisis Shelters\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Ranges\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Hotlines\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Hwy Patrols OOS\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Parks/Recreation\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Shelters\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"SL County Services\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"SL Resources\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Truck/Tire Repair\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"MCC Employees\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"Gate Access Codes\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"VT Call Signs\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + "	"
+            + "	<TAB title = \"SLCC Employees\">"
+            + "		"
+            + "		"
+            + "		"
+            + "	</TAB>"
+            + ""
+            + "</CARDFILE>";
+    private static final String oneincidentXML =
+            "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
+            + ""
+            + "<TMC_SCRIPT title=\"One Incident Simulation\">"
+            + ""
+            + "	<SCRIPT_EVENT>"
+            + "		<TIME_INDEX>00:00:00</TIME_INDEX>"
+            + "		<INCIDENT LogNum=\"100\">Media Log</INCIDENT>		"
+            + "		"
+            + "		<CAD_DATA>"
+            + "			<HEADER_INFO>"
+            + "				<Type>Media</Type>"
+            + "				<Beat>"
+            + "				</Beat>"
+            + "				<TruncLoc>"
+            + "				</TruncLoc>"
+            + "				<FullLoc>"
+            + "				</FullLoc>"
+            + "			</HEADER_INFO>			"
+            + "			"
+            + "			<CAD_INCIDENT_EVENT>	"
+            + "			</CAD_INCIDENT_EVENT>		"
+            + "			"
+            + "		</CAD_DATA>				"
+            + "		"
+            + "	</SCRIPT_EVENT>	"
+            + "</TMC_SCRIPT>";
+}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorGUITest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorGUITest.java	(revision 34)
+++ trunk/test/tmcsim/cadsimulator/CADSimulatorGUITest.java	(revision 47)
@@ -5,5 +5,4 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.fail;
@@ -50,26 +49,4 @@
         removeMe.delete();
     }
-
-    /**
-     * Test of getCADTime method, of class CADSimulator.
-     */
-    public void testGetCADTime()
-    {
-        System.out.println("getCADTime");
-        String result = CADSimulator.getCADTime();
-        // Just test length for now
-        assertEquals(4, result.length());
-    }
-
-    /**
-     * Test of getCADDate method, of class CADSimulator.
-     */
-    public void testGetCADDate()
-    {
-        System.out.println("getCADDate");
-        String result = CADSimulator.getCADDate();
-        // Just test length for now
-        assertEquals(6, result.length());
-    }
     /**
      * Test of main method, of class CADSimulator.
@@ -79,9 +56,17 @@
     public void testConstructor() throws SimulationException, RemoteException, ScriptException
     {
+        System.out.println("CADSimulator constructor");
         CADSimulatorFixture.writeConfigData();
         CADSimulatorFixture.writedata("config.txt", configData);
-        System.out.println("CADSimulator constructor");
+        Window cadwindow = null;
+//        try
+//        {
+//            app = new CADSimulator("config.txt");
+//        } catch (Exception e)
+//        {
+//            fail("Couldn't launch CADSimulator" + e.getMessage());
+//        }
+
         System.setProperty("CONFIG_DIR", "config/testConfig");
-        Window cadwindow = null;
         if (System.getProperty("CONFIG_DIR") != null)
         {
@@ -100,33 +85,41 @@
                 }
             });
-        } else
+        }
+        else
         {
             fail("CONFIG_DIR system property not defined.");
         }
-        assertEquals("CAD Simulator", cadwindow.getTitle());
+
+        System.out.println("Tests for text fields.");
+        // Create a UISpec window from the CADSimulator's Viewer (gui)
+//        cadwindow = new Window((CADSimulatorViewer) app.theViewer);
+        assertTrue("Title bar incorrect", cadwindow.getTitle().startsWith("CAD Simulator revision:"));
         Panel mainPanel = cadwindow.getPanel("contentPane");
         TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
-        assertEquals("No Script", txtStatus.getText());
+        assertEquals("simulation status should say No Script", "No Script", txtStatus.getText().trim());
         TextBox terminals = mainPanel.getTextBox("termConnectedTF");
-        assertEquals("0", terminals.getText().trim());
-        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-        assertEquals("0:00:00", mainPanel.getTextBox("simulationClockLabel").getText());
+        assertEquals("should be 0 terminals", "0", terminals.getText().trim());
+        assertEquals("mgr connected should be no", "No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
+        assertEquals("paramics connected should be no", "No", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
+        assertEquals("initial time should be 0:00:00", "0:00:00", mainPanel.getTextBox("simulationClockLabel").getText().trim());
 
-        CADClientInterface ci = new FakeClient();
+        CADClientInterface ci = mock(CADClientInterface.class);
         app.theCoordinator.registerForCallback(ci);
-        assertEquals("1", terminals.getText().trim());
+        assertEquals("should be 1 terminal", "1", terminals.getText().trim());
         app.theCoordinator.registerForCallback(ci);
-        assertEquals("2", terminals.getText().trim());
+        assertEquals("should be 2 terminals", "2", terminals.getText().trim());
 
         SimulationManagerInterface si = mock(SimulationManagerInterface.class);
+
         app.theCoordinator.registerForCallback(si);
-        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
+        assertEquals("mgr connected should be yes", "Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
 
         Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
         cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
 
+        System.out.println("Tests for message panes.");
         Panel infoPane = mainPanel.getPanel("infoMessagesPane");
         TextBox infoText = infoPane.getTextBox("infoMessagesTA");
-        assertEquals(". = Sample Info Message.", infoText.getText().trim());
+        assertEquals("wrong info msg text", ". = Sample Info Message.", infoText.getText().trim());
 
         cadSimLogger.logp(Level.SEVERE, "", "", "Sample Error Message.");
@@ -134,10 +127,11 @@
         Panel errPane = mainPanel.getPanel("errorMessagesPane");
         TextBox errText = errPane.getTextBox("errorMessagesTA");
-        assertEquals(". = Sample Error Message.", errText.getText().trim());
+        assertEquals("wrong error msg text", ". = Sample Error Message.", errText.getText().trim());
 
+        System.out.println("Tests for status changes.");
         app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
         CADSimulatorFixture.pause(500);
-        assertEquals("Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
-        assertEquals("None", mainPanel.getTextBox("networkLoadedTF").getText().trim());
+        assertEquals("paramics connected should be yes", "Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
+        assertEquals("network id should be None", "None", mainPanel.getTextBox("networkLoadedTF").getText().trim());
 
 //        app.theCoordinator.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING);
@@ -148,35 +142,21 @@
         app.theCoordinator.loadScriptFile(new File(autoloadScriptname));
         // The status should now say Ready
-        assertEquals("Ready", mainPanel.getTextBox("simulationStatus").getText().trim());
+        assertEquals("sim status should be ready", "Ready", mainPanel.getTextBox("simulationStatus").getText().trim());
 
         app.theCoordinator.startSimulation();
-        CADSimulatorFixture.pause(500);
-        assertEquals("Running", mainPanel.getTextBox("simulationStatus").getText().trim());
-        assertEquals("0:00:01", mainPanel.getTextBox("simulationClockLabel").getText());
+        CADSimulatorFixture.pause(900);
+        assertEquals("sim status should be running", "Running", mainPanel.getTextBox("simulationStatus").getText().trim());
+        assertEquals("sim time should be 0:00:01", "0:00:01", mainPanel.getTextBox("simulationClockLabel").getText().trim());
 
         ParamicsSimulationManager psm = mock(ParamicsSimulationManager.class);
         when(psm.isConnected()).thenReturn(Boolean.TRUE);
+        when(psm.getParamicsNetworkLoaded()).thenReturn(1); // provide the network ID to return
         app.theParamicsSimMgr = psm;
-        app.theCoordinator.loadParamicsNetwork(1);
-
-//        app.theViewer.dispose();
-//        Window confirmPopup = null;
-//        confirmPopup = WindowInterceptor.run(new Trigger()
-//        {
-//            public void run()
-//            {
-//                app.theViewer.closeViewer();
-//            }
-//        });
-//        confirmPopup.getButton("OK").click();
-    }
-
-    class FakeClient implements CADClientInterface
-    {
-
-        @Override
-        public void refresh() throws RemoteException
-        {
-        }
+        // this will tell the model it has a new network ID
+        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+        CADSimulatorFixture.pause(500);
+        assertEquals("network id should be 1", "1", mainPanel.getTextBox("networkLoadedTF").getText().trim());
+        //mainPanel.getMenu().getItem("Exit").click();
+        boolean breakpoint = true;
     }
 }
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorFixture.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorFixture.java	(revision 26)
+++ trunk/test/tmcsim/cadsimulator/CADSimulatorFixture.java	(revision 47)
@@ -34,5 +34,5 @@
             + "ATMSProperties         = empty.txt\n"
             + "MediaProperties        = empty.txt\n";
-    static final String configpData = "ParamicsCommHost = 192.168.251.45\n"
+    static final String paramicsData = "ParamicsCommHost       = 192.168.251.45\n"
             + "ParamicsCommPort       = 4450\n"
             + "IncidentUpdateInterval = 30\n"
@@ -60,6 +60,5 @@
         System.setOut(ps);
         writedata("config.txt", configData);
-        writedata("pconfig.txt", configpData);
-        writedata("pmcprops.txt", paramConfig);
+        writedata("pconfig.txt", paramicsData);
         writedata("empty.txt", "");
         writeScriptfiles();
Index: trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java	(revision 47)
@@ -0,0 +1,253 @@
+package tmcsim.cadsimulator.viewer;
+
+import java.io.StringWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import tmcsim.cadsimulator.viewer.model.CADSimulatorModel;
+import tmcsim.common.CADEnums;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class CADConsoleViewerTest extends TestCase
+{
+
+    CADConsoleViewer console;
+    CADSimulatorModel cadmodel;
+    StringWriter sw;
+
+    public CADConsoleViewerTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        console = new CADConsoleViewer();
+        cadmodel = new CADSimulatorModel();
+        cadmodel.addObserver(console);
+        sw = new StringWriter();
+        console.setWriter(sw);
+    }
+    /**
+     * compare StringWriter contents against expected
+     */
+    private void verify(String msg, String expect)
+    {
+        String result = sw.toString().trim();
+        result = result.replaceAll("\n", ",");
+        String fullExpect = expect.trim();
+        fullExpect = fullExpect.replaceAll("\n", ",");
+        assertTrue(msg + ": " + result, result.endsWith(fullExpect));
+    }
+
+    public static void pause(int millis)
+    {
+        try
+        {
+            Thread.sleep(millis);
+        } catch (InterruptedException ex)
+        {
+        }
+    }
+
+    /**
+     * Test of setVisible method, of class CADConsoleViewer.
+     */
+    public void testSetVisible()
+    {
+        String expected1 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --";
+        System.out.println("setVisible");
+        console.setVisible(true);
+        String out = sw.toString().trim();
+        assertEquals(expected1, out);
+    }
+
+    public void testConnect()
+    {
+        String expected2 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 1\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.connectClient();
+        verify("connected 1 terminal output incorrect: ", expected2);
+    }
+
+    public void testConnect2()
+    {
+        String expected3 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 2\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.connectClient();
+        cadmodel.connectClient();
+        verify("connected 2 terminals output incorrect: ", expected3);
+    }
+
+    public void testDisconnect()
+    {
+        String expected3 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 2\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.connectClient();
+        cadmodel.connectClient();
+        cadmodel.connectClient();
+        cadmodel.disconnectClient();
+        verify("disconnect terminal output incorrect: ", expected3);
+    }
+
+    public void testSimMgrConnect()
+    {
+        String expected4 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: Yes\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.setSimManagerStatus(true);
+        verify("sim mgr connected output incorrect: ", expected4);
+    }
+
+    public void testInfoPane()
+    {
+        String expected5 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n"
+                + ". = Console Info Message.\n"
+                + "-- Error Messages --\n\n";
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Console Info Message.");
+        verify("Info message output incorrect: ", expected5);
+    }
+
+    public void testErrorPane()
+    {
+        String expected7 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n"
+                + "Someclass.Somemethod = Something bad happened.\n";
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.SEVERE, "Someclass", "Somemethod", "Something bad happened.");
+        verify("Error message output incorrect: ", expected7);
+    }
+
+    public void testParamicsChg()
+    {
+        String expected6 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : Yes\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
+        pause(500);
+        verify("paramics connected should be yes", expected6);
+    }
+
+    public void testSimStatus()
+    {
+        String expected8 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : Ready\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_STOPPED_NOT_STARTED);
+        verify("sim status should be ready", expected8);
+        cadmodel.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING);
+        String result = sw.toString();
+        assertTrue("sim status should be running: " + result, result.contains("Running"));
+    }
+
+    public void testSimTime()
+    {
+        String expected9 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:01:01\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : None\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        cadmodel.setTime(61L);
+        verify("sim time should be 0:01:01", expected9);
+    }
+
+    public void testNetworkID()
+    {
+        String expected10 =
+                "--- CAD Simulator ---\n"
+                + "Elapsed Simulation Time     : 0:00:00\n"
+                + "Status                      : No Script\n"
+                + "Connected CAD Terminals     : 0\n"
+                + "Simulation Manager Connected: No\n"
+                + "Connected to Paramics       : No\n"
+                + "Network Loaded              : 17\n"
+                + "-- Info Messages --\n\n"
+                + "-- Error Messages --\n\n";
+        // this will tell the model it has a new network ID
+        cadmodel.setParamicsNetworkLoaded("17");
+        cadmodel.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+        pause(500);
+        verify("network id should be 17", expected10);
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorModelTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorModelTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorModelTest.java	(revision 47)
@@ -0,0 +1,151 @@
+package tmcsim.cadsimulator.viewer.model;
+
+import java.util.Observable;
+import java.util.Observer;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import junit.framework.TestCase;
+import tmcsim.cadsimulator.viewer.DVDInfoPanel;
+import java.util.Iterator;
+import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate;
+import tmcsim.common.CADEnums;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorModelTest extends TestCase implements Observer
+{
+
+    private CADSimulatorModel model;
+    private String currentTest;
+
+    public CADSimulatorModelTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void setUp()
+    {
+        model = new CADSimulatorModel();
+        model.addObserver(this);
+    }
+
+    /**
+     * Test of connectClient method, of class CADSimulatorStatus.
+     */
+    public void testConnectClient()
+    {
+        currentTest = "connectClient";
+        model.connectClient();
+    }
+
+    /**
+     * Test of disconnectClient method, of class CADSimulatorStatus.
+     */
+    public void testDisconnectClient()
+    {
+        currentTest = "doNothing";
+        model.connectClient();
+        model.connectClient();
+        currentTest = "disconnectClient";
+        model.disconnectClient();
+    }
+
+    /**
+     * Test of setSimManagerStatus method, of class CADSimulatorStatus.
+     */
+    public void testSetSimManagerStatus()
+    {
+        currentTest = "setSimManagerStatus";
+        model.setSimManagerStatus(false);
+    }
+
+    /**
+     * Test of setTime method, of class CADSimulatorStatus.
+     */
+    public void testSetTime()
+    {
+        currentTest = "setTime";
+        long seconds = 0L;
+        model.setTime(seconds);
+    }
+
+    /**
+     * Test of setScriptStatus method, of class CADSimulatorStatus.
+     */
+    public void testSetScriptStatus()
+    {
+        currentTest = "setScriptStatus";
+        CADEnums.SCRIPT_STATUS newStatus = CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING;
+        model.setScriptStatus(newStatus);
+    }
+
+    public void testSetParamicsStatus()
+    {
+        currentTest = "setParamicsStatus";
+        CADEnums.PARAMICS_STATUS newStatus = CADEnums.PARAMICS_STATUS.CONNECTED;
+        model.setParamicsStatus(newStatus);
+    }
+
+    public void testLoadNetwork()
+    {
+        currentTest = "loadNetwork";
+        model.setParamicsNetworkLoaded("ABC");
+    }
+    
+    public void testDVDupdate()
+    {
+        currentTest = "dvdUpdate";
+        model.updateDVDStatus(new DVDStatusUpdate("1", false, new Throwable()));
+    }
+
+    @Override
+    public void update(Observable obs, Object obj)
+    {
+        CADSimulatorStatus stat = null;
+        CADMediaStatus ms = null;
+        if (obs instanceof CADSimulatorStatus)
+        {
+            stat = (CADSimulatorStatus) obs;
+        }
+        if (obs instanceof CADMediaStatus)
+        {
+            ms = (CADMediaStatus) obs;
+        }
+        System.out.println(currentTest);
+        switch (currentTest)
+        {
+            case "connectClient":
+                assertEquals(1, stat.getNumClients());
+                break;
+            case "disconnectClient":
+                assertEquals(1, stat.getNumClients());
+                break;
+            case "setSimManagerStatus":
+                assertFalse(stat.isSimManagerConnected());
+                break;
+            case "setTime":
+                assertEquals("0:00:00", stat.getCurrentTime());
+                break;
+            case "setScriptStatus":
+                CADEnums.SCRIPT_STATUS expResult = CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING;
+                CADEnums.SCRIPT_STATUS result = stat.getScriptStatus();
+                assertEquals(expResult, result);
+                break;
+            case "setParamicsStatus":
+                CADEnums.PARAMICS_STATUS expect = CADEnums.PARAMICS_STATUS.CONNECTED;
+                assertEquals(expect, stat.getParamicsStatus());
+                break;
+            case "loadNetwork":
+                String id = stat.getParmicsNetworkID();
+                assertEquals("ABC", id);
+                break;
+            case "dvdUpdate":
+                Iterator<DVDInfoPanel> iter = ms.getDVDlist();
+                assertTrue(iter.hasNext());
+            case "doNothing":
+                break;
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorStatusTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorStatusTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/viewer/model/CADSimulatorStatusTest.java	(revision 47)
@@ -0,0 +1,108 @@
+package tmcsim.cadsimulator.viewer.model;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import static junit.framework.Assert.assertEquals;
+import junit.framework.TestCase;
+import tmcsim.common.CADEnums;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorStatusTest extends TestCase
+{
+
+    CADSimulatorStatus stat;
+
+    public CADSimulatorStatusTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void setUp()
+    {
+        stat = new CADSimulatorStatus();
+    }
+
+    /**
+     * Test of connectClient method, of class CADSimulatorStatus.
+     */
+    public void testConnectClient()
+    {
+        System.out.println("connectClient");
+        stat.connectClient();
+        assertEquals(1, stat.getNumClients());
+    }
+
+    /**
+     * Test of disconnectClient method, of class CADSimulatorStatus.
+     */
+    public void testDisconnectClient()
+    {
+        System.out.println("disconnectClient");
+        stat.connectClient();
+        stat.connectClient();
+        stat.disconnectClient();
+        assertEquals(1, stat.getNumClients());
+    }
+
+    /**
+     * Test of getNumClients method, of class CADSimulatorStatus.
+     */
+    public void testGetNumClients()
+    {
+        System.out.println("getNumClients");
+        int expResult = 0;
+        int result = stat.getNumClients();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of setSimManagerStatus method, of class CADSimulatorStatus.
+     */
+    public void testSetSimManagerStatus()
+    {
+        System.out.println("setSimManagerStatus");
+        stat.setSimManagerStatus(false);
+        assertFalse(stat.isSimManagerConnected());
+    }
+
+    /**
+     * Test of setTime method, of class CADSimulatorStatus.
+     */
+    public void testSetTime()
+    {
+        System.out.println("setTime");
+        long seconds = 1L;
+        stat.setTime(seconds);
+        String result = stat.getCurrentTime();
+        assertEquals("0:00:01", result);
+    }
+
+    /**
+     * Test of setScriptStatus method, of class CADSimulatorStatus.
+     */
+    public void testSetScriptStatus()
+    {
+        System.out.println("setScriptStatus");
+        CADEnums.SCRIPT_STATUS newStatus = CADEnums.SCRIPT_STATUS.NO_SCRIPT;
+        stat.setScriptStatus(newStatus);
+        CADEnums.SCRIPT_STATUS expResult = CADEnums.SCRIPT_STATUS.NO_SCRIPT;
+        CADEnums.SCRIPT_STATUS result = stat.getScriptStatus();
+        assertEquals(expResult, result);
+        newStatus = CADEnums.SCRIPT_STATUS.ATMS_SYNCHRONIZATION;
+        stat.setScriptStatus(newStatus);
+        assertEquals(CADEnums.SCRIPT_STATUS.ATMS_SYNCHRONIZATION, stat.getScriptStatus());
+        newStatus = CADEnums.SCRIPT_STATUS.SCRIPT_PAUSED_STARTED;
+        stat.setScriptStatus(newStatus);
+        assertEquals(CADEnums.SCRIPT_STATUS.SCRIPT_PAUSED_STARTED, stat.getScriptStatus());
+    }
+
+    public void testInfoMsg()
+    {
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
+        assertEquals(". = Sample Info Message.", stat.getInfoMessages());
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/viewer/CADSimulatorViewModelTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/viewer/CADSimulatorViewModelTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/viewer/CADSimulatorViewModelTest.java	(revision 47)
@@ -0,0 +1,146 @@
+package tmcsim.cadsimulator.viewer;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.uispec4j.*;
+import tmcsim.cadsimulator.viewer.model.CADSimulatorModel;
+import tmcsim.common.CADEnums;
+
+/**
+ *
+ * @author jdalbey
+ */
+public class CADSimulatorViewModelTest extends junit.framework.TestCase //extends UISpecTestCase
+{
+
+    CADSimulatorViewer viewer;
+    Window cadwindow;
+    CADSimulatorModel model;
+    Panel mainPanel;
+
+    public CADSimulatorViewModelTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        viewer = new CADSimulatorViewer();
+        cadwindow = new Window(viewer);
+        model = new CADSimulatorModel();
+        model.addObserver(viewer);
+        mainPanel = cadwindow.getPanel("contentPane");
+    }
+
+    public void testInitialView()
+    {
+        String actual;
+        assertTrue("Title bar incorrect", cadwindow.getTitle().trim().startsWith("CAD Simulator"));
+        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
+        actual = txtStatus.getText().trim();
+        assertEquals("simulation status should say No Script", "No Script", actual);
+        TextBox terminals = mainPanel.getTextBox("termConnectedTF");
+        actual = terminals.getText().trim();
+        assertEquals("should be 0 terminals", "0", actual);
+        actual = mainPanel.getTextBox("managerConnectedTF").getText().trim();
+        assertEquals("mgr connected should be no", "No", actual);
+        actual = mainPanel.getTextBox("paramicsConnectedTF").getText().trim();
+        assertEquals("paramics connected should be no", "No", actual);
+        actual = mainPanel.getTextBox("simulationClockLabel").getText().trim();
+        assertEquals("initial time should be 0:00:00", "0:00:00", actual);
+        actual = mainPanel.getTextBox("networkLoadedTF").getText().trim();
+        assertEquals("network id should be None", "None", actual);
+    }
+
+    public void testClients()
+    {
+        String actual;
+        model.connectClient();
+        TextBox terminals = mainPanel.getTextBox("termConnectedTF");
+        assertEquals(1, model.getNumClients());
+        assertEquals("should be 1 terminal", "1", terminals.getText().trim());
+        model.connectClient();
+        assertEquals("should be 2 terminals", "2", terminals.getText().trim());
+        model.disconnectClient();
+        assertEquals("should be 1 terminal after disconnect", "1", terminals.getText().trim());
+    }
+
+    public void testSimMgr()
+    {
+        String actual;
+        model.setSimManagerStatus(true);
+        actual = mainPanel.getTextBox("managerConnectedTF").getText().trim();
+        assertEquals("mgr connected should be yes", "Yes", actual);
+        assertTrue(model.isSimManagerConnected());
+    }
+
+    public void testMessagePanes()
+    {
+        String actual;
+        System.out.println("Tests for message panes.");
+        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
+        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
+        Panel infoPane = mainPanel.getPanel("infoMessagesPane");
+        TextBox infoText = infoPane.getTextBox("infoMessagesTA");
+        actual = infoText.getText().trim();
+        assertEquals("wrong info msg text", ". = Sample Info Message.", actual);
+
+        cadSimLogger.logp(Level.SEVERE, "", "", "Sample Error Message.");
+
+        Panel errPane = mainPanel.getPanel("errorMessagesPane");
+        TextBox errText = errPane.getTextBox("errorMessagesTA");
+        actual = errText.getText().trim();
+        assertEquals("wrong error msg text", ". = Sample Error Message.", actual);
+    }
+
+    public void testStatusChg()
+    {
+        String actual;
+        System.out.println("Tests for status changes.");
+        model.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
+        pause(500);
+        actual = mainPanel.getTextBox("paramicsConnectedTF").getText().trim();
+        assertEquals("paramics connected should be yes", "Yes", actual);
+        actual = mainPanel.getTextBox("networkLoadedTF").getText().trim();
+        assertEquals("network id should be None", "None", actual);
+
+        model.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_STOPPED_NOT_STARTED);
+
+        // The status should now say Ready
+        actual = mainPanel.getTextBox("simulationStatus").getText().trim();
+        assertEquals("sim status should be ready", "Ready", actual);
+
+        model.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING);
+        model.setTime(61L);
+        actual = mainPanel.getTextBox("simulationStatus").getText().trim();
+        assertEquals("sim status should be running", "Running", actual);
+        actual = mainPanel.getTextBox("simulationClockLabel").getText().trim();
+        assertEquals("sim time should be 0:01:01", "0:01:01", actual);
+    }
+
+    public void testNetworkID()
+    {
+        String actual;
+        // this will tell the model it has a new network ID
+        model.setParamicsNetworkLoaded("1");
+        model.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED);
+        pause(500);
+        actual = mainPanel.getTextBox("networkLoadedTF").getText().trim();
+        assertEquals("network id should be 1", "1", actual);
+
+        //  model.updateDVDStatus(new DVDStatusUpdate("1", false, new Throwable()));
+
+    }
+
+    public static void pause(int millis)
+    {
+        try
+        {
+            Thread.sleep(millis);
+        } catch (InterruptedException ex)
+        {
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/BOStest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/BOStest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/BOStest.java	(revision 47)
@@ -0,0 +1,60 @@
+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";
+}
Index: trunk/test/tmcsim/cadsimulator/VisibleSystemDemoDriver.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/VisibleSystemDemoDriver.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/VisibleSystemDemoDriver.java	(revision 47)
@@ -0,0 +1,202 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.rmi.RemoteException;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+import org.uispec4j.*;
+import org.uispec4j.interception.WindowInterceptor;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.paramicscommunicator.PComm;
+import tmcsim.paramicscommunicator.gui.ParamicsCommunicatorGUI;
+import tmcsim.simulationmanager.SimulationManager;
+
+/**
+ * Requires manual starting CADSimulator before running this test. System test
+ * with emulated Paramics Modeler NO ATMS server.
+ *
+ * @author jdalbey
+ */
+public class VisibleSystemDemoDriver extends UISpecTestCase
+{
+
+    SimulationManager simMgrApp;
+
+    public VisibleSystemDemoDriver(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * Test of run method, of class ParamicsCommunicator.
+     */
+    public void testRun() throws ScriptException, SimulationException, RemoteException
+    {
+        System.out.println("Visible System Test starting.");
+        // NOTE: CADSimulator must be started prior to running this test,
+        // because it displays a GUI, and if we try to do it inside this test,
+        // UISpec will complain about an uncaught window appearing.
+
+        PComm pc = null;
+        pc = new PComm("config/testConfig/paramics_communicator_config.properties");
+        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI();
+        pc.setGUI(theGUI);
+        // Note: Don't set visible ANY windows during UISpec test
+
+        // expect pcomm to say "sleeping"
+
+        Window simMgrWindow = null;
+        simMgrWindow = WindowInterceptor.run(new Trigger()
+        {
+            public void run()
+            {
+                try
+                {
+                    simMgrApp = new SimulationManager("config/sim_manager_systest_config.properties");
+                } catch (Exception ex)
+                {
+                    fail("Couldn't launch Simulation Manager, perhaps CADSimulator isn't running.");
+                }
+            }
+        });
+
+        // Check that the Sim Mgr GUI appears without a script loaded yet
+        Panel contentPanel = simMgrWindow.getPanel("contentPane");
+        TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText");
+        assertEquals("No Script", txtSimStatus.getText());
+        TextBox txtParamStatus = contentPanel.getTextBox("paramicsStatusInfoLabel");
+        assertEquals("Unknown", txtParamStatus.getText());
+        Button loadNetworkBtn = simMgrWindow.getButton("Load Network");
+        assertFalse(loadNetworkBtn.isEnabled());
+        // Begin actions
+        Button paramicsBtn = simMgrWindow.getButton("Connect to Paramics");
+        paramicsBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Disconnect from Paramics", paramicsBtn.getLabel());
+
+        assertEquals("Connected", txtParamStatus.getText());
+        pc.startReading();
+
+        loadNetworkBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Sending Network ID", txtParamStatus.getText());
+        System.out.println("Sending Network ID");
+        assertFalse(loadNetworkBtn.isEnabled());
+        String warmingXML = "<Paramics>\n"
+                + "<Network_Status>WARMING</Network_Status>\n"
+                + "<Network_ID>1</Network_ID>\n"
+                + "</Paramics>";
+        writedata("paramics_status.xml", warmingXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Warming Up", txtParamStatus.getText());
+        System.out.println("Warming Up Passed");
+
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        String loadedXML = "<Paramics>\n"
+                + "<Network_Status>LOADED</Network_Status>"
+                + "<Network_ID>1</Network_ID>"
+                + "</Paramics>";
+        writedata("paramics_status.xml", loadedXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Network 1 Loaded", txtParamStatus.getText());
+        System.out.println("Network Loaded Passed");
+
+        // Load a script file
+        String autoloadScriptname = "scripts/audio_systest.xml";
+        simMgrApp.loadScript(new File(autoloadScriptname));
+        try
+        {
+            Thread.sleep(500);
+        } catch (Exception ex)
+        {
+        }
+
+        // The status should now say Ready
+        assertEquals("Ready", txtSimStatus.getText());
+
+        // Click "Start"
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+        assertEquals("Running", txtSimStatus.getText());
+        System.out.println("Running Passed");
+        try
+        {
+            Thread.sleep(9000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        simMgrWindow.getMenuBar().getMenu("File").getSubMenu("Exit").click();
+        System.out.println("Exiting.");
+    }
+
+    // Write the test data to a file
+    public static void writedata(String filename, String data)
+    {
+//        System.out.println("writedata called for " + filename);
+        PrintWriter writer = null;
+        try
+        {
+            writer = new PrintWriter(new FileWriter(filename));
+            writer.println(data);
+            writer.close();
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/SystemTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/SystemTest.java	(revision 47)
+++ trunk/test/tmcsim/cadsimulator/SystemTest.java	(revision 47)
@@ -0,0 +1,228 @@
+package tmcsim.cadsimulator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.rmi.RemoteException;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+import org.uispec4j.*;
+import org.uispec4j.interception.WindowInterceptor;
+import tmcsim.common.ScriptException;
+import tmcsim.common.SimulationException;
+import tmcsim.paramicscommunicator.PComm;
+import tmcsim.paramicscommunicator.ParamicsCommunicator;
+import tmcsim.paramicscommunicator.gui.ParamicsCommunicatorGUI;
+import tmcsim.simulationmanager.SimulationManager;
+
+/**
+ * System test (include CADSimulator) with emulated Paramics Modeler NO ATMS
+ * server captures GUI display using UISpec4J.
+ *
+ * @author jdalbey
+ */
+public class SystemTest extends UISpecTestCase
+{
+
+    SimulationManager simMgrApp;
+    CADSimulator engine;
+    ParamicsCommunicator paramicscomm;
+
+    public SystemTest(String testName)
+    {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * Test of run method, of class ParamicsCommunicator.
+     */
+    public void testRun() throws ScriptException, SimulationException, RemoteException
+    {
+        System.out.println("Invisible System Test");
+        Window cadwindow = null;
+        cadwindow = WindowInterceptor.run(new Trigger()
+        {
+            public void run()
+            {
+                try
+                {
+                    engine = new CADSimulator("config/testConfig/cad_simulator_config.properties");
+                } catch (Exception e)
+                {
+                    fail("Couldn't launch CADSimulator");
+                }
+            }
+        });
+
+        // Check CAD Simulator appears with no script and nothing connected
+        assertTrue("Title bar incorrect", cadwindow.getTitle().trim().startsWith("CAD Simulator"));
+        Panel mainPanel = cadwindow.getPanel("contentPane");
+        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
+        assertEquals("No Script", txtStatus.getText());
+        TextBox terms = mainPanel.getTextBox("termConnectedTF");
+        assertEquals("0", terms.getText().trim());
+        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
+        assertEquals("network id should be None", "None", mainPanel.getTextBox("networkLoadedTF").getText().trim());
+
+        PComm pc = null;
+        pc = new PComm("config/testConfig/paramics_communicator_config.properties");
+        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI();
+        pc.setGUI(theGUI);
+        // Note: Can't set visible ANY windows during UISpec test
+
+        // expect pcomm to say "sleeping"
+
+        Window simMgrWindow = null;
+        simMgrWindow = WindowInterceptor.run(new Trigger()
+        {
+            public void run()
+            {
+                try
+                {
+                    simMgrApp = new SimulationManager("config/sim_manager_systest_config.properties");
+                } catch (Exception ex)
+                {
+                    fail("Couldn't launch Simulation Manager");
+                }
+            }
+        });
+
+        // TODO: Check that the Sim Mgr GUI appears without a script loaded yet
+
+        Panel contentPanel = simMgrWindow.getPanel("contentPane");
+        TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText");
+        assertEquals("No Script", txtSimStatus.getText());
+        TextBox txtParamStatus = contentPanel.getTextBox("paramicsStatusInfoLabel");
+        assertEquals("Unknown", txtParamStatus.getText());
+        Button loadNetworkBtn = simMgrWindow.getButton("Load Network");
+        assertFalse(loadNetworkBtn.isEnabled());
+
+        Button paramicsBtn = simMgrWindow.getButton("Connect to Paramics");
+        paramicsBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Disconnect from Paramics", paramicsBtn.getLabel());
+
+        assertEquals("Connected", txtParamStatus.getText());
+        pc.startReading();
+
+        loadNetworkBtn.click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Sending Network ID", txtParamStatus.getText());
+        System.out.println("Sending Network ID");
+        assertFalse(loadNetworkBtn.isEnabled());
+        String warmingXML = "<Paramics>\n"
+                + "<Network_Status>WARMING</Network_Status>\n"
+                + "<Network_ID>1</Network_ID>\n"
+                + "</Paramics>";
+        writedata("paramics_status.xml", warmingXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Warming Up", txtParamStatus.getText());
+        System.out.println("Warming Up Passed");
+
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        String loadedXML = "<Paramics>\n"
+                + "<Network_Status>LOADED</Network_Status>"
+                + "<Network_ID>1</Network_ID>"
+                + "</Paramics>";
+        writedata("paramics_status.xml", loadedXML);
+        try
+        {
+            Thread.sleep(2100);
+        } catch (Exception ex)
+        {
+        }
+        assertEquals("Network 1 Loaded", txtParamStatus.getText());
+        assertEquals("network id should be 1", "1", mainPanel.getTextBox("networkLoadedTF").getText().trim());
+
+
+        // Load a script file
+        String autoloadScriptname = "scripts/system_test_script.xml";
+        simMgrApp.loadScript(new File(autoloadScriptname));
+        try
+        {
+            Thread.sleep(500);
+        } catch (Exception ex)
+        {
+        }
+
+        // The status should now say Ready
+        assertEquals("Ready", txtSimStatus.getText());
+
+        // Click "Start"
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(200);
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+        assertEquals("Running", txtSimStatus.getText());
+        System.out.println("Running Passed");
+        try
+        {
+            Thread.sleep(9000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Start").click();
+        try
+        {
+            Thread.sleep(3000);
+        } catch (InterruptedException ex)
+        {
+        }
+        simMgrWindow.getButton("Pause").click();
+        simMgrWindow.getMenuBar().getMenu("File").getSubMenu("Exit").click();
+        System.out.println("Exiting.");
+    }
+
+    // Write the test data to a file
+    public static void writedata(String filename, String data)
+    {
+        PrintWriter writer = null;
+        try
+        {
+            writer = new PrintWriter(new FileWriter(filename));
+            writer.println(data);
+            writer.close();
+        } catch (Exception ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorNetworkTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorNetworkTest.java	(revision 28)
+++ 	(revision )
@@ -1,174 +1,0 @@
-package tmcsim.cadsimulator;
-
-import java.io.File;
-import java.rmi.RemoteException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.fail;
-import static org.mockito.Mockito.*;
-import org.uispec4j.*;
-import org.uispec4j.interception.WindowInterceptor;
-import tmcsim.cadsimulator.managers.ParamicsSimulationManager;
-import tmcsim.common.CADEnums;
-import tmcsim.common.ScriptException;
-import tmcsim.common.SimulationException;
-import tmcsim.interfaces.CADClientInterface;
-import tmcsim.interfaces.SimulationManagerInterface;
-import tmcsim.paramicscommunicator.ParamicsCommunicator;
-
-/**
- * Test of CADSimulator GUI
- *
- * @author jdalbey
- */
-public class CADSimulatorNetworkTest extends UISpecTestCase
-{
-
-    static final String configData =
-            "CADClientPort          = 4444 \n"
-            + "CoordinatorRMIPort     = 4445 \n"
-            + "CADRmiPort             = 4446 \n"
-            + "UserInterface          = tmcsim.cadsimulator.viewer.CADSimulatorViewer\n"
-            + "ParamicsProperties     = pconfig.txt\n"
-            + "ATMSProperties         = empty.txt\n"
-            + "MediaProperties        = empty.txt\n";
-
-    public CADSimulatorNetworkTest(String testName)
-    {
-        super(testName);
-    }
-
-    @Override
-    public void tearDown() throws java.io.IOException
-    {
-        File removeMe = new File("config.txt");
-        removeMe.delete();
-        removeMe = new File("pconfig.txt");
-        removeMe.delete();
-        removeMe = new File("empty.txt");
-        removeMe.delete();
-        removeMe = new File("pmcprops.txt");
-        removeMe.delete();
-    }
-
-    /**
-     * Test of getCADTime method, of class CADSimulator.
-     */
-    public void testGetCADTime()
-    {
-        System.out.println("getCADTime");
-        String result = CADSimulator.getCADTime();
-        // Just test length for now
-        assertEquals(4, result.length());
-    }
-
-    /**
-     * Test of getCADDate method, of class CADSimulator.
-     */
-    public void testGetCADDate()
-    {
-        System.out.println("getCADDate");
-        String result = CADSimulator.getCADDate();
-        // Just test length for now
-        assertEquals(6, result.length());
-    }
-    /**
-     * Test of main method, of class CADSimulator.
-     */
-    CADSimulator app;
-
-    public void testConstructor() throws SimulationException, RemoteException, ScriptException
-    {
-        CADSimulatorFixture.writeConfigData();
-        CADSimulatorFixture.writedata("config.txt", configData);
-        System.out.println("CADSimulator constructor");
-        System.setProperty("CAD_SIM_PROPERTIES", "config.txt");
-        Window cadwindow = null;
-        if (System.getProperty("CAD_SIM_PROPERTIES") != null)
-        {
-            cadwindow = WindowInterceptor.run(new Trigger()
-            {
-                public void run()
-                {
-                    try
-                    {
-                        app = new CADSimulator(System.getProperty("CAD_SIM_PROPERTIES"));
-                    } catch (Exception e)
-                    {
-                        fail("Couldn't launch CADSimulator" + e.getMessage());
-                    }
-                }
-            });
-        } else
-        {
-            fail("CAD_SIM_PROPERTIES system property not defined.");
-        }
-        assertEquals("CAD Simulator", cadwindow.getTitle());
-        Panel mainPanel = cadwindow.getPanel("contentPane");
-        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
-        assertEquals("No Script", txtStatus.getText());
-        TextBox terminals = mainPanel.getTextBox("termConnectedTF");
-        assertEquals("0", terminals.getText().trim());
-        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-        assertEquals("0:00:00", mainPanel.getTextBox("simulationClockLabel").getText());
-
-        CADClientInterface ci = mock (CADClientInterface.class);
-        app.theCoordinator.registerForCallback(ci);
-        assertEquals("1", terminals.getText().trim());
-        app.theCoordinator.registerForCallback(ci);
-        assertEquals("2", terminals.getText().trim());
-
-        SimulationManagerInterface si = mock(SimulationManagerInterface.class);
-        app.theCoordinator.registerForCallback(si);
-        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-
-
-        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED);
-        CADSimulatorFixture.pause(500);
-        assertEquals("Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
-        assertEquals("None", mainPanel.getTextBox("networkLoadedTF").getText().trim());
-
-String loadedXML = "<Paramics>\n"
-    + "<Network_Status>LOADED</Network_Status>"
-    + "<Network_ID>1</Network_ID>"
-    + "</Paramics>";
-
-//         Thread pmc = new Thread(new ParamicsCommunicator("pmcprops.txt"));
-//        pmc.start();
-//        pmc.stop();
-        /*
-         * Start Paramics Controller.
-         * app.theCoordinator.connectToParamics();
-        CADSimulatorFixture.pause(500);
-        assertEquals("Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim());
-           theCoorInt.loadParamicsNetwork(networkID);
-         * Optional: assert Status is "Sending Network ID" in Sim Mgr
-         * When "
-         * paramics_status.xml becomes 
-<Paramics>
-<Network_Status>WARMING</Network_Status>
-<Network_ID>1</Network_ID>
-</Paramics>
-*          then Sim Mgr status becomes "Warming up"
- When paramics_status.xml becomes loadedXML
-CADSimulatorFixture.writedata(loadedXML, "paramics_status.xml");
-pause()
-       then Sim MGr status becomes Network Loaded and
- CADSimulator Netowrk Loaded field says "1".
- * 
- * When "Load Script" happens, Camera Status is sent to Paramics Comm.
-* 
-         */
-        ParamicsSimulationManager psm = mock(ParamicsSimulationManager.class);
-        when(psm.isConnected()).thenReturn(Boolean.TRUE);
-        app.theParamicsSimMgr = psm;
-        app.theCoordinator.loadParamicsNetwork(1);
-        // Load a script file
-        String autoloadScriptname = "scripts/one-incident.xml";
-        app.theCoordinator.loadScriptFile(new File(autoloadScriptname));
-        // The status should now say Ready
-        assertEquals("Ready", mainPanel.getTextBox("simulationStatus").getText().trim());
-    }
-
-}
Index: trunk/test/tmcsim/cadsimulator/CADSimulatorTest.java
===================================================================
--- trunk/test/tmcsim/cadsimulator/CADSimulatorTest.java	(revision 34)
+++ 	(revision )
@@ -1,167 +1,0 @@
-package tmcsim.cadsimulator;
-
-import java.rmi.RemoteException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.JScrollPane;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.fail;
-import org.uispec4j.*;
-import org.uispec4j.interception.WindowInterceptor;
-import tmcsim.client.CADClient;
-import tmcsim.client.cadclientgui.data.Incident;
-import tmcsim.client.cadclientgui.data.IncidentEvent;
-import tmcsim.common.CADEnums;
-import tmcsim.common.SimulationException;
-import tmcsim.interfaces.CADClientInterface;
-import tmcsim.interfaces.SimulationManagerInterface;
-
-/**
- * Test of CADSimulator GUI
- *
- * @author jdalbey
- */
-public class CADSimulatorTest extends UISpecTestCase
-{
-
-    public CADSimulatorTest(String testName)
-    {
-        super(testName);
-    }
-
-    /**
-     * Test of getCADTime method, of class CADSimulator.
-     */
-    public void testGetCADTime()
-    {
-        System.out.println("getCADTime");
-        String result = CADSimulator.getCADTime();
-        // Just test length for now
-        assertEquals(4, result.length());
-    }
-
-    /**
-     * Test of getCADDate method, of class CADSimulator.
-     */
-    public void testGetCADDate()
-    {
-        System.out.println("getCADDate");
-        String result = CADSimulator.getCADDate();
-        // Just test length for now
-        assertEquals(6, result.length());
-    }
-    /**
-     * Test of main method, of class CADSimulator.
-     */
-    CADSimulator app;
-
-    public void testConstructor() throws SimulationException, RemoteException
-    {
-        System.out.println("CADSimulator constructor");
-        System.setProperty("CONFIG_DIR", "config/testConfig");
-        Window cadwindow = null;
-        if (System.getProperty("CONFIG_DIR") != null)
-        {
-            cadwindow = WindowInterceptor.run(new Trigger()
-            {
-                public void run()
-                {
-                    try
-                    {
-                        app = new CADSimulator(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + "cad_simulator_config.properties");
-                    }
-                    catch (Exception e)
-                    {
-                        fail("Couldn't launch CADSimulator");
-                    }
-                }
-            });
-        }
-        else
-        {
-            fail("CONFIG_DIR system property not defined.");
-        }
-        assertEquals("CAD Simulator", cadwindow.getTitle());
-        Panel mainPanel = cadwindow.getPanel("contentPane");
-        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
-        assertEquals("No Script", txtStatus.getText());
-        TextBox terminals = mainPanel.getTextBox("termConnectedTF");
-        assertEquals("0", terminals.getText().trim());
-        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-
-        CADClientInterface ci = new CADSimulatorTest.FakeClient();
-        app.theCoordinator.registerForCallback(ci);
-        assertEquals("1", terminals.getText().trim());
-        app.theCoordinator.registerForCallback(ci);
-        assertEquals("2", terminals.getText().trim());
-
-        SimulationManagerInterface si = new CADSimulatorTest.FakeSimMgr();
-        app.theCoordinator.registerForCallback(si);
-        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
-
-        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
-        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
-
-        Panel infoPane = mainPanel.getPanel("InfoMessagesPane");
-        TextBox infoText = infoPane.getTextBox("infoMessagesTA");
-        assertEquals(". = Sample Info Message.\n", infoText.getText());
-
-        app = null;
-    }
-
-    class FakeClient implements CADClientInterface
-    {
-
-        @Override
-        public void refresh() throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-    }
-
-    class FakeSimMgr implements SimulationManagerInterface
-    {
-
-        @Override
-        public void tick(long theTime) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void eventOccured(Integer logNumber, IncidentEvent theEvent) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void incidentAdded(Incident newIncident) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void incidentStarted(Integer logNumber) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void incidentRemoved(Integer logNumber) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void setScriptStatus(CADEnums.SCRIPT_STATUS newStatus) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-
-        @Override
-        public void setParamicsStatus(CADEnums.PARAMICS_STATUS newStatus) throws RemoteException
-        {
-            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-        }
-    }
-}
