Warning: Can't use blame annotator:
svn blame failed on trunk/test/atmsdriver/model/PostmileCoordsTest.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/trunk/test/atmsdriver/model/PostmileCoordsTest.java @ 248

Revision 248, 2.2 KB checked in by jdalbey, 7 years ago (diff)

TrafficModelManager?: multi-file commit to enhance Traffic Mgr to output highway status to json file for viewing in Google Map.

RevLine 
1
2package atmsdriver.model;
3
4import java.io.FileInputStream;
5import java.io.FileNotFoundException;
6import java.util.Iterator;
7import java.util.Scanner;
8import junit.framework.TestCase;
9
10/**
11 *
12 * @author jdalbey
13 */
14public class PostmileCoordsTest extends TestCase
15{
16    private PostmileCoords pmc;
17   
18    public PostmileCoordsTest(String testName)
19    {
20        super(testName);
21    }
22   
23    @Override
24    protected void setUp() throws Exception
25    {
26        super.setUp();
27    }
28   
29    @Override
30    protected void tearDown() throws Exception
31    {
32        super.tearDown();
33    }
34
35    public void testLoad() throws FileNotFoundException
36    {
37
38        System.out.println("load");
39        String line1 = "5 N 4.02, 33.33, -117.117\n5 S 3.56, 33.33, -117.117";
40        Scanner scan = new Scanner(line1).useDelimiter("\\A"); 
41        pmc = new PostmileCoords();
42        pmc.load(scan);
43        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 
44                "-117.117");
45        assertEquals(pm,pmc.get(0));
46        assert(pmc.size() == 2);
47    }
48    public void testLoadwithPrefix() throws FileNotFoundException
49    {
50
51        System.out.println("load");
52        String line1 = "5 N R4.02, 33.33, -117.117\n5 S 3.56, 33.33, -117.117";
53        Scanner scan = new Scanner(line1).useDelimiter("\\A"); 
54        pmc = new PostmileCoords();
55        pmc.load(scan);
56        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 
57                "-117.117");
58        assertEquals(pm,pmc.get(0));
59        assert(pmc.size() == 2);
60    }
61    public void testIterator() throws FileNotFoundException
62    {
63        System.out.println("iterator");
64        testLoad();
65        int count = 0;
66        for (Object pm: pmc)
67        {
68            count++;
69        }
70        assert(count == 2);
71    }
72    public void testFind() throws FileNotFoundException
73    {
74        System.out.println("find");
75        testLoad();
76        PostmileCoords.Postmile result = pmc.find("5 N 4.02");
77        assertNotNull(result);
78        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", "-117.117");
79        assertEquals(pm,result);
80        PostmileCoords.Postmile result2 = pmc.find("X");
81        assertNull(result2);
82    }
83}
Note: See TracBrowser for help on using the repository browser.