Changeset 655 in tmcsimulator for trunk/test
- Timestamp:
- 09/11/2022 04:28:42 PM (4 years ago)
- Location:
- trunk/test/tmcsim
- Files:
-
- 2 edited
-
cadsimulator/CADSimulatorConsoleTest.java (modified) (5 diffs)
-
highwaymodel/HighwaysTest.java (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java
r653 r655 30 30 private CADConsoleViewer console; 31 31 private StringWriter sw; 32 32 // Setup a path for temp files 33 static String tmpPath = "/tmp/";// default path is for linux 34 static 35 { 36 String myOs = System.getProperty("os.name").toLowerCase(); 37 if (myOs.indexOf("win") >= 0) 38 { 39 tmpPath = "C:/TEMP/"; // alt path for Windows 40 } 41 } 33 42 public CADSimulatorConsoleTest(String testName) 34 43 { … … 70 79 71 80 /** 72 * compare StringWriter contents against expected81 * obsolete: compare StringWriter contents against expected 73 82 */ 74 private void verify (String msg, String expect)83 private void verify0(String msg, String expect) 75 84 { 76 85 String result = sw.toString().trim(); … … 85 94 assertTrue(msg + ": " + result, match); 86 95 } 87 96 /** compare StringWriter contents against expected 97 * @param expected contains just the most recent lines of output 98 * @param errmsg message to be displayed if test fails 99 * improved to verify line by line 100 */ 101 private void verify(String errmsg, String expect) 102 { 103 String[] results = sw.toString().trim().split("\n"); // split into lines 104 String[] expecteds = expect.trim().split("\n"); 105 // Work backwards from the most recent line of output 106 for (int item=expecteds.length-1; item >= 0; item--) 107 { 108 //System.out.println("Verifying "+expecteds[item]+" against "+results[item]); 109 assertEquals(errmsg + " line "+item, expecteds[item], results[item]); 110 } 111 } 88 112 public static void pause(int millis) 89 113 { … … 134 158 CADClientInterface ci = mock(CADClientInterface.class); 135 159 app.theCoordinator.registerForCallback(ci); 160 pause(500); 136 161 verify("connected 1 terminal output incorrect: ", expected2); 137 162 String expected3 = … … 286 311 +"FEPSim_IP_addr = localhost\n" 287 312 +"Output_Destination = Console\n" 288 +"Highway_Status_File = /tmp/highway_status.json\n";313 +"Highway_Status_File = "+tmpPath+"highway_status.json\n"; 289 314 static final String paramicsData = "ParamicsCommHost = 127.0.0.1\n" 290 315 + "ParamicsCommPort = 4450\n" -
trunk/test/tmcsim/highwaymodel/HighwaysTest.java
r653 r655 22 22 public class HighwaysTest extends TestCase { 23 23 24 // Setup a path for temp files 25 static String tmpPath = "/tmp/";// default path is for linux 26 static 27 { 28 String myOs = System.getProperty("os.name").toLowerCase(); 29 if (myOs.indexOf("win") >= 0) 30 { 31 tmpPath = "C:/TEMP/"; // alt path for Windows 32 } 33 } 34 35 24 36 public HighwaysTest(String testName) { 25 37 super(testName); … … 31 43 PrintWriter writer = null; 32 44 try { 33 writer = new PrintWriter(new FileWriter( "/tmp/postmiles1.txt"));45 writer = new PrintWriter(new FileWriter(tmpPath + "postmiles1.txt")); 34 46 writer.println("5 S 0.9,33.408425,-117.599923,CALAFIA,0,0"); 35 47 writer.println("5 N 1.24,33.413051,-117.601964,MAGDALENA,0,0"); … … 37 49 writer.close(); 38 50 39 writer = new PrintWriter(new FileWriter( "/tmp/postmiles2.txt"));51 writer = new PrintWriter(new FileWriter(tmpPath + "postmiles2.txt")); 40 52 writer.println("5 N 5.89,33.459637,-117.657305,ESTRELLA2,0,0"); 41 53 writer.println("5 S 6.47,33.464281,-117.665631,SACRAMENTO,-0.56275,-0.826627"); … … 47 59 writer.close(); 48 60 49 writer = new PrintWriter(new FileWriter( "/tmp/postmiles3.txt"));61 writer = new PrintWriter(new FileWriter(tmpPath + "/postmiles3.txt")); 50 62 writer.println("73 N 23.9,33.643656,-117.859875,BISON 2,0.976131,0.217185"); 51 63 writer.println("55 S 6.88,33.697495,-117.862677,MACARTHU1,-0.710326,0.703873"); … … 63 75 protected void tearDown() throws Exception { 64 76 super.tearDown(); 65 Path path = FileSystems.getDefault().getPath( "/tmp/", "postmiles1.txt");77 Path path = FileSystems.getDefault().getPath(tmpPath, "postmiles1.txt"); 66 78 Files.delete(path); 67 path = FileSystems.getDefault().getPath( "/tmp/", "postmiles2.txt");79 path = FileSystems.getDefault().getPath(tmpPath, "postmiles2.txt"); 68 80 Files.delete(path); 69 path = FileSystems.getDefault().getPath( "/tmp/", "postmiles3.txt");81 path = FileSystems.getDefault().getPath(tmpPath, "postmiles3.txt"); 70 82 Files.delete(path); 71 83 } … … 74 86 System.out.println("test FindStation()"); 75 87 Highways highways = new Highways( 76 "/tmp/postmiles1.txt");88 tmpPath + "postmiles1.txt"); 77 89 assertTrue(null != highways.findStation(5, DIRECTION.SOUTH, 0.9)); 78 90 assertTrue(null != highways.findStation(5, DIRECTION.SOUTH, 1.49)); … … 86 98 System.out.println("toString"); 87 99 Highways highways = new Highways( 88 "/tmp/postmiles2.txt");100 tmpPath + "postmiles2.txt"); 89 101 highways.getHighwayByRouteNumber(5).stations.get(0).loops.get(0).vol = 1; 90 102 String result = highways.toString(); … … 108 120 System.out.println("toJson"); 109 121 Highways highways = new Highways( 110 "/tmp/postmiles1.txt");122 tmpPath + "postmiles1.txt"); 111 123 String result = highways.toJson(); 112 124 System.out.println(result); … … 130 142 System.out.println("stationSort"); 131 143 Highways highways = new Highways( 132 "/tmp/postmiles3.txt");144 tmpPath + "postmiles3.txt"); 133 145 String result = highways.toJson(); 134 146 JSONParser parser = new JSONParser(); … … 155 167 System.out.println("routeSort"); 156 168 Highways highways = new Highways( 157 "/tmp/postmiles3.txt");169 tmpPath + "postmiles3.txt"); 158 170 String result = highways.toJson(); 159 171 JSONParser parser = new JSONParser(); … … 180 192 System.out.println("apply color"); 181 193 Highways highways = new Highways( 182 "/tmp/postmiles1.txt");194 tmpPath + "postmiles1.txt"); 183 195 highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 0.9, 2.0, 184 196 LoopDetector.DOTCOLOR.RED);
Note: See TracChangeset
for help on using the changeset viewer.
