public void testWriteGenericRoute() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(super.loadConfig(null)); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile("test/scenarios/equil/network.xml"); Link link1 = network.getLinks().get(Id.create(1, Link.class)); Link link2 = network.getLinks().get(Id.create(2, Link.class)); Scenario tmpScenario = new ScenarioBuilder(ConfigUtils.createConfig()).setNetwork(network).build() ; Population pop = tmpScenario.getPopulation(); PopulationFactory pb = pop.getFactory(); Person person = pb.createPerson(Id.create(1, Person.class)); Plan plan = (Plan) pb.createPlan(); plan.setPerson(person); plan.addActivity(pb.createActivityFromLinkId("h", link1.getId())); Leg leg = pb.createLeg("undefined"); Route route = RouteUtils.createGenericRouteImpl(link1.getId(), link2.getId()); route.setTravelTime(123); leg.setRoute(route); plan.addLeg(leg); plan.addActivity(pb.createActivityFromLinkId("h", Id.create(1, Link.class))); person.addPlan(plan); pop.addPerson(person); String filename = getOutputDirectory() + "population.xml"; new PopulationWriter(pop, network).writeV4(filename); Population pop2 = scenario.getPopulation(); new PopulationReader(scenario).readFile(filename); Person person2 = pop2.getPersons().get(Id.create(1, Person.class)); Leg leg2 = (Leg) person2.getPlans().get(0).getPlanElements().get(1); Route route2 = leg2.getRoute(); assertEquals(123, route2.getTravelTime(), EPSILON); // if this succeeds, we know that writing/reading the data works }