protected void runTest(KNAnalysisEventsHandler calcLegTimes) { calcLegTimes.writeStats( utils.getOutputDirectory() + KNAnalysisEventsHandlerTest.BASE_FILE_NAME); // actual test: compare checksums of the files for (StatType type : StatType.values()) { final String str = KNAnalysisEventsHandlerTest.BASE_FILE_NAME + type.toString() + ".txt"; Logger.getLogger(this.getClass()).info("comparing " + str); final long expectedChecksum = CRCChecksum.getCRCFromFile(utils.getInputDirectory() + str); final long actualChecksum = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + str); Assert.assertEquals("Output files differ.", expectedChecksum, actualChecksum); } }
@Test @Ignore public void testAveraging() { // yy this test is probably not doing anything with respect to some of the newer statistics, // such as money. kai, mar'14 KNAnalysisEventsHandler testee = new KNAnalysisEventsHandler(this.scenario); EventsManager events = EventsUtils.createEventsManager(); events.addHandler(testee); Leg leg = PopulationUtils.createLeg(TransportMode.car); leg.setDepartureTime(Time.parseTime("07:10:00")); leg.setTravelTime(Time.parseTime("07:30:00") - leg.getDepartureTime()); testee.handleEvent( new PersonDepartureEvent( leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); testee.handleEvent( new PersonArrivalEvent( leg.getDepartureTime() + leg.getTravelTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); leg = PopulationUtils.createLeg(TransportMode.car); leg.setDepartureTime(Time.parseTime("07:00:00")); leg.setTravelTime(Time.parseTime("07:10:00") - leg.getDepartureTime()); testee.handleEvent( new PersonDepartureEvent( leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); testee.handleEvent( new PersonArrivalEvent( leg.getDepartureTime() + leg.getTravelTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); leg = PopulationUtils.createLeg(TransportMode.car); leg.setDepartureTime(Time.parseTime("31:12:00")); leg.setTravelTime(Time.parseTime("31:22:00") - leg.getDepartureTime()); testee.handleEvent( new PersonDepartureEvent( leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); testee.handleEvent( new PersonArrivalEvent( leg.getDepartureTime() + leg.getTravelTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); leg = PopulationUtils.createLeg(TransportMode.car); leg.setDepartureTime(Time.parseTime("30:12:00")); leg.setTravelTime(Time.parseTime("30:12:01") - leg.getDepartureTime()); testee.handleEvent( new PersonDepartureEvent( leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); testee.handleEvent( new PersonArrivalEvent( leg.getDepartureTime() + leg.getTravelTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); this.runTest(testee); }