Warning: Can't use blame annotator:
svn blame failed on trunk/test/tmcsim/simulationmanager/SimulationManagerSmokeTest.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/trunk/test/tmcsim/simulationmanager/SimulationManagerSmokeTest.java @ 34

Revision 34, 4.2 KB checked in by bokumura, 10 years ago (diff)

Change unit tests to work with the new config directory restructure.

RevLine 
1package tmcsim.simulationmanager;
2
3import java.io.File;
4import static junit.framework.Assert.assertEquals;
5import static junit.framework.Assert.fail;
6import org.uispec4j.*;
7import org.uispec4j.interception.WindowInterceptor;
8import tmcsim.cadsimulator.CADSimulator;
9import tmcsim.common.ScriptException;
10import tmcsim.common.SimulationException;
11
12/**
13 * Smoke Test of system. Start the CAD server, Start the Sim Mgr, see if the Sim
14 * Mgr view shows "No Script".
15 *
16 * @author jdalbey
17 */
18public class SimulationManagerSmokeTest extends UISpecTestCase
19{
20
21    SimulationManager simMgrApp;
22    CADSimulator engine;
23
24    public SimulationManagerSmokeTest(String testName)
25    {
26        super(testName);
27    }
28
29    /**
30     * Call constructors for both classes
31     */
32    public void testBothGUIs() throws ScriptException, SimulationException
33    {
34        System.out.println("Smoke Test Sim Mgr & CADSimulator");
35
36        Window cadwindow = null;
37        System.setProperty("CONFIG_DIR", "config/testConfig");
38        if (System.getProperty("CONFIG_DIR") != null)
39        {
40            cadwindow = WindowInterceptor.run(new Trigger()
41            {
42                public void run()
43                {
44                    try
45                    {
46                        engine = new CADSimulator(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + "cad_simulator_config.properties");
47
48                    } catch (Exception e)
49                    {
50                        fail("Couldn't launch CADSimulator");
51                    }
52                }
53            });
54        } else
55        {
56            fail("CONFIG_DIR system property not defined.");
57        }
58
59        // Check CAD Simulator appears with no script and nothing connected
60        assertEquals("CAD Simulator", cadwindow.getTitle());
61        Panel mainPanel = cadwindow.getPanel("contentPane");
62        TextBox txtStatus = mainPanel.getTextBox("simulationStatus");
63        assertEquals("No Script", txtStatus.getText());
64        TextBox terms = mainPanel.getTextBox("termConnectedTF");
65        assertEquals("0", terms.getText().trim());
66        assertEquals("No", mainPanel.getTextBox("managerConnectedTF").getText().trim());
67
68        Window simMgrWindow = null;
69        System.setProperty("CONFIG_DIR", "config/testConfig");
70        if (System.getProperty("CONFIG_DIR") != null)
71        {
72            simMgrWindow = WindowInterceptor.run(new Trigger()
73            {
74                public void run()
75                {
76                    try
77                    {
78                        //simMgrApp = new SimulationManager(System.getProperty("SIM_MGR_PROPERTIES"));
79                        simMgrApp = new SimulationManager(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + "sim_manager_config.properties");
80                    } catch (Exception ex)
81                    {
82                        fail("Couldn't launch Simulation Manager");
83                    }
84                }
85            });
86        } else
87        {
88            fail("CONFIG_DIR system property not defined.");
89        }
90
91        // Check that the Sim Mgr GUI appears without a script loaded yet
92        SimulationManagerView view = simMgrApp.theSimManagerView;
93        assertFalse(view.isSimulationStarted());
94        Window win = new Window(view);
95        Panel contentPanel = win.getPanel("contentPane");
96        TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText");
97        assertEquals("No Script", txtSimStatus.getText());
98
99        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim());
100
101        // Load a script file
102        String autoloadScriptname = "scripts/practice_script_2016.xml";
103        SimulationManagerModel simMgrModel = simMgrApp.theSimManagerModel;
104        simMgrModel.loadScript(new File(autoloadScriptname));
105        // The status should now say Ready
106        assertEquals("Ready", txtSimStatus.getText());
107
108        // Click "Start"
109        win.getButton("Start").click();
110        try
111        {
112            Thread.sleep(200);
113        } catch (Exception ex)
114        {
115            ex.printStackTrace();
116        }
117        assertEquals("Running", txtSimStatus.getText());
118
119        // Quit
120        engine = null;
121        simMgrApp = null;
122    }
123}
Note: See TracBrowser for help on using the repository browser.