Ignore:
Timestamp:
04/26/2016 06:50:09 PM (10 years ago)
Author:
jdalbey
Message:

CADSimulatorNetworkTest added, modifed ParamicsCommunicator? to check for a property if it should run without a GUI (for testing).

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/test/tmcsim/cadsimulator/CADSimulatorNetworkTest.java

    r19 r26  
    1616import tmcsim.interfaces.CADClientInterface; 
    1717import tmcsim.interfaces.SimulationManagerInterface; 
     18import tmcsim.paramicscommunicator.ParamicsCommunicator; 
    1819 
    1920/** 
     
    2223 * @author jdalbey 
    2324 */ 
    24 public class CADSimulatorGUITest extends UISpecTestCase 
     25public class CADSimulatorNetworkTest extends UISpecTestCase 
    2526{ 
    2627 
     
    3435            + "MediaProperties        = empty.txt\n"; 
    3536 
    36     public CADSimulatorGUITest(String testName) 
     37    public CADSimulatorNetworkTest(String testName) 
    3738    { 
    3839        super(testName); 
     
    4748        removeMe.delete(); 
    4849        removeMe = new File("empty.txt"); 
     50        removeMe.delete(); 
     51        removeMe = new File("pmcprops.txt"); 
    4952        removeMe.delete(); 
    5053    } 
     
    111114        assertEquals("0:00:00", mainPanel.getTextBox("simulationClockLabel").getText()); 
    112115 
    113         CADClientInterface ci = new FakeClient(); 
     116        CADClientInterface ci = mock (CADClientInterface.class); 
    114117        app.theCoordinator.registerForCallback(ci); 
    115118        assertEquals("1", terminals.getText().trim()); 
     
    121124        assertEquals("Yes", mainPanel.getTextBox("managerConnectedTF").getText().trim()); 
    122125 
    123         Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator"); 
    124         cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message."); 
    125  
    126         Panel infoPane = mainPanel.getPanel("infoMessagesPane"); 
    127         TextBox infoText = infoPane.getTextBox("infoMessagesTA"); 
    128         assertEquals(". = Sample Info Message.", infoText.getText().trim()); 
    129  
    130         cadSimLogger.logp(Level.SEVERE, "", "", "Sample Error Message."); 
    131  
    132         Panel errPane = mainPanel.getPanel("errorMessagesPane"); 
    133         TextBox errText = errPane.getTextBox("errorMessagesTA"); 
    134         assertEquals(". = Sample Error Message.", errText.getText().trim()); 
    135126 
    136127        app.theCoordinator.setParamicsStatus(CADEnums.PARAMICS_STATUS.CONNECTED); 
     
    139130        assertEquals("None", mainPanel.getTextBox("networkLoadedTF").getText().trim()); 
    140131 
    141 //        app.theCoordinator.setScriptStatus(CADEnums.SCRIPT_STATUS.SCRIPT_RUNNING); 
    142 //        assertEquals("Running", mainPanel.getTextBox("simulationStatus").getText().trim()); 
     132String loadedXML = "<Paramics>\n" 
     133    + "<Network_Status>LOADED</Network_Status>" 
     134    + "<Network_ID>1</Network_ID>" 
     135    + "</Paramics>"; 
    143136 
     137//         Thread pmc = new Thread(new ParamicsCommunicator("pmcprops.txt")); 
     138//        pmc.start(); 
     139//        pmc.stop(); 
     140        /* 
     141         * Start Paramics Controller. 
     142         * app.theCoordinator.connectToParamics(); 
     143        CADSimulatorFixture.pause(500); 
     144        assertEquals("Yes", mainPanel.getTextBox("paramicsConnectedTF").getText().trim()); 
     145           theCoorInt.loadParamicsNetwork(networkID); 
     146         * Optional: assert Status is "Sending Network ID" in Sim Mgr 
     147         * When " 
     148         * paramics_status.xml becomes  
     149<Paramics> 
     150<Network_Status>WARMING</Network_Status> 
     151<Network_ID>1</Network_ID> 
     152</Paramics> 
     153*          then Sim Mgr status becomes "Warming up" 
     154 When paramics_status.xml becomes loadedXML 
     155CADSimulatorFixture.writedata(loadedXML, "paramics_status.xml"); 
     156pause() 
     157       then Sim MGr status becomes Network Loaded and 
     158 CADSimulator Netowrk Loaded field says "1". 
     159*  
     160         */ 
     161        ParamicsSimulationManager psm = mock(ParamicsSimulationManager.class); 
     162        when(psm.isConnected()).thenReturn(Boolean.TRUE); 
     163        app.theParamicsSimMgr = psm; 
     164        app.theCoordinator.loadParamicsNetwork(1); 
    144165        // Load a script file 
    145166        String autoloadScriptname = "scripts/one-incident.xml"; 
     
    147168        // The status should now say Ready 
    148169        assertEquals("Ready", mainPanel.getTextBox("simulationStatus").getText().trim()); 
    149  
    150         app.theCoordinator.startSimulation(); 
    151         CADSimulatorFixture.pause(500); 
    152         assertEquals("Running", mainPanel.getTextBox("simulationStatus").getText().trim()); 
    153         assertEquals("0:00:01", mainPanel.getTextBox("simulationClockLabel").getText()); 
    154  
    155         ParamicsSimulationManager psm = mock(ParamicsSimulationManager.class); 
    156         when(psm.isConnected()).thenReturn(Boolean.TRUE); 
    157         app.theParamicsSimMgr = psm; 
    158         app.theCoordinator.loadParamicsNetwork(1); 
    159  
    160 //        app.theViewer.dispose(); 
    161 //        Window confirmPopup = null; 
    162 //        confirmPopup = WindowInterceptor.run(new Trigger() 
    163 //        { 
    164 //            public void run() 
    165 //            { 
    166 //                app.theViewer.closeViewer(); 
    167 //            } 
    168 //        }); 
    169 //        confirmPopup.getButton("OK").click(); 
    170170    } 
    171171 
    172     class FakeClient implements CADClientInterface 
    173     { 
    174  
    175         @Override 
    176         public void refresh() throws RemoteException 
    177         { 
    178         } 
    179     } 
    180172} 
Note: See TracChangeset for help on using the changeset viewer.