Skip to content

Commit

Permalink
Merge pull request #3731 from matsim-org/bugfix/fixTestOnWindowsPipeline
Browse files Browse the repository at this point in the history
Update FreeSpeedTravelTimeMatrixTest to fix Windows Pipeline
  • Loading branch information
jfbischoff authored Feb 17, 2025
2 parents fa2c3e2 + 91ddfab commit 839c9cc
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.matsim.contrib.zone.skims;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
Expand Down Expand Up @@ -87,7 +88,7 @@ void matrix() throws MalformedURLException {
assertThat(matrix.getTravelTime(nodeC, nodeA, 0)).isEqualTo(0);
assertThat(matrix.getTravelTime(nodeB, nodeC, 0)).isEqualTo(20 + 1); // 1 s for moving over nodes
assertThat(matrix.getTravelTime(nodeC, nodeB, 0)).isEqualTo(10 + 1); // 1 s for moving over nodes

// write and read cache
URL cachePath = new File(utils.getOutputDirectory(), "cache.bin").toURI().toURL();
matrix.write(cachePath, network);
Expand Down Expand Up @@ -145,15 +146,14 @@ void sparseMatrix() throws MalformedURLException {
}

@Test
void cacheViaConfig() throws MalformedURLException {
void cacheViaConfig() {
// need to get an absolute path, otherwise will try to generate the cache relative to the config
String cachePath = new File(utils.getOutputDirectory() + "/cache.bin").getAbsolutePath();

URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"),
"generic_dvrp_one_taxi_config.xml");

Config config = ConfigUtils.loadConfig(configUrl, new DvrpConfigGroup());

DvrpConfigGroup dvrpConfig = DvrpConfigGroup.get(config);

DvrpTravelTimeMatrixParams params = dvrpConfig.getTravelTimeMatrixParams();
Expand All @@ -162,15 +162,16 @@ void cacheViaConfig() throws MalformedURLException {

SquareGridZoneSystemParams zoneParams = new SquareGridZoneSystemParams();
zoneParams.cellSize = 1000;
params.addParameterSet(zoneParams);
params.addParameterSet(zoneParams);

Scenario scenario = ScenarioUtils.createScenario(config);
ScenarioUtils.loadScenario(scenario);

{
// generate from scratch
assertTrue(!new File(cachePath).exists());
assertFalse(new File(cachePath).exists());

config.controller().setOutputDirectory( "test\\output\\generic_dvrp_one_taxi_cacheViaConfig_1");
Controler controller = new Controler(scenario);
controller.addOverridingModule(new DvrpModule());
controller.getInjector().getInstance(TravelTimeMatrix.class);
Expand All @@ -179,7 +180,7 @@ void cacheViaConfig() throws MalformedURLException {
{
// read from cache
assertTrue(new File(cachePath).exists());

config.controller().setOutputDirectory( "test\\output\\generic_dvrp_one_taxi_cacheViaConfig_2");
Controler controller = new Controler(scenario);
controller.addOverridingModule(new DvrpModule());
controller.getInjector().getInstance(TravelTimeMatrix.class);
Expand Down

0 comments on commit 839c9cc

Please sign in to comment.