- Timestamp:
- 09/12/2022 01:30:08 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
src/tmcsim/cadsimulator/Coordinator.java (modified) (1 diff)
-
test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java (modified) (3 diffs)
-
test/tmcsim/cadsimulator/SystemTest.java (modified) (3 diffs)
-
test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java (modified) (2 diffs)
-
test/tmcsim/highwaymodel/LoadHighwaysTest.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/Coordinator.java
r560 r657 609 609 Path source = Paths.get(selectedFile); 610 610 Files.copy(source, destination,REPLACE_EXISTING); 611 Logger.getLogger(Coordinator.class.getName()).log(Level.INFO,612 "Loaded script copied to " + destination);611 //Logger.getLogger(Coordinator.class.getName()).log(Level.INFO, 612 // "Loaded script copied to " + destination); 613 613 } catch (IOException ex) { 614 614 Logger.getLogger(Coordinator.class.getName()).log(Level.SEVERE, null, ex); -
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 } -
trunk/test/tmcsim/highwaymodel/LoadHighwaysTest.java
r653 r657 18 18 */ 19 19 public class LoadHighwaysTest extends TestCase { 20 // Setup a path for temp files 21 static String tmpPath = "/tmp/";// default path is for linux 22 static 23 { 24 String myOs = System.getProperty("os.name").toLowerCase(); 25 if (myOs.indexOf("win") >= 0) 26 { 27 tmpPath = "C:/TEMP/"; // alt path for Windows 28 } 29 } 20 30 21 31 public LoadHighwaysTest(String testName) { … … 28 38 PrintWriter writer = null; 29 39 try { 30 writer = new PrintWriter(new FileWriter( "/tmp/postmiles1.txt"));40 writer = new PrintWriter(new FileWriter(tmpPath + "postmiles1.txt")); 31 41 writer.println("5 S 0.9,33.408425,-117.599923,CALAFIA,0,0"); 32 42 writer.println("5 N 1.24,33.413051,-117.601964,MAGDALENA,0,0"); 33 43 writer.println("5 S 1.49,33.416348,-117.603827,EL CAMINO REAL,0,0"); 34 44 writer.close(); 35 writer = new PrintWriter(new FileWriter( "/tmp/postmiles3.txt"));45 writer = new PrintWriter(new FileWriter(tmpPath + "postmiles3.txt")); 36 46 writer.println("73 N 23.9,33.643656,-117.859875,BISON 2,0.976131,0.217185"); 37 47 writer.println("55 S 6.88,33.697495,-117.862677,MACARTHU1,-0.710326,0.703873"); … … 49 59 protected void tearDown() throws Exception { 50 60 super.tearDown(); 51 Path path = FileSystems.getDefault().getPath( "/tmp", "postmiles1.txt");61 Path path = FileSystems.getDefault().getPath(tmpPath, "postmiles1.txt"); 52 62 Files.delete(path); 53 path = FileSystems.getDefault().getPath( "/tmp", "postmiles3.txt");63 path = FileSystems.getDefault().getPath(tmpPath, "postmiles3.txt"); 54 64 Files.delete(path); 55 65 } … … 61 71 System.out.println("testLoadHighways"); 62 72 Highways highways = new Highways( 63 "/tmp/postmiles1.txt");73 tmpPath + "postmiles1.txt"); 64 74 65 75 // Test for correct number of highways … … 97 107 System.out.println("testLoadHighways2"); 98 108 Highways highways = new Highways( 99 "/tmp/postmiles3.txt");109 tmpPath + "postmiles3.txt"); 100 110 101 111 // Test for correct number of highways
Note: See TracChangeset
for help on using the changeset viewer.
