X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=test%2Fnet%2Fjaekl%2Fqd%2Fxml%2FParseResultTest.java;h=7b0ea6fc57d0d6e29e7beb4437934e5d321e1a5f;hp=d58ab8c9a522484c4ada261145725e8a3ab486a3;hb=5bc9bbe3fd54b9fc7aa3b92d2d37e95c41b9645a;hpb=a938b67bf3d3bd86f8dd7b1f958e81007bf6f2fe diff --git a/test/net/jaekl/qd/xml/ParseResultTest.java b/test/net/jaekl/qd/xml/ParseResultTest.java index d58ab8c..7b0ea6f 100644 --- a/test/net/jaekl/qd/xml/ParseResultTest.java +++ b/test/net/jaekl/qd/xml/ParseResultTest.java @@ -5,6 +5,7 @@ package net.jaekl.qd.xml; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Locale; import org.junit.Assert; @@ -70,14 +71,14 @@ public class ParseResultTest { + "41Northbound" + "Rideau C / Ctr Rideau" + "" - + "Rideau Centre / Centre Rideau19:00" + + "Rideau Centre / Centre Rideau19:00" + "160.45" + "4LB - IN45.408957-75.664125" + "66.4" - + "Rideau Centre / Centre Rideau" + + "Rideau Centre / Centre Rideau" + "19:3040-1" + "4LB - IN" - + "Rideau Centre / Centre Rideau20:00" + + "Rideau Centre / Centre Rideau20:00" + "70-1" + "4LB - IN" + "" @@ -94,7 +95,7 @@ public class ParseResultTest { @Override public void endContents(String uri, String localName, String qName, - String chars, Attributes attr) throws XmlParseException + String chars) throws XmlParseException { Assert.fail("Should not have any contents to end."); } @@ -197,7 +198,7 @@ public class ParseResultTest { @Override public void endContents(String uri, String localName, String qName, - String chars, Attributes attr) throws XmlParseException + String chars) throws XmlParseException { if (localName.equals(ONE)) { m_one = chars; @@ -281,8 +282,7 @@ public class ParseResultTest { public RouteParse getRoute(int idx) { return m_routes.get(idx); } @Override - public void endContents(String uri, String localName, String qName, - String chars, Attributes attr) throws XmlParseException + public void endContents(String uri, String localName, String qName, String chars) throws XmlParseException { if (localName.equals(STOP_NO)) { m_stopNo = Integer.parseInt(chars); @@ -344,7 +344,7 @@ public class ParseResultTest { @Override public void endContents(String uri, String localName, String qName, - String chars, Attributes attr) throws XmlParseException + String chars) throws XmlParseException { if (localName.equals(ROUTE_NO)) { m_routeNo = Integer.parseInt(chars); @@ -376,6 +376,7 @@ public class ParseResultTest { } public static class TripParse extends ParseResult { private static final String TRIP = "Trip"; + private static final String GHOST = "ghost"; private static final String TRIP_DEST = "TripDestination"; private static final String TRIP_START = "TripStartTime"; private static final String ADJ_SCHED_TIME = "AdjustedScheduleTime"; @@ -386,22 +387,33 @@ public class ParseResultTest { // Data gleaned from parsing String m_dest; String m_startTime; - int m_adjSchedTime;; + int m_adjSchedTime; + boolean m_ghost; public TripParse() { super(TRIP, INTERNAL, EXTERNAL); m_dest = m_startTime = null; m_adjSchedTime = 0; + m_ghost = false; } public String getDestination() { return m_dest; } public String getStartTime() { return m_startTime; } public int getAdjustedScheduleTime() { return m_adjSchedTime; } + public boolean ghostAttrSet() { return m_ghost; } + + @Override + public void handleMainAttributes(Attributes attr) throws MissingAttributeException + { + String scratch = this.getRequiredAttr(TRIP, attr, GHOST); + Assert.assertNotNull(scratch); + m_ghost = scratch.toLowerCase(Locale.CANADA).equals("true"); + } @Override public void endContents(String uri, String localName, String qName, - String chars, Attributes attr) throws XmlParseException + String chars) throws XmlParseException { if (localName.equals(TRIP_DEST)) { m_dest = chars; @@ -502,18 +514,21 @@ public class ParseResultTest { Assert.assertEquals("Rideau Centre / Centre Rideau", tp.getDestination()); Assert.assertEquals("19:00", tp.getStartTime()); Assert.assertEquals(16, tp.getAdjustedScheduleTime()); + Assert.assertEquals(false, tp.ghostAttrSet()); tp = rp.getTrip(1); Assert.assertNotNull(tp); Assert.assertEquals("Rideau Centre / Centre Rideau", tp.getDestination()); Assert.assertEquals("19:30", tp.getStartTime()); Assert.assertEquals(40, tp.getAdjustedScheduleTime()); + Assert.assertEquals(true, tp.ghostAttrSet()); tp = rp.getTrip(2); Assert.assertNotNull(tp); Assert.assertEquals("Rideau Centre / Centre Rideau", tp.getDestination()); Assert.assertEquals("20:00", tp.getStartTime()); Assert.assertEquals(70, tp.getAdjustedScheduleTime()); + Assert.assertEquals(true, tp.ghostAttrSet()); } finally { if (null != bais) {