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

Revision 266, 2.3 KB checked in by jdalbey, 7 years ago (diff)

PostmileCoords?.java: Add cross street name attribute and modified toJson to include it.

Line 
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,Dyer Rd\n5 S 3.56, 33.33, -117.117,Dyer Rd";
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","Dyer Rd");
45        assertEquals(pm,pmc.get(0));
46        assert(pmc.size() == 2);
47    }
48    public void testLoadwithPrefix() throws FileNotFoundException
49    {
50        System.out.println("load");
51        String line1 = "5 N R4.02, 33.33, -117.117,Dyer Rd\n5 S 3.56, 33.33, -117.117,Dyer Rd";
52        Scanner scan = new Scanner(line1).useDelimiter("\\A"); 
53        pmc = new PostmileCoords();
54        pmc.load(scan);
55        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 
56                "-117.117","Dyer Rd");
57        assertEquals(pm,pmc.get(0));
58        assert(pmc.size() == 2);
59    }
60    public void testIterator() throws FileNotFoundException
61    {
62        System.out.println("iterator");
63        testLoad();
64        int count = 0;
65        for (Object pm: pmc)
66        {
67            count++;
68        }
69        assert(count == 2);
70    }
71    public void testFind() throws FileNotFoundException
72    {
73        System.out.println("find");
74        testLoad();
75        PostmileCoords.Postmile result = pmc.find("5 N 4.02");
76        assertNotNull(result);
77        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", "-117.117","Dyer Rd");
78        assertEquals(pm,result);
79        PostmileCoords.Postmile result2 = pmc.find("X");
80        assertNull(result2);
81        System.out.println(pm.toJson());
82    }
83}
Note: See TracBrowser for help on using the repository browser.