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

Revision 162, 2.5 KB checked in by jtorres, 9 years ago (diff)

branches/atmsdata/: added the atms sql dump vds data

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                "test/atmsdriver/model/lds_loadhighways_sample.txt",
51                "config/vds_data/loop.txt",
52                "config/vds_data/highwaysMeta.txt",
53                "localhost", 8080);
54       
55         // Test for correct number of highways
56        ArrayList<Highway> result = highways.highways;
57        assertEquals(2, result.size());
58       
59        // Test 5 N was loaded
60        Highway fiftyfiveN = result.get(0);
61        assertEquals(new Integer(5), fiftyfiveN.routeNumber);
62       
63        ArrayList<Station> stations = fiftyfiveN.stations;
64        Station sad = stations.get(0);
65        System.out.println(""+sad.getStationMeta());
66        assertEquals(22, sad.loops.size());
67
68        // Test 405 S was loaded
69        Highway fourohfiveS = result.get(1);
70        assertEquals(new Integer(405), fourohfiveS.routeNumber);
71        stations = fourohfiveS.stations;
72        Station happy = stations.get(0);
73        System.out.println(""+happy.getStationMeta());
74        assertEquals(9, happy.loops.size());
75    }
76}
Note: See TracBrowser for help on using the repository browser.