Ignore:
Timestamp:
09/11/2022 04:28:42 PM (4 years ago)
Author:
jdalbey
Message:

Improve unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/tmcsim/highwaymodel/HighwaysTest.java

    r653 r655  
    2222public class HighwaysTest extends TestCase { 
    2323 
     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     
    2436    public HighwaysTest(String testName) { 
    2537        super(testName); 
     
    3143        PrintWriter writer = null; 
    3244        try { 
    33             writer = new PrintWriter(new FileWriter("/tmp/postmiles1.txt")); 
     45            writer = new PrintWriter(new FileWriter(tmpPath + "postmiles1.txt")); 
    3446            writer.println("5 S 0.9,33.408425,-117.599923,CALAFIA,0,0"); 
    3547            writer.println("5 N 1.24,33.413051,-117.601964,MAGDALENA,0,0"); 
     
    3749            writer.close(); 
    3850 
    39             writer = new PrintWriter(new FileWriter("/tmp/postmiles2.txt")); 
     51            writer = new PrintWriter(new FileWriter(tmpPath + "postmiles2.txt")); 
    4052            writer.println("5 N 5.89,33.459637,-117.657305,ESTRELLA2,0,0"); 
    4153            writer.println("5 S 6.47,33.464281,-117.665631,SACRAMENTO,-0.56275,-0.826627"); 
     
    4759            writer.close(); 
    4860 
    49             writer = new PrintWriter(new FileWriter("/tmp/postmiles3.txt")); 
     61            writer = new PrintWriter(new FileWriter(tmpPath + "/postmiles3.txt")); 
    5062            writer.println("73 N 23.9,33.643656,-117.859875,BISON 2,0.976131,0.217185"); 
    5163            writer.println("55 S 6.88,33.697495,-117.862677,MACARTHU1,-0.710326,0.703873"); 
     
    6375    protected void tearDown() throws Exception { 
    6476        super.tearDown(); 
    65         Path path = FileSystems.getDefault().getPath("/tmp/", "postmiles1.txt"); 
     77        Path path = FileSystems.getDefault().getPath(tmpPath, "postmiles1.txt"); 
    6678        Files.delete(path); 
    67         path = FileSystems.getDefault().getPath("/tmp/", "postmiles2.txt"); 
     79        path = FileSystems.getDefault().getPath(tmpPath, "postmiles2.txt"); 
    6880        Files.delete(path); 
    69         path = FileSystems.getDefault().getPath("/tmp/", "postmiles3.txt"); 
     81        path = FileSystems.getDefault().getPath(tmpPath, "postmiles3.txt"); 
    7082        Files.delete(path); 
    7183    } 
     
    7486        System.out.println("test FindStation()"); 
    7587        Highways highways = new Highways( 
    76                 "/tmp/postmiles1.txt"); 
     88                tmpPath + "postmiles1.txt"); 
    7789        assertTrue(null != highways.findStation(5, DIRECTION.SOUTH, 0.9)); 
    7890        assertTrue(null != highways.findStation(5, DIRECTION.SOUTH, 1.49)); 
     
    8698        System.out.println("toString"); 
    8799        Highways highways = new Highways( 
    88                 "/tmp/postmiles2.txt"); 
     100                tmpPath + "postmiles2.txt"); 
    89101        highways.getHighwayByRouteNumber(5).stations.get(0).loops.get(0).vol = 1; 
    90102        String result = highways.toString(); 
     
    108120        System.out.println("toJson"); 
    109121        Highways highways = new Highways( 
    110                 "/tmp/postmiles1.txt"); 
     122                tmpPath + "postmiles1.txt"); 
    111123        String result = highways.toJson(); 
    112124        System.out.println(result); 
     
    130142        System.out.println("stationSort"); 
    131143        Highways highways = new Highways( 
    132                 "/tmp/postmiles3.txt"); 
     144                tmpPath + "postmiles3.txt"); 
    133145        String result = highways.toJson(); 
    134146        JSONParser parser = new JSONParser(); 
     
    155167        System.out.println("routeSort"); 
    156168        Highways highways = new Highways( 
    157                 "/tmp/postmiles3.txt"); 
     169                tmpPath + "postmiles3.txt"); 
    158170        String result = highways.toJson(); 
    159171        JSONParser parser = new JSONParser(); 
     
    180192        System.out.println("apply color"); 
    181193        Highways highways = new Highways( 
    182                 "/tmp/postmiles1.txt"); 
     194                tmpPath + "postmiles1.txt"); 
    183195        highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 0.9, 2.0, 
    184196                LoopDetector.DOTCOLOR.RED); 
Note: See TracChangeset for help on using the changeset viewer.