source: tmcsimulator/trunk/test/atmsdriver/model/LoadSadDotsTest.java @ 185

Revision 185, 2.4 KB checked in by jtorres, 9 years ago (diff)

HighwaysTest?.java, LoadHighwaysTest?.java, LoadSadDotsTest?.java: configured Highways initialization to reflect new configuration, but the tests obviously still fail. branches/FEPSimulator: removed tinxml/ and unlinked the tinyxml library in project configuration

Line 
1package atmsdriver.model;
2
3import java.io.FileWriter;
4import java.io.PrintWriter;
5import java.nio.file.FileSystems;
6import java.nio.file.Files;
7import java.nio.file.Path;
8import java.util.ArrayList;
9import junit.framework.TestCase;
10
11/**
12 *
13 * @author jdalbey
14 */
15public class LoadSadDotsTest extends TestCase {
16
17    public LoadSadDotsTest(String testName) {
18        super(testName);
19    }
20
21    @Override
22    protected void setUp() throws Exception {
23        super.setUp();
24        PrintWriter writer = null;
25        try {
26            writer = new PrintWriter(new FileWriter("test/atmsdriver/model/lds_loadhighways_sample.txt"));
27           
28            writer.println("lds_id      line    drop sch lineinfo       system_key      sch_seq glo_seq         count   freeway Dir     ca_pm   lds_name");
29            writer.println("1205146     50      3       13      13      1123005873      24148   1357650         19      5       N       29.79   NEWPORT");
30            writer.println("1201190     46      6       36      36      1123006209      26472   1357644         20      405     S       4.03    JEFFREY 2");
31            writer.close();
32        } catch (Exception e) {
33            e.printStackTrace();
34        }
35    }
36
37    @Override
38    protected void tearDown() throws Exception {
39        super.tearDown();
40        Path path = FileSystems.getDefault().getPath("test/atmsdriver/model", "lds_loadhighways_sample.txt");
41        Files.delete(path);
42    }
43
44    /**
45     * Test of toXML method, of class Network.
46     */
47    public void testLoadHighways() {
48        System.out.println("toXML");
49        Highways highways = new Highways(
50                "config/vds_data/highways_fullmap.txt",
51                "localhost", 8080);
52       
53         // Test for correct number of highways
54        ArrayList<Highway> result = highways.highways;
55        assertEquals(2, result.size());
56       
57        // Test 5 N was loaded
58        Highway fiftyfiveN = result.get(0);
59        assertEquals(new Integer(5), fiftyfiveN.routeNumber);
60       
61        ArrayList<Station> stations = fiftyfiveN.stations;
62        Station sad = stations.get(0);
63        System.out.println(""+sad.getStationMeta());
64        assertEquals(22, sad.loops.size());
65
66        // Test 405 S was loaded
67        Highway fourohfiveS = result.get(1);
68        assertEquals(new Integer(405), fourohfiveS.routeNumber);
69        stations = fourohfiveS.stations;
70        Station happy = stations.get(0);
71        System.out.println(""+happy.getStationMeta());
72        assertEquals(9, happy.loops.size());
73    }
74}
Note: See TracBrowser for help on using the repository browser.