Changeset 657 in tmcsimulator for trunk/test/tmcsim/cadsimulator
- Timestamp:
- 09/12/2022 01:30:08 PM (4 years ago)
- Location:
- trunk/test/tmcsim/cadsimulator
- Files:
-
- 3 edited
-
CADSimulatorConsoleTest.java (modified) (3 diffs)
-
SystemTest.java (modified) (3 diffs)
-
viewer/CADConsoleViewerTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java
r656 r657 85 85 private void verify(String errmsg, String expect) 86 86 { 87 String[] results = sw.toString().trim().split("\n"); // split into lines 87 88 String result = sw.toString().trim().replace("\r",""); // Remove windows line feed characters 89 String[] results = result.split("\n"); //System.getProperty("line.separator")); // split into lines 88 90 String[] expecteds = expect.trim().split("\n"); 89 91 int rIdx = results.length-1; // index to results array … … 234 236 + "Network Loaded : None\n" 235 237 + "-- Info Messages --\n" 236 + ". = Console Info Message." 237 + "tmcsim.cadsimulator.Coordinator.copyXMLfile = Loaded script copied to webapps/dynamicdata/incident_script.xml\n" 238 + ". = Console Info Message.\n" 238 239 + "-- Error Messages --\n" 239 240 + "Someclass.Somemethod = Sample error message.\n"; … … 247 248 + "Network Loaded : None\n" 248 249 + "-- Info Messages --\n" 249 + ". = Console Info Message." 250 + "tmcsim.cadsimulator.Coordinator.copyXMLfile = Loaded script copied to webapps/dynamicdata/incident_script.xml\n" 250 + ". = Console Info Message.\n" 251 251 + "-- Error Messages --\n" 252 252 + "Someclass.Somemethod = Sample error message.\n"; -
trunk/test/tmcsim/cadsimulator/SystemTest.java
r653 r657 62 62 }); 63 63 64 // Check CAD S imulator appears with no script and nothing connected64 // Check CAD Server appears with no script and nothing connected 65 65 assertTrue("Title bar incorrect", cadwindow.getTitle().trim().startsWith("CAD Server")); 66 66 Panel mainPanel = cadwindow.getPanel("contentPane"); … … 72 72 assertEquals("network id should be None", "None", mainPanel.getTextBox("networkLoadedTF").getText().trim()); 73 73 74 ParamicsCommunicator pc = null; 75 pc = new ParamicsCommunicator("config/paramics_communicator_config.properties"); 76 ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI(); 77 pc.setGUI(theGUI); 74 78 75 // Note: Can't set visible ANY windows during UISpec test 79 80 // expect pcomm to say "sleeping"81 76 82 77 Window simMgrWindow = null; … … 100 95 TextBox txtSimStatus = contentPanel.getTextBox("simulationStatusText"); 101 96 assertEquals("No Script", txtSimStatus.getText()); 102 TextBox txtParamStatus = contentPanel.getTextBox("paramicsStatusInfoLabel");103 assertEquals("Unknown", txtParamStatus.getText());104 Button loadNetworkBtn = simMgrWindow.getButton("Load Network");105 assertFalse(loadNetworkBtn.isEnabled());106 107 Button paramicsBtn = simMgrWindow.getButton("Connect to Paramics");108 paramicsBtn.click();109 try110 {111 Thread.sleep(200);112 } catch (Exception ex)113 {114 }115 assertEquals("Disconnect from Paramics", paramicsBtn.getLabel());116 117 assertEquals("Connected", txtParamStatus.getText());118 pc.startReading();119 120 loadNetworkBtn.click();121 try122 {123 Thread.sleep(200);124 } catch (Exception ex)125 {126 }127 assertEquals("Sending Network ID", txtParamStatus.getText());128 System.out.println("Sending Network ID");129 assertFalse(loadNetworkBtn.isEnabled());130 String warmingXML = "<Paramics>\n"131 + "<Network_Status>WARMING</Network_Status>\n"132 + "<Network_ID>1</Network_ID>\n"133 + "</Paramics>";134 writedata("paramics_status.xml", warmingXML);135 try136 {137 Thread.sleep(2100);138 } catch (Exception ex)139 {140 }141 assertEquals("Warming Up", txtParamStatus.getText());142 System.out.println("Warming Up Passed");143 144 try145 {146 Thread.sleep(2100);147 } catch (Exception ex)148 {149 }150 String loadedXML = "<Paramics>\n"151 + "<Network_Status>LOADED</Network_Status>"152 + "<Network_ID>1</Network_ID>"153 + "</Paramics>";154 writedata("paramics_status.xml", loadedXML);155 try156 {157 Thread.sleep(2100);158 } catch (Exception ex)159 {160 }161 //assertEquals("Network 1 Loaded", txtParamStatus.getText());162 //assertEquals("network id should be 1", "1", mainPanel.getTextBox("networkLoadedTF").getText().trim());163 97 164 98 -
trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java
r455 r657 34 34 console.setWriter(sw); 35 35 } 36 /** 37 * compare StringWriter contents against expected 36 /** compare StringWriter contents against expected 37 * @param expected contains just the most recent lines of output 38 * @param errmsg message to be displayed if test fails 39 * improved to verify line by line 38 40 */ 39 private void verify(String msg, String expect) 40 { 41 String result = sw.toString().trim(); 42 result = result.replaceAll("\n", ","); 43 String fullExpect = expect.trim(); 44 fullExpect = fullExpect.replaceAll("\n", ","); 45 assertTrue(msg + ": " + result, result.endsWith(fullExpect)); 46 } 41 private void verify(String errmsg, String expect) 42 { 43 44 String result = sw.toString().trim().replace("\r",""); // Remove windows line feed characters 45 String[] results = result.split("\n"); //System.getProperty("line.separator")); // split into lines 46 String[] expecteds = expect.trim().split("\n"); 47 int rIdx = results.length-1; // index to results array 48 // Work backwards from the most recent line of output 49 for (int eIdx=expecteds.length-1; eIdx >= 0; eIdx--) 50 { 51 //System.out.println("Verifying "+eIdx+". "+expecteds[eIdx]+" against "+results[rIdx]); 52 assertEquals(errmsg + " line "+eIdx, expecteds[eIdx], results[rIdx]); 53 rIdx--; 54 } 55 } 47 56 48 57 public static void pause(int millis) … … 233 242 } 234 243 235 public void testNetworkID() 236 { 237 String expected10 = 238 "--- CAD Simulator ---\n" 239 + "Elapsed Simulation Time : 0:00:00\n" 240 + "Status : No Script\n" 241 + "Connected CAD Terminals : 0\n" 242 + "Simulation Manager Connected: No\n" 243 + "Connected to Paramics : No\n" 244 + "Network Loaded : 17\n" 245 + "-- Info Messages --\n\n" 246 + "-- Error Messages --\n\n"; 247 // this will tell the model it has a new network ID 248 cadmodel.setParamicsNetworkLoaded("17"); 249 cadmodel.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED); 250 pause(500); 251 verify("network id should be 17", expected10); 252 } 244 253 245 }
Note: See TracChangeset
for help on using the changeset viewer.
