diff --git a/pom.xml b/pom.xml index 8f3408d5..9c1b78d2 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ - 16.0-2023w50 + 16.0-2023w51 @@ -155,11 +155,18 @@ - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter-engine + 5.10.1 test + + org.junit.jupiter + junit-jupiter + 5.10.1 + test + + diff --git a/src/test/java/org/matsim/codeexamples/RunAbcSimpleExampleTest.java b/src/test/java/org/matsim/codeexamples/RunAbcSimpleExampleTest.java index c0ae5074..59bee9da 100644 --- a/src/test/java/org/matsim/codeexamples/RunAbcSimpleExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/RunAbcSimpleExampleTest.java @@ -3,10 +3,9 @@ import com.jogamp.common.util.SyncedRingbuffer; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -17,15 +16,15 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class RunAbcSimpleExampleTest{ private static final Logger log = LogManager.getLogger(RunAbcSimpleExampleTest.class) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void testMain(){ + void testMain(){ try{ RunAbcSimpleExample.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ).toString() , "--config:controler.outputDirectory=" + utils.getOutputDirectory() @@ -45,7 +44,7 @@ public void testMain(){ for( Person expectedPerson : expected.getPersons().values() ){ Person actualPerson = actual.getPersons().get( Id.createPersonId( expectedPerson.getId() ) ); - Assert.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); + Assertions.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); } } diff --git a/src/test/java/org/matsim/codeexamples/config/ExamplesByConfigfileTest.java b/src/test/java/org/matsim/codeexamples/config/ExamplesByConfigfileTest.java index 3588b193..1c926f47 100644 --- a/src/test/java/org/matsim/codeexamples/config/ExamplesByConfigfileTest.java +++ b/src/test/java/org/matsim/codeexamples/config/ExamplesByConfigfileTest.java @@ -23,13 +23,13 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; +import java.util.stream.Stream; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.core.config.Config; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.utils.io.IOUtils; @@ -39,44 +39,25 @@ * @author nagel * */ -@RunWith(Parameterized.class) public class ExamplesByConfigfileTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; - private String configFile; - - public ExamplesByConfigfileTest(String configFile ) { - this.configFile = configFile ; - } - - @Parameters(name = "{index}: configFilename == {0};") - public static Collection createTests() { - Collection filesToRun = new ArrayList<>(); - - filesToRun.add(new Object [] {"scenarios/equil/config.xml"}); - filesToRun.add(new Object [] {"scenarios/equil/config-with-minimal-plans-file.xml"}); - filesToRun.add(new Object [] {"scenarios/equil/config-with-mobsim.xml"}); - filesToRun.add(new Object [] {"scenarios/equil/example2-config.xml"}); - filesToRun.add(new Object [] {"scenarios/equil/example5-config.xml"}); - filesToRun.add(new Object [] {"scenarios/equil/config-with-controlerListener.xml"}); - filesToRun.add(new Object [] {"scenarios/equil/config-with-pluggablePlanStrategy.xml"}); - - filesToRun.add(new Object [] {"scenarios/equil-extended/config-extended.xml"}); - filesToRun.add(new Object [] {"scenarios/equil-extended/config-with-lanes.xml"}); - filesToRun.add(new Object [] {"scenarios/equil-extended/config-with-network-change-events.xml"}); - - filesToRun.add(new Object [] {"scenarios/equil-extended/config-with-subpopulation.xml"}); - filesToRun.add(new Object [] {"scenarios/equil-extended/config-with-trips.xml"}); - - filesToRun.add(new Object [] {"scenarios/equil-mixedTraffic/config-with-mode-vehicles.xml"}); - filesToRun.add(new Object [] {"scenarios/equil-mixedTraffic/config-with-all-vehicles-from-file.xml"}); - - filesToRun.add(new Object [] {"examples/tutorial/config/externalReplanning.xml"}); - - return filesToRun; - - // the convention, I think, is that the output of the method marked by "@Parameters" is taken as input to the constructor - // before running each test. kai, jul'16 + public static Stream arguments() { + return Stream.of("scenarios/equil/config.xml", + "scenarios/equil/config-with-minimal-plans-file.xml", + "scenarios/equil/config-with-mobsim.xml", + "scenarios/equil/example2-config.xml", + "scenarios/equil/example5-config.xml", + "scenarios/equil/config-with-controlerListener.xml", + "scenarios/equil/config-with-pluggablePlanStrategy.xml", + "scenarios/equil-extended/config-extended.xml", + "scenarios/equil-extended/config-with-lanes.xml", + "scenarios/equil-extended/config-with-network-change-events.xml", + "scenarios/equil-extended/config-with-subpopulation.xml", + "scenarios/equil-extended/config-with-trips.xml", + "scenarios/equil-mixedTraffic/config-with-mode-vehicles.xml", + "scenarios/equil-mixedTraffic/config-with-all-vehicles-from-file.xml", + "examples/tutorial/config/externalReplanning.xml"); } private String outputDir ; @@ -86,8 +67,9 @@ public static Collection createTests() { * Test method for {@link RunFromConfigfileExample#main(java.lang.String[])}. */ @SuppressWarnings("static-method") - @Test - public final void testMain() { + @ParameterizedTest + @MethodSource("arguments") + final void testMain(String configFile) { if ( outputDir==null ) { outputDir = utils.getOutputDirectory() ; // removes output dir every time this is run so run it only once } @@ -111,7 +93,7 @@ public final void testMain() { } } catch( Exception ee ){ ee.printStackTrace(); - Assert.fail(); + Assertions.fail(); } } diff --git a/src/test/java/org/matsim/codeexamples/config/commandline/RunWithCommandLineOptionsExampleTest.java b/src/test/java/org/matsim/codeexamples/config/commandline/RunWithCommandLineOptionsExampleTest.java index b8607e9e..20e60857 100644 --- a/src/test/java/org/matsim/codeexamples/config/commandline/RunWithCommandLineOptionsExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/config/commandline/RunWithCommandLineOptionsExampleTest.java @@ -1,16 +1,16 @@ package org.matsim.codeexamples.config.commandline; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class RunWithCommandLineOptionsExampleTest{ - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void testMain(){ + void testMain(){ RunWithCommandLineOptionsExample.main( new String [] {"--config:controler.outputDirectory=" + utils.getPackageInputDirectory()} ) ; diff --git a/src/test/java/org/matsim/codeexamples/config/external/ExternalMobsimByConfigfileTest.java b/src/test/java/org/matsim/codeexamples/config/external/ExternalMobsimByConfigfileTest.java index d203f44f..baa4bf65 100644 --- a/src/test/java/org/matsim/codeexamples/config/external/ExternalMobsimByConfigfileTest.java +++ b/src/test/java/org/matsim/codeexamples/config/external/ExternalMobsimByConfigfileTest.java @@ -21,7 +21,7 @@ import java.io.File; import java.io.UncheckedIOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; /** @@ -29,13 +29,13 @@ * */ public class ExternalMobsimByConfigfileTest { - + /** * Test method for {@link RunExternalMobsimExample#main(java.lang.String[])}. */ @SuppressWarnings("static-method") @Test - public final void testMain() { + final void testMain() { try { IOUtils.deleteDirectoryRecursively(new File("./output/example").toPath()); } catch ( UncheckedIOException ee ) { diff --git a/src/test/java/org/matsim/codeexamples/dvrptc/RunTaxiExampleTest.java b/src/test/java/org/matsim/codeexamples/dvrptc/RunTaxiExampleTest.java index 6b21c1f7..78f1dc58 100644 --- a/src/test/java/org/matsim/codeexamples/dvrptc/RunTaxiExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/dvrptc/RunTaxiExampleTest.java @@ -1,13 +1,12 @@ package org.matsim.codeexamples.dvrptc; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import org.matsim.codeexamples.extensions.dvrp.RunTaxiExample; public class RunTaxiExampleTest { @Test - public void test() { + void test() { RunTaxiExample.main(null); } diff --git a/src/test/java/org/matsim/codeexamples/extensions/discrete_mode_choice/RunDiscreteModeChoiceExampleTest.java b/src/test/java/org/matsim/codeexamples/extensions/discrete_mode_choice/RunDiscreteModeChoiceExampleTest.java index 35e242e5..8f989fa4 100644 --- a/src/test/java/org/matsim/codeexamples/extensions/discrete_mode_choice/RunDiscreteModeChoiceExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/extensions/discrete_mode_choice/RunDiscreteModeChoiceExampleTest.java @@ -2,10 +2,9 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -17,14 +16,14 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunDiscreteModeChoiceExampleTest{ private static final Logger log = LogManager.getLogger( RunDiscreteModeChoiceExampleTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMain(){ + void testMain(){ try{ RunDiscreteModeChoiceExample.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ).toString() @@ -45,7 +44,7 @@ public void testMain(){ for( Person expectedPerson : expected.getPersons().values() ){ Person actualPerson = actual.getPersons().get( Id.createPersonId( expectedPerson.getId() ) ); - Assert.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); + Assertions.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); } } diff --git a/src/test/java/org/matsim/codeexamples/extensions/drt/RunMelunPrebookingTest.java b/src/test/java/org/matsim/codeexamples/extensions/drt/RunMelunPrebookingTest.java index 54008840..eface0e4 100644 --- a/src/test/java/org/matsim/codeexamples/extensions/drt/RunMelunPrebookingTest.java +++ b/src/test/java/org/matsim/codeexamples/extensions/drt/RunMelunPrebookingTest.java @@ -2,16 +2,16 @@ import java.io.File; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; public class RunMelunPrebookingTest { - @Rule + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void runExample() { + void runExample() { RunMelunPrebooking.RunSettings settings = new RunMelunPrebooking.RunSettings(); settings.prebookingShare = 0.5; diff --git a/src/test/java/org/matsim/codeexamples/extensions/dvrp/RunDrtExampleTest.java b/src/test/java/org/matsim/codeexamples/extensions/dvrp/RunDrtExampleTest.java index 10f11f05..bc3fd3d0 100644 --- a/src/test/java/org/matsim/codeexamples/extensions/dvrp/RunDrtExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/extensions/dvrp/RunDrtExampleTest.java @@ -1,23 +1,23 @@ package org.matsim.codeexamples.extensions.dvrp; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; import org.matsim.core.population.PopulationUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunDrtExampleTest{ private static final Logger log = LogManager.getLogger( RunDrtExampleTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMain(){ + void testMain(){ try{ RunDrtExample.run(false, "scenarios/multi_mode_one_shared_taxi/multi_mode_one_shared_taxi_config.xml" diff --git a/src/test/java/org/matsim/codeexamples/extensions/emissions/RunAverageEmissionToolOfflineExampleTest.java b/src/test/java/org/matsim/codeexamples/extensions/emissions/RunAverageEmissionToolOfflineExampleTest.java index f42a9a32..ebe0e824 100644 --- a/src/test/java/org/matsim/codeexamples/extensions/emissions/RunAverageEmissionToolOfflineExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/extensions/emissions/RunAverageEmissionToolOfflineExampleTest.java @@ -1,23 +1,23 @@ package org.matsim.codeexamples.extensions.emissions; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; import org.matsim.core.population.PopulationUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunAverageEmissionToolOfflineExampleTest{ private static final Logger log = LogManager.getLogger( RunAverageEmissionToolOfflineExampleTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMain(){ + void testMain(){ try{ RunAverageEmissionToolOfflineExample.main( new String []{ "./scenarios/sampleScenario/testv2_Vehv2/config_average.xml" diff --git a/src/test/java/org/matsim/codeexamples/extensions/freight/RunFreightExampleTest.java b/src/test/java/org/matsim/codeexamples/extensions/freight/RunFreightExampleTest.java index 98bf5157..5a160f82 100644 --- a/src/test/java/org/matsim/codeexamples/extensions/freight/RunFreightExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/extensions/freight/RunFreightExampleTest.java @@ -2,9 +2,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; @@ -16,10 +16,10 @@ public class RunFreightExampleTest{ private static final Logger log = LogManager.getLogger( RunFreightExampleTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMain(){ + void testMain(){ try{ String[] args = { IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "freight-chessboard-9x9" ), "config.xml" ).toString() , "--config:controller.outputDirectory", utils.getOutputDirectory(), @@ -37,13 +37,13 @@ public void testMain(){ PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); boolean result = PopulationUtils.comparePopulations( expected, actual ); - Assert.assertTrue( result ); + Assertions.assertTrue( result ); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz"; String actual = utils.getOutputDirectory() + "/output_events.xml.gz"; EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); + Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); } } catch( Exception ee ){ @@ -51,7 +51,7 @@ public void testMain(){ ee.printStackTrace(); // if one catches an exception, then one needs to explicitly fail the test: - Assert.fail(); + Assertions.fail(); } } } diff --git a/src/test/java/org/matsim/codeexamples/extensions/freight/RunFreightWithIterationsExampleTest.java b/src/test/java/org/matsim/codeexamples/extensions/freight/RunFreightWithIterationsExampleTest.java index 788849da..1ed44451 100644 --- a/src/test/java/org/matsim/codeexamples/extensions/freight/RunFreightWithIterationsExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/extensions/freight/RunFreightWithIterationsExampleTest.java @@ -2,9 +2,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; @@ -18,10 +18,10 @@ public class RunFreightWithIterationsExampleTest{ private static final Logger log = LogManager.getLogger( RunFreightWithIterationsExampleTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMain(){ + void testMain(){ try{ String[] args = { IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "freight-chessboard-9x9" ), "config.xml" ).toString() , "--config:controller.outputDirectory", utils.getOutputDirectory(), @@ -39,13 +39,13 @@ public void testMain(){ PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); boolean result = PopulationUtils.comparePopulations( expected, actual ); - Assert.assertTrue( result ); + Assertions.assertTrue( result ); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz"; String actual = utils.getOutputDirectory() + "/output_events.xml.gz"; EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); + Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); } } catch( Exception ee ){ @@ -53,7 +53,7 @@ public void testMain(){ ee.printStackTrace(); // if one catches an exception, then one needs to explicitly fail the test: - Assert.fail(); + Assertions.fail(); } } } diff --git a/src/test/java/org/matsim/codeexamples/extensions/locationChoice/RunLocationChoiceFrozenEpsilonsTest.java b/src/test/java/org/matsim/codeexamples/extensions/locationChoice/RunLocationChoiceFrozenEpsilonsTest.java index 972a1e23..ecf40a25 100644 --- a/src/test/java/org/matsim/codeexamples/extensions/locationChoice/RunLocationChoiceFrozenEpsilonsTest.java +++ b/src/test/java/org/matsim/codeexamples/extensions/locationChoice/RunLocationChoiceFrozenEpsilonsTest.java @@ -2,9 +2,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -16,14 +15,15 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunLocationChoiceFrozenEpsilonsTest{ private static final Logger log = LogManager.getLogger( RunLocationChoiceFrozenEpsilonsTest.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; - @Test public void testMain(){ + @Test + void testMain(){ // I don't know if this is overall doing something reasonable, thus commenting out the regression check. kai, jun'23 try{ diff --git a/src/test/java/org/matsim/codeexamples/extensions/minibus/RunMinibusTest.java b/src/test/java/org/matsim/codeexamples/extensions/minibus/RunMinibusTest.java index 320ef75a..8171b109 100644 --- a/src/test/java/org/matsim/codeexamples/extensions/minibus/RunMinibusTest.java +++ b/src/test/java/org/matsim/codeexamples/extensions/minibus/RunMinibusTest.java @@ -18,8 +18,8 @@ * *********************************************************************** */ package org.matsim.codeexamples.extensions.minibus; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.minibus.RunMinibus; import org.matsim.core.config.Config; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -27,15 +27,15 @@ public class RunMinibusTest { - @Rule + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; - /** - * Test method for {@link RunMinibus#main(java.lang.String[])}. - */ - @SuppressWarnings("static-method") - @Test - public final void testMain() { + /** + * Test method for {@link RunMinibus#main(java.lang.String[])}. + */ + @SuppressWarnings("static-method") + @Test + final void testMain() { RunMinibus runner = new RunMinibus( new String[]{"https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/atlantis/minibus/config.xml"} ); Config config = runner.getConfig(); diff --git a/src/test/java/org/matsim/codeexamples/facilities/facilitiesAndOpenTimes/RunWithFacilitiesExampleTest.java b/src/test/java/org/matsim/codeexamples/facilities/facilitiesAndOpenTimes/RunWithFacilitiesExampleTest.java index f0a334d9..5f6fecca 100644 --- a/src/test/java/org/matsim/codeexamples/facilities/facilitiesAndOpenTimes/RunWithFacilitiesExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/facilities/facilitiesAndOpenTimes/RunWithFacilitiesExampleTest.java @@ -20,8 +20,8 @@ import java.util.Map; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -36,14 +36,14 @@ public class RunWithFacilitiesExampleTest { /** * Test method for {@link RunWithFacilitiesExample#run()}. */ - @SuppressWarnings({ "static-method", "javadoc" }) + @SuppressWarnings({"static-method", "javadoc"}) @Test - public final void testRun() { + final void testRun() { RunWithFacilitiesExample example = new RunWithFacilitiesExample() ; example.run(); Scenario scenario = example.getScenario() ; Map, ? extends Person> persons = scenario.getPopulation().getPersons() ; - Assert.assertEquals( 124.84230476216275, persons.get(Id.createPersonId(1)).getSelectedPlan().getScore() , EPS ) ; - Assert.assertEquals( 112.84230476216275, persons.get(Id.createPersonId(2)).getSelectedPlan().getScore() , EPS ) ; + Assertions.assertEquals( 124.84230476216275, persons.get(Id.createPersonId(1)).getSelectedPlan().getScore() , EPS ) ; + Assertions.assertEquals( 112.84230476216275, persons.get(Id.createPersonId(2)).getSelectedPlan().getScore() , EPS ) ; } } diff --git a/src/test/java/org/matsim/codeexamples/integration/RunMultipleModesExampleTest.java b/src/test/java/org/matsim/codeexamples/integration/RunMultipleModesExampleTest.java index 11d9b27d..14e5f72a 100644 --- a/src/test/java/org/matsim/codeexamples/integration/RunMultipleModesExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/integration/RunMultipleModesExampleTest.java @@ -1,8 +1,7 @@ package org.matsim.codeexamples.integration; - -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; @@ -10,11 +9,11 @@ import org.matsim.testcases.MatsimTestUtils; public class RunMultipleModesExampleTest{ - @Rule + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRun() { + void testRun() { try{ Config config = RunMultipleModesExample.prepareConfig() ; @@ -29,7 +28,7 @@ public void testRun() { controler.run() ; } catch ( Exception ee ) { ee.printStackTrace(); - Assert.fail("something went wrong; see stack trace" ) ; + Assertions.fail("something went wrong; see stack trace" ) ; } } diff --git a/src/test/java/org/matsim/codeexamples/mobsim/mobsimPassingVehicleQ/RunMobsimWithMultipleModeVehiclesExampleTest.java b/src/test/java/org/matsim/codeexamples/mobsim/mobsimPassingVehicleQ/RunMobsimWithMultipleModeVehiclesExampleTest.java index 9155022c..6a2adce6 100644 --- a/src/test/java/org/matsim/codeexamples/mobsim/mobsimPassingVehicleQ/RunMobsimWithMultipleModeVehiclesExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/mobsim/mobsimPassingVehicleQ/RunMobsimWithMultipleModeVehiclesExampleTest.java @@ -1,10 +1,9 @@ package org.matsim.codeexamples.mobsim.mobsimPassingVehicleQ; import java.io.File; - -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -12,10 +11,10 @@ import org.matsim.testcases.MatsimTestUtils; public class RunMobsimWithMultipleModeVehiclesExampleTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void test() { + void test() { String[] args = { "scenarios/equil/example5-config.xml", "--config:controler.outputDirectory", utils.getOutputDirectory(), @@ -27,7 +26,7 @@ public void test() { RunMobsimWithMultipleModeVehiclesExample.main( args ); } catch ( Exception ee ) { ee.printStackTrace(); - Assert.fail(); + Assertions.fail(); } } diff --git a/src/test/java/org/matsim/codeexamples/mobsim/ownMobsimAgentWithPerception/RunOwnMobsimAgentWithPerceptionExampleTest.java b/src/test/java/org/matsim/codeexamples/mobsim/ownMobsimAgentWithPerception/RunOwnMobsimAgentWithPerceptionExampleTest.java index 813c2a6b..a7d41dfa 100644 --- a/src/test/java/org/matsim/codeexamples/mobsim/ownMobsimAgentWithPerception/RunOwnMobsimAgentWithPerceptionExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/mobsim/ownMobsimAgentWithPerception/RunOwnMobsimAgentWithPerceptionExampleTest.java @@ -1,12 +1,12 @@ package org.matsim.codeexamples.mobsim.ownMobsimAgentWithPerception; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class RunOwnMobsimAgentWithPerceptionExampleTest { @Test - public void main() { + void main() { try { RunOwnMobsimAgentWithPerceptionExample.main(new String[]{}); } catch (Exception ee ) { diff --git a/src/test/java/org/matsim/codeexamples/mobsim/replaceAgentFactory/RunReplaceAgentFactoryExampleTest.java b/src/test/java/org/matsim/codeexamples/mobsim/replaceAgentFactory/RunReplaceAgentFactoryExampleTest.java index cc91a8d8..c10fdf21 100644 --- a/src/test/java/org/matsim/codeexamples/mobsim/replaceAgentFactory/RunReplaceAgentFactoryExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/mobsim/replaceAgentFactory/RunReplaceAgentFactoryExampleTest.java @@ -1,9 +1,8 @@ package org.matsim.codeexamples.mobsim.replaceAgentFactory; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.Event; import org.matsim.core.config.Config; @@ -17,9 +16,10 @@ import jakarta.inject.Inject; public class RunReplaceAgentFactoryExampleTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; - - @Test public void testMain() { + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; + + @Test + void testMain() { try { final RunReplaceAgentFactoryExample main = new RunReplaceAgentFactoryExample();; final Config config = main.prepareConfig(); @@ -39,11 +39,11 @@ public class RunReplaceAgentFactoryExampleTest { main.run() ; - Assert.assertEquals( 9024, eventsCounter.getCnt() ); + Assertions.assertEquals( 9024, eventsCounter.getCnt() ); } catch (Exception ee) { ee.printStackTrace(); - Assert.fail() ; + Assertions.fail() ; } } diff --git a/src/test/java/org/matsim/codeexamples/population/demandGenerationFromShapefile/CreateDemandTest.java b/src/test/java/org/matsim/codeexamples/population/demandGenerationFromShapefile/CreateDemandTest.java index 9a8edc0b..71eb5a2a 100644 --- a/src/test/java/org/matsim/codeexamples/population/demandGenerationFromShapefile/CreateDemandTest.java +++ b/src/test/java/org/matsim/codeexamples/population/demandGenerationFromShapefile/CreateDemandTest.java @@ -1,15 +1,15 @@ package org.matsim.codeexamples.population.demandGenerationFromShapefile; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Population; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class CreateDemandTest { @Test - public void testCreate() { + void testCreate() { CreateDemand createDemand = new CreateDemand(); createDemand.create(); diff --git a/src/test/java/org/matsim/codeexamples/programming/controlerListener/ControlerListenerExampleTest.java b/src/test/java/org/matsim/codeexamples/programming/controlerListener/ControlerListenerExampleTest.java index 1f93eea9..48ea9484 100644 --- a/src/test/java/org/matsim/codeexamples/programming/controlerListener/ControlerListenerExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/controlerListener/ControlerListenerExampleTest.java @@ -18,23 +18,23 @@ * *********************************************************************** */ package org.matsim.codeexamples.programming.controlerListener; -import static org.junit.Assert.fail; - import java.io.File; import java.io.UncheckedIOException; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.fail; + +import org.junit.jupiter.api.Test; import org.matsim.codeexamples.programming.controlerListener.RunControlerListenerExample; import org.matsim.core.utils.io.IOUtils; public class ControlerListenerExampleTest { - + /** * Test method for {@link RunControlerListenerExample#main(java.lang.String[])}. */ @SuppressWarnings("static-method") @Test - public final void testMain() { + final void testMain() { final String pathname = "./output/example/"; try { diff --git a/src/test/java/org/matsim/codeexamples/programming/demandGenerationWithFacilities/IntegrationTest.java b/src/test/java/org/matsim/codeexamples/programming/demandGenerationWithFacilities/IntegrationTest.java index 2ad2e01d..1105e23b 100644 --- a/src/test/java/org/matsim/codeexamples/programming/demandGenerationWithFacilities/IntegrationTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/demandGenerationWithFacilities/IntegrationTest.java @@ -18,9 +18,8 @@ * *********************************************************************** */ package org.matsim.codeexamples.programming.demandGenerationWithFacilities; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.codeexamples.population.demandGenerationWithFacilities.RunCreateFacilities; import org.matsim.codeexamples.population.demandGenerationWithFacilities.RunCreatePopulationAndDemand; @@ -32,10 +31,10 @@ */ public class IntegrationTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public final void test() { + final void test() { // try { RunCreateFacilities.main(null); diff --git a/src/test/java/org/matsim/codeexamples/programming/eventsHandler/IntegrationTest.java b/src/test/java/org/matsim/codeexamples/programming/eventsHandler/IntegrationTest.java index 8dcf54b0..6ebcec4d 100644 --- a/src/test/java/org/matsim/codeexamples/programming/eventsHandler/IntegrationTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/eventsHandler/IntegrationTest.java @@ -1,17 +1,16 @@ package org.matsim.codeexamples.programming.eventsHandler; -import static org.junit.Assert.fail; - import java.io.File; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.fail; + +import org.junit.jupiter.api.Test; import org.matsim.codeexamples.events.eventsHandling.RunEventsHandlingWithControlerExample; import org.matsim.core.utils.io.IOUtils; public class IntegrationTest { - - @Test - public final void testMain() { + @Test + final void testMain() { try { IOUtils.deleteDirectoryRecursively(new File( RunEventsHandlingWithControlerExample.outputDirectory ).toPath()); } catch ( Exception ee ) { diff --git a/src/test/java/org/matsim/codeexamples/programming/individualizedScoringParameters/IntegrationTest.java b/src/test/java/org/matsim/codeexamples/programming/individualizedScoringParameters/IntegrationTest.java index bd08ff74..e94e318e 100644 --- a/src/test/java/org/matsim/codeexamples/programming/individualizedScoringParameters/IntegrationTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/individualizedScoringParameters/IntegrationTest.java @@ -1,8 +1,7 @@ package org.matsim.codeexamples.programming.individualizedScoringParameters; -import org.junit.Test; import org.matsim.core.utils.io.IOUtils; - +import org.junit.jupiter.api.Test; import org.matsim.codeexamples.scoring.individualizedScoringParameters.RunIndividualizedScoringExample; import java.io.File; @@ -13,7 +12,7 @@ */ public class IntegrationTest { @Test - public void testMain() { + void testMain() { final String pathname = "output/exampleIndividualScores/"; try { IOUtils.deleteDirectoryRecursively(new File(pathname).toPath()); diff --git a/src/test/java/org/matsim/codeexamples/programming/mobsimListener/MobsimListenerExampleTest.java b/src/test/java/org/matsim/codeexamples/programming/mobsimListener/MobsimListenerExampleTest.java index 67939821..b09ef3c7 100644 --- a/src/test/java/org/matsim/codeexamples/programming/mobsimListener/MobsimListenerExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/mobsimListener/MobsimListenerExampleTest.java @@ -21,8 +21,8 @@ */ package org.matsim.codeexamples.programming.mobsimListener; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.codeexamples.mobsim.mobsimListener.RunMobsimListenerExample; import org.matsim.testcases.MatsimTestUtils; @@ -32,14 +32,14 @@ */ public class MobsimListenerExampleTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link RunMobsimListenerExample} */ @SuppressWarnings("static-method") @Test - public final void testMain() { + final void testMain() { RunMobsimListenerExample.outputDirectory = utils.getOutputDirectory() + "/mobsim-listener"; RunMobsimListenerExample.main(null); } diff --git a/src/test/java/org/matsim/codeexamples/programming/multipleSubpopulations/SubpopulationsExampleTest.java b/src/test/java/org/matsim/codeexamples/programming/multipleSubpopulations/SubpopulationsExampleTest.java index 60b82536..ff6d37f0 100644 --- a/src/test/java/org/matsim/codeexamples/programming/multipleSubpopulations/SubpopulationsExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/multipleSubpopulations/SubpopulationsExampleTest.java @@ -18,11 +18,11 @@ * *********************************************************************** */ package org.matsim.codeexamples.programming.multipleSubpopulations; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -42,14 +42,14 @@ */ public class SubpopulationsExampleTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link RunSubpopulationsExample#main(java.lang.String[])}. */ @SuppressWarnings("static-method") @Test - public final void testMain() { + final void testMain() { try { // RunSubpopulationsExample.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil-extended" ), "config-with-subpopulation.xml" ).toString() // , "--config:controler.outputDirectory=" + utils.getOutputDirectory() @@ -74,11 +74,11 @@ public final void testMain() { final Population actual = PopulationUtils.createPopulation( ConfigUtils.createConfig() ); PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); boolean result = PopulationUtils.equalPopulation( expected, actual ); - Assert.assertTrue( "populations are different", result ); + Assertions.assertTrue( result, "populations are different" ); for( Person expectedPerson : expected.getPersons().values() ){ Person actualPerson = actual.getPersons().get( Id.createPersonId( expectedPerson.getId() ) ); - Assert.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); + Assertions.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); } } diff --git a/src/test/java/org/matsim/codeexamples/programming/personAttributes/RunPersonAttributesExampleTest.java b/src/test/java/org/matsim/codeexamples/programming/personAttributes/RunPersonAttributesExampleTest.java index 498b6e6d..0fa1d846 100644 --- a/src/test/java/org/matsim/codeexamples/programming/personAttributes/RunPersonAttributesExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/personAttributes/RunPersonAttributesExampleTest.java @@ -23,17 +23,17 @@ */ package org.matsim.codeexamples.programming.personAttributes; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.codeexamples.population.personAttributes.RunPersonAttributesExample; import org.matsim.testcases.MatsimTestUtils; public class RunPersonAttributesExampleTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void test(){ + void test(){ RunPersonAttributesExample.main(null); } diff --git a/src/test/java/org/matsim/codeexamples/programming/planStrategyForRemoval/RunPlanStrategyForRemovalExampleTest.java b/src/test/java/org/matsim/codeexamples/programming/planStrategyForRemoval/RunPlanStrategyForRemovalExampleTest.java index 7ad29bdd..a0b41199 100644 --- a/src/test/java/org/matsim/codeexamples/programming/planStrategyForRemoval/RunPlanStrategyForRemovalExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/planStrategyForRemoval/RunPlanStrategyForRemovalExampleTest.java @@ -18,10 +18,9 @@ * *********************************************************************** */ package org.matsim.codeexamples.programming.planStrategyForRemoval; - -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.codeexamples.strategies.planStrategyForRemoval.RunPlanSelectorForRemovalExample; import org.matsim.testcases.MatsimTestUtils; @@ -31,15 +30,15 @@ public class RunPlanStrategyForRemovalExampleTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public final void testMain() { + final void testMain() { try { RunPlanSelectorForRemovalExample.main(null); } catch(Exception e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } } diff --git a/src/test/java/org/matsim/codeexamples/programming/scenario/ScenarioElementAndInjection.java b/src/test/java/org/matsim/codeexamples/programming/scenario/ScenarioElementAndInjection.java index 240e39d5..3b5bf74c 100644 --- a/src/test/java/org/matsim/codeexamples/programming/scenario/ScenarioElementAndInjection.java +++ b/src/test/java/org/matsim/codeexamples/programming/scenario/ScenarioElementAndInjection.java @@ -2,9 +2,9 @@ import com.google.inject.Inject; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.roadpricing.RoadPricingScheme; import org.matsim.contrib.roadpricing.RoadPricingSchemeImpl; @@ -22,13 +22,13 @@ public class ScenarioElementAndInjection{ private static final Logger log = LogManager.getLogger( ScenarioElementAndInjection.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; /** * This is testing at what phase a scenario element would be available. */ @Test - public void test1() { + void test1() { // not really a test in its current form! Config config = ConfigUtils.createConfig() ; diff --git a/src/test/java/org/matsim/codeexamples/programming/simpleadaptivesignalengine/RunSimpleAdaptiveSignalExampleTest.java b/src/test/java/org/matsim/codeexamples/programming/simpleadaptivesignalengine/RunSimpleAdaptiveSignalExampleTest.java index e779c408..03b73367 100644 --- a/src/test/java/org/matsim/codeexamples/programming/simpleadaptivesignalengine/RunSimpleAdaptiveSignalExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/simpleadaptivesignalengine/RunSimpleAdaptiveSignalExampleTest.java @@ -21,8 +21,8 @@ */ package org.matsim.codeexamples.programming.simpleadaptivesignalengine; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.codeexamples.mobsim.simpleAdaptiveSignalEngine.RunSimpleAdaptiveSignalExample; import org.matsim.testcases.MatsimTestUtils; @@ -34,10 +34,10 @@ */ public class RunSimpleAdaptiveSignalExampleTest { - @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @RegisterExtension public MatsimTestUtils testUtils = new MatsimTestUtils(); + @Test - public void testRunSimpleAdaptiveSignalExample(){ + void testRunSimpleAdaptiveSignalExample(){ String[] args = {testUtils.getOutputDirectory()}; RunSimpleAdaptiveSignalExample.main(args); diff --git a/src/test/java/org/matsim/codeexamples/programming/tubClass/RunLeastCostPathCalculatorExampleIT.java b/src/test/java/org/matsim/codeexamples/programming/tubClass/RunLeastCostPathCalculatorExampleIT.java index e390c81b..57379911 100644 --- a/src/test/java/org/matsim/codeexamples/programming/tubClass/RunLeastCostPathCalculatorExampleIT.java +++ b/src/test/java/org/matsim/codeexamples/programming/tubClass/RunLeastCostPathCalculatorExampleIT.java @@ -21,7 +21,7 @@ import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.codeexamples.programming.leastCostPath.RunLeastCostPathCalculatorExample; import org.matsim.core.utils.io.IOUtils; @@ -32,7 +32,7 @@ public class RunLeastCostPathCalculatorExampleIT { @Test - public void test() { + void test() { try { IOUtils.deleteDirectoryRecursively(new File( RunLeastCostPathCalculatorExample.outputDirectory ).toPath()); } catch ( Exception ee ) { diff --git a/src/test/java/org/matsim/codeexamples/programming/withinDayReplanningFromPlans/IntegrationTest.java b/src/test/java/org/matsim/codeexamples/programming/withinDayReplanningFromPlans/IntegrationTest.java index f4b90831..fe6fa3e9 100644 --- a/src/test/java/org/matsim/codeexamples/programming/withinDayReplanningFromPlans/IntegrationTest.java +++ b/src/test/java/org/matsim/codeexamples/programming/withinDayReplanningFromPlans/IntegrationTest.java @@ -21,8 +21,8 @@ import java.io.File; import java.io.UncheckedIOException; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.utils.io.IOUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.codeexamples.withinday.withinDayReplanningFromPlans.RunWithinDayReplanningFromPlansExample; @@ -32,14 +32,14 @@ * */ public class IntegrationTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link RunWithinDayReplanningFromPlansExample} */ @SuppressWarnings("static-method") @Test - public final void testMain() { + final void testMain() { final String pathname = "./output/within-day"; try { IOUtils.deleteDirectoryRecursively(new File(pathname).toPath()); diff --git a/src/test/java/org/matsim/codeexamples/router/travelDisutility/RunTravelDisutilityExampleTest.java b/src/test/java/org/matsim/codeexamples/router/travelDisutility/RunTravelDisutilityExampleTest.java index 6ff1b57c..e7cfa571 100644 --- a/src/test/java/org/matsim/codeexamples/router/travelDisutility/RunTravelDisutilityExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/router/travelDisutility/RunTravelDisutilityExampleTest.java @@ -1,16 +1,16 @@ package org.matsim.codeexamples.router.travelDisutility; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class RunTravelDisutilityExampleTest { private static final Logger log = LogManager.getLogger(RunTravelDisutilityExampleTest.class) ; @Test - public void main() { + void main() { try { RunTravelDisutilityExample.main(null); } catch ( Exception ee ) { diff --git a/src/test/java/org/matsim/codeexamples/run/RunMatsimTest.java b/src/test/java/org/matsim/codeexamples/run/RunMatsimTest.java index 37c5e196..d11e3781 100644 --- a/src/test/java/org/matsim/codeexamples/run/RunMatsimTest.java +++ b/src/test/java/org/matsim/codeexamples/run/RunMatsimTest.java @@ -1,17 +1,16 @@ package org.matsim.codeexamples.run; - -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class RunMatsimTest{ - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void main(){ + void main(){ String[] args = {"scenarios/equil/config.xml" , "--config:controler.outputDirectory=" + utils.getOutputDirectory() @@ -22,7 +21,7 @@ public void main(){ RunMatsim.main( args ); } catch ( Exception ee ) { ee.printStackTrace(); - Assert.fail(); + Assertions.fail(); } } diff --git a/src/test/java/org/matsim/codeexamples/scoring/aaAddToScoring/RunAddToScoringExampleTest.java b/src/test/java/org/matsim/codeexamples/scoring/aaAddToScoring/RunAddToScoringExampleTest.java index 4349c493..c33f5009 100644 --- a/src/test/java/org/matsim/codeexamples/scoring/aaAddToScoring/RunAddToScoringExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/scoring/aaAddToScoring/RunAddToScoringExampleTest.java @@ -2,9 +2,9 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -16,15 +16,15 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.utils.eventsfilecomparison.EventsFileComparator; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunAddToScoringExampleTest{ private static final Logger log = LogManager.getLogger( RunAddToScoringExampleTest.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void testMain(){ + void testMain(){ try{ RunAddToScoringExample.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ).toString() , "--config:controler.outputDirectory=" + utils.getOutputDirectory() @@ -34,7 +34,7 @@ public void testMain(){ String expected = utils.getInputDirectory() + "/output_events.xml.gz" ; String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ; var result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result); } { final Population expected = PopulationUtils.createPopulation( ConfigUtils.createConfig() ); @@ -45,7 +45,7 @@ public void testMain(){ for( Person expectedPerson : expected.getPersons().values() ){ Person actualPerson = actual.getPersons().get( Id.createPersonId( expectedPerson.getId() ) ); - Assert.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); + Assertions.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); } } diff --git a/src/test/java/org/matsim/codeexamples/scoring/aaIncomeDependentScoring/RunIncomeDependentScoringExampleTest.java b/src/test/java/org/matsim/codeexamples/scoring/aaIncomeDependentScoring/RunIncomeDependentScoringExampleTest.java index 62bedb21..10cd7b11 100644 --- a/src/test/java/org/matsim/codeexamples/scoring/aaIncomeDependentScoring/RunIncomeDependentScoringExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/scoring/aaIncomeDependentScoring/RunIncomeDependentScoringExampleTest.java @@ -2,13 +2,12 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; -import org.matsim.codeexamples.RunAbcSimpleExample; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; import org.matsim.core.population.PopulationUtils; @@ -16,14 +15,15 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunIncomeDependentScoringExampleTest{ private static final Logger log = LogManager.getLogger( RunIncomeDependentScoringExampleTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMain(){ + void testMain(){ try{ RunIncomeDependentScoringExample.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ).toString() , "--config:controler.outputDirectory=" + utils.getOutputDirectory() @@ -43,7 +43,7 @@ public void testMain(){ for( Person expectedPerson : expected.getPersons().values() ){ Person actualPerson = actual.getPersons().get( Id.createPersonId( expectedPerson.getId() ) ); - Assert.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); + Assertions.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); } } diff --git a/src/test/java/org/matsim/codeexamples/scoring/customscoring/RunCustomScoringExampleTest.java b/src/test/java/org/matsim/codeexamples/scoring/customscoring/RunCustomScoringExampleTest.java index a4c57641..7f2f23bf 100644 --- a/src/test/java/org/matsim/codeexamples/scoring/customscoring/RunCustomScoringExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/scoring/customscoring/RunCustomScoringExampleTest.java @@ -2,9 +2,9 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -16,15 +16,15 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunCustomScoringExampleTest{ private static final Logger log = LogManager.getLogger( RunCustomScoringExampleTest.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void testMain(){ + void testMain(){ try{ RunCustomScoringExample.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ).toString() , "--config:controler.outputDirectory=" + utils.getOutputDirectory() @@ -44,7 +44,7 @@ public void testMain(){ for( Person expectedPerson : expected.getPersons().values() ){ Person actualPerson = actual.getPersons().get( Id.createPersonId( expectedPerson.getId() ) ); - Assert.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); + Assertions.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); } } diff --git a/src/test/java/org/matsim/codeexamples/scoring/individualizedScoringParameters/RunIndividualizedScoringExampleTest.java b/src/test/java/org/matsim/codeexamples/scoring/individualizedScoringParameters/RunIndividualizedScoringExampleTest.java index 2fe52dd7..4b600a56 100644 --- a/src/test/java/org/matsim/codeexamples/scoring/individualizedScoringParameters/RunIndividualizedScoringExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/scoring/individualizedScoringParameters/RunIndividualizedScoringExampleTest.java @@ -2,9 +2,9 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -15,15 +15,16 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunIndividualizedScoringExampleTest { private static final Logger log = LogManager.getLogger( RunIndividualizedScoringExampleTest.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; - @Test public void testMain(){ + @Test + void testMain(){ try{ RunIndividualizedScoringExample.main( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ).toString(), @@ -43,7 +44,7 @@ public class RunIndividualizedScoringExampleTest { for( Person expectedPerson : expected.getPersons().values() ){ Person actualPerson = actual.getPersons().get( Id.createPersonId( expectedPerson.getId() ) ); - Assert.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); + Assertions.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); } } diff --git a/src/test/java/org/matsim/codeexamples/scoring/ownMoneyScoring/RunOwnMoneyScoringExampleTest.java b/src/test/java/org/matsim/codeexamples/scoring/ownMoneyScoring/RunOwnMoneyScoringExampleTest.java index 38d2af57..04747bf9 100644 --- a/src/test/java/org/matsim/codeexamples/scoring/ownMoneyScoring/RunOwnMoneyScoringExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/scoring/ownMoneyScoring/RunOwnMoneyScoringExampleTest.java @@ -2,9 +2,9 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -16,14 +16,14 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class RunOwnMoneyScoringExampleTest{ private static final Logger log = LogManager.getLogger( RunOwnMoneyScoringExampleTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMain(){ + void testMain(){ try{ RunOwnMoneyScoringExample.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ).toString() , "--config:controler.outputDirectory=" + utils.getOutputDirectory() @@ -43,7 +43,7 @@ public void testMain(){ for( Person expectedPerson : expected.getPersons().values() ){ Person actualPerson = actual.getPersons().get( Id.createPersonId( expectedPerson.getId() ) ); - Assert.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); + Assertions.assertEquals( expectedPerson.getSelectedPlan().getScore(), actualPerson.getSelectedPlan().getScore() ); } } diff --git a/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyFromFile/RunPluggablePlanStrategyFromFileExampleTest.java b/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyFromFile/RunPluggablePlanStrategyFromFileExampleTest.java index 2e825be3..bad34071 100644 --- a/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyFromFile/RunPluggablePlanStrategyFromFileExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyFromFile/RunPluggablePlanStrategyFromFileExampleTest.java @@ -1,13 +1,13 @@ package org.matsim.codeexamples.strategies.pluggablePlanStrategyFromFile; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.codeexamples.strategies.pluggablePlanStrategyFromFile.RunPluggablePlanStrategyFromFileExample; public class RunPluggablePlanStrategyFromFileExampleTest { @Test - public void testMain() { + void testMain() { RunPluggablePlanStrategyFromFileExample.main(new String[]{}); } diff --git a/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/MyPlanSelectorTest.java b/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/MyPlanSelectorTest.java index 02eafdeb..e53655ce 100644 --- a/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/MyPlanSelectorTest.java +++ b/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/MyPlanSelectorTest.java @@ -1,7 +1,7 @@ package org.matsim.codeexamples.strategies.pluggablePlanStrategyInCode; -import org.junit.Test; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -11,7 +11,7 @@ public class MyPlanSelectorTest { @Test - public final void selectPlanTest() + final void selectPlanTest() { //set up Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -25,6 +25,6 @@ public final void selectPlanTest() Plan resultPlan = selector.selectPlan(person); //assert - Assert.assertEquals(plan0, resultPlan); + Assertions.assertEquals(plan0, resultPlan); } } diff --git a/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/MyPlanStrategyProviderTest.java b/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/MyPlanStrategyProviderTest.java index cb72bbd5..340b2306 100644 --- a/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/MyPlanStrategyProviderTest.java +++ b/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/MyPlanStrategyProviderTest.java @@ -1,7 +1,7 @@ package org.matsim.codeexamples.strategies.pluggablePlanStrategyInCode; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.codeexamples.strategies.pluggablePlanStrategyInCode.MyPlanStrategyProvider; import org.matsim.core.api.experimental.events.EventsManager; @@ -15,7 +15,7 @@ public class MyPlanStrategyProviderTest { @Test - public final void testGet() + final void testGet() { //set up EventsManager manager = EventsUtils.createEventsManager(); @@ -27,6 +27,6 @@ public final void testGet() PlanStrategy strategy = strategyFactory.get(); //assert - Assert.assertNotNull("strategy was null", strategy); + Assertions.assertNotNull(strategy, "strategy was null"); } } diff --git a/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/RunPluggablePlanStrategyInCodeExampleTest.java b/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/RunPluggablePlanStrategyInCodeExampleTest.java index faf58397..630fd559 100644 --- a/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/RunPluggablePlanStrategyInCodeExampleTest.java +++ b/src/test/java/org/matsim/codeexamples/strategies/pluggablePlanStrategyInCode/RunPluggablePlanStrategyInCodeExampleTest.java @@ -1,12 +1,12 @@ package org.matsim.codeexamples.strategies.pluggablePlanStrategyInCode; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.codeexamples.strategies.pluggablePlanStrategyInCode.RunPluggablePlanStrategyInCodeExample; public class RunPluggablePlanStrategyInCodeExampleTest { @Test - public final void testMain() + final void testMain() { String[] args = new String[0]; RunPluggablePlanStrategyInCodeExample.main(args);