source: tmcsimulator/trunk/test/atmsdriver/model/StationTest.java @ 186

Revision 186, 2.0 KB checked in by jtorres, 9 years ago (diff)

Highways.java, FEPLine.java, LoopDetector?.java, Station.java: reconfigured the getHighwaysMeta() function to a toCondensedFormat(boolean MetaDataOnly?) method. By specifying MetaDataOnly? as true, you get the same output as the previous getHighwaysMeta() function. By specifying MetaDataOnly? as false, you get the new condensed format needed to send to the FEPSim over the socket. This allows us to use the same function to get a meta data dump, as well as get the highways data format needed for FEPSim socket. HighwaysParser?.cpp: removed the old tinyxml code, set up skeleton for new parser. NetworkReader?.h: deleted, and added HighwaysParser?.h. LoadSadDotsTest?.java and StationTest?.java: configured to use new toCondensedFormat method instead of getHighwaysMeta.

Line 
1
2package atmsdriver.model;
3
4import atmsdriver.model.Station.DIRECTION;
5import java.util.ArrayList;
6import junit.framework.TestCase;
7import org.w3c.dom.Element;
8
9/**
10 *
11 * @author jdalbey
12 */
13public class StationTest extends TestCase {
14    Station alpha;
15    public StationTest(String testName) {
16        super(testName);
17    }
18   
19    @Override
20    protected void setUp() throws Exception {
21        super.setUp();
22        alpha = new Station(1,2,3,"A",new ArrayList<LoopDetector>(), 4, DIRECTION.NORTH, 1.0);
23    }
24   
25    @Override
26    protected void tearDown() throws Exception {
27        super.tearDown();
28    }
29
30    /**
31     * Test of getHighwayNumber method, of class Station.
32     */
33    public void testGetHighwayNumber() {
34        System.out.println("getHighwayNumber");
35        assertEquals(4, alpha.routeNumber);
36    }
37
38    /**
39     * Test of getDirection method, of class Station.
40     */
41    public void testGetDirection() {
42        System.out.println("getDirection");
43        assertEquals(DIRECTION.NORTH, alpha.direction);
44    }
45
46    /**
47     * Test of getStationMeta method, of class Station.
48     */
49    public void testGetStationMeta() {
50        System.out.println("getStationMeta");
51        String expResult = "2 3 4 N 1.0 0 A\n";
52        String result = alpha.toCondensedFormat(true);
53        assertEquals(expResult, result);
54    }
55
56    /**
57     * Test of getPostmile method, of class Station.
58     */
59    public void testGetPostmile() {
60        System.out.println("getPostmile");
61        assertEquals(1.0, alpha.postmile,0.1);
62    }
63
64    /**
65     * Test of compareTo method, of class Station.
66     */
67    public void testCompareTo() {
68        System.out.println("compareTo");
69        Station beta = new Station(1,2,3,"B",new ArrayList<LoopDetector>(), 4, DIRECTION.NORTH, 2.0);
70        int expResult = 0;
71        assertEquals(-1, alpha.compareTo(beta));
72        assertEquals(1, beta.compareTo(alpha));
73        assertEquals(0, beta.compareTo(beta));
74    }
75
76    /**
77     * TODO: Test of toXML method, of class Station.
78     */
79   
80}
Note: See TracBrowser for help on using the repository browser.