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

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

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

branches/FEPSimulator/tests/HighwaysParserTest.cpp: Unit test for HighwaysParser?.cpp. HighwaysTest?.java: now passing toXML(), added test for toCondensedFormat() method. LoadHighwaysTest?.java: passing. LoadSadDotsTest?.java: conformed to changes, not passing. Highway.java/Highways.java: converted class attributes to List instead of ArrayList?. Highways.java: corrected toCondensedFormat() method comments and added comments throughout file.

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