| 1 | /* |
|---|
| 2 | * To change this license header, choose License Headers in Project Properties. |
|---|
| 3 | * To change this template file, choose Tools | Templates |
|---|
| 4 | * and open the template in the editor. |
|---|
| 5 | */ |
|---|
| 6 | package tmcsim.utilities; |
|---|
| 7 | |
|---|
| 8 | import java.util.Scanner; |
|---|
| 9 | import junit.framework.TestCase; |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * |
|---|
| 13 | * @author jdalbey |
|---|
| 14 | */ |
|---|
| 15 | public class VehicleDetectionStationTest extends TestCase |
|---|
| 16 | { |
|---|
| 17 | |
|---|
| 18 | public VehicleDetectionStationTest(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 | String allFields = "1202464 57 N 12 59 8100 21.16 10.426 33.929701 -117.879881 .975 ML 4 LAMBERT 973"; |
|---|
| 35 | String noLength = "1202428 57 N 12 59 8100 20 9.266 33.912859 -117.883163 OR 1 IMPERIAL 2 972"; |
|---|
| 36 | String noCiy = "1202475 57 S 12 59 22.06 11.411 33.94149 -117.874675 1.269 ML 4 TONNER 987 "; |
|---|
| 37 | String noCitynoLen = "1202470 57 S 12 59 22 11.351 33.940956 -117.875322 OR 1 BONNER 987"; |
|---|
| 38 | public void testScan1() |
|---|
| 39 | { |
|---|
| 40 | Scanner lineIn = new Scanner(allFields).useDelimiter("\t"); |
|---|
| 41 | VehicleDetectionStation vds1 = new VehicleDetectionStation(lineIn); |
|---|
| 42 | String result = vds1.toString(); |
|---|
| 43 | assertEquals("LAMBERT",vds1.street); |
|---|
| 44 | } |
|---|
| 45 | public void testScan2() |
|---|
| 46 | { |
|---|
| 47 | Scanner lineIn = new Scanner(noLength).useDelimiter("\t"); |
|---|
| 48 | VehicleDetectionStation vds1 = new VehicleDetectionStation(lineIn); |
|---|
| 49 | String result = vds1.toString(); |
|---|
| 50 | assertEquals("IMPERIAL 2",vds1.street); |
|---|
| 51 | } |
|---|
| 52 | public void testScan3() |
|---|
| 53 | { |
|---|
| 54 | Scanner lineIn = new Scanner(noCiy).useDelimiter("\t"); |
|---|
| 55 | VehicleDetectionStation vds1 = new VehicleDetectionStation(lineIn); |
|---|
| 56 | String result = vds1.toString(); |
|---|
| 57 | assertEquals("TONNER",vds1.street); |
|---|
| 58 | } |
|---|
| 59 | public void testScan4() |
|---|
| 60 | { |
|---|
| 61 | Scanner lineIn = new Scanner(noCitynoLen).useDelimiter("\t"); |
|---|
| 62 | VehicleDetectionStation vds1 = new VehicleDetectionStation(lineIn); |
|---|
| 63 | String result = vds1.toString(); |
|---|
| 64 | assertEquals("BONNER",vds1.street); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | } |
|---|