package tmcsim.highwaymodel; import tmcsim.highwaymodel.LoopDetector; import tmcsim.highwaymodel.Station; import tmcsim.highwaymodel.Station.DIRECTION; import java.util.ArrayList; import junit.framework.TestCase; import org.w3c.dom.Element; /** * * @author jdalbey */ public class StationTest extends TestCase { Station alpha; public StationTest(String testName) { super(testName); } @Override protected void setUp() throws Exception { super.setUp(); alpha = new Station(1,2,3,"A",new ArrayList(), 4, DIRECTION.NORTH, 1.0); } @Override protected void tearDown() throws Exception { super.tearDown(); } /** * Test of getHighwayNumber method, of class Station. */ public void testGetHighwayNumber() { System.out.println("getHighwayNumber"); assertEquals(4, alpha.routeNumber); } /** * Test of getDirection method, of class Station. */ public void testGetDirection() { System.out.println("getDirection"); assertEquals(DIRECTION.NORTH, alpha.direction); } /** * Test of getPostmile method, of class Station. */ public void testGetPostmile() { System.out.println("getPostmile"); assertEquals(1.0, alpha.postmile,0.1); } /** * Test of compareTo method, of class Station. */ public void testCompareTo() { System.out.println("compareTo"); Station beta = new Station(1,2,3,"B",new ArrayList(), 4, DIRECTION.NORTH, 2.0); int expResult = 0; assertEquals(-1, alpha.compareTo(beta)); assertEquals(1, beta.compareTo(alpha)); assertEquals(0, beta.compareTo(beta)); } public void testMatches() { Station alpha = new Station(1,2,3,"A",new ArrayList(), 4, DIRECTION.NORTH, 2.0); assertTrue(alpha.matches(DIRECTION.NORTH, 2.0)); assertFalse(alpha.matches(DIRECTION.NORTH,2.1)); } /** * Test get Color and LoopDetector accessors */ public void testGetColor() { LoopDetector lane = new LoopDetector(999,"locid","loc"); ArrayList lanes = new ArrayList(); lanes.add(lane); Station alpha = new Station(1,2,3,"A",lanes, 4, DIRECTION.NORTH, 2.0); assertEquals('-',alpha.getColor().symbol()); assertEquals("lime",alpha.getColor().htmlColor()); lane.setAttributes(LoopDetector.DOTCOLOR.YELLOW); assertEquals('+',alpha.getColor().symbol()); assertEquals("yellow",alpha.getColor().htmlColor()); lane.setAttributes(LoopDetector.DOTCOLOR.RED); assertEquals('@',alpha.getColor().symbol()); assertEquals("red",alpha.getColor().htmlColor()); } }