diff --git a/brouter-core/build.gradle b/brouter-core/build.gradle index c96982f..cb7dde5 100644 --- a/brouter-core/build.gradle +++ b/brouter-core/build.gradle @@ -3,11 +3,12 @@ plugins { } dependencies { - implementation project(':brouter-mapaccess') implementation project(':brouter-util') implementation project(':brouter-expressions') implementation project(':brouter-codec') - testImplementation 'junit:junit:4.13.1' - + testImplementation 'junit:junit:4.13.2' } + +// MapcreatorTest generates segments which are used in tests +test.dependsOn ':brouter-map-creator:test' diff --git a/brouter-core/src/test/java/btools/router/RoutingEngineTest.java b/brouter-core/src/test/java/btools/router/RoutingEngineTest.java index 1ef99f2..ba2dc90 100644 --- a/brouter-core/src/test/java/btools/router/RoutingEngineTest.java +++ b/brouter-core/src/test/java/btools/router/RoutingEngineTest.java @@ -1,47 +1,46 @@ package btools.router; -import java.util.*; - import org.junit.Assert; +import org.junit.Before; import org.junit.Test; -import java.net.URL; import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; public class RoutingEngineTest { private File workingDir; - @Test - public void routerTest() throws Exception { + @Before + public void before() { URL resulturl = this.getClass().getResource("/testtrack0.gpx"); - Assert.assertTrue("reference result not found: ", resulturl != null); + Assert.assertNotNull("reference result not found: ", resulturl); File resultfile = new File(resulturl.getFile()); workingDir = resultfile.getParentFile(); + } - String msg; - - // first test: route within dreiech test-map crossing tile border - - msg = calcRoute(8.720897, 50.002515, 8.723658, 49.997510, "testtrack"); - + @Test + public void routeCrossingSegmentBorder() { + String msg = calcRoute(8.720897, 50.002515, 8.723658, 49.997510, "testtrack"); // error message from router? - Assert.assertTrue("routing failed: " + msg, msg == null); + Assert.assertNull("routing failed: " + msg, msg); // if the track didn't change, we expect the first alternative also File a1 = new File(workingDir, "testtrack1.gpx"); Assert.assertTrue("result content missmatch", a1.exists()); - - // second test: to-point far off - - msg = calcRoute(8.720897, 50.002515, 16.723658, 49.997510, "notrack"); - - Assert.assertTrue(msg, msg != null && msg.indexOf("not found") >= 0); } - private String calcRoute(double flon, double flat, double tlon, double tlat, String trackname) throws Exception { + @Test + public void routeDestinationPointFarOff() { + String msg = calcRoute(8.720897, 50.002515, 16.723658, 49.997510, "notrack"); + Assert.assertTrue(msg, msg != null && msg.contains("not found")); + } + + private String calcRoute(double flon, double flat, double tlon, double tlat, String trackname) { String wd = workingDir.getAbsolutePath(); - List wplist = new ArrayList(); + List wplist = new ArrayList<>(); OsmNodeNamed n; n = new OsmNodeNamed(); n.name = "from"; @@ -57,7 +56,6 @@ public class RoutingEngineTest { RoutingContext rctx = new RoutingContext(); rctx.localFunction = wd + "/../../../../misc/profiles2/trekking.brf"; - // c.setAlternativeIdx( 1 ); RoutingEngine re = new RoutingEngine( wd + "/" + trackname, diff --git a/brouter-mapaccess/build.gradle b/brouter-mapaccess/build.gradle index c920239..40189cb 100644 --- a/brouter-mapaccess/build.gradle +++ b/brouter-mapaccess/build.gradle @@ -6,4 +6,8 @@ dependencies { implementation project(':brouter-util') implementation project(':brouter-codec') implementation project(':brouter-expressions') + testImplementation 'junit:junit:4.13.2' } + +// MapcreatorTest generates segments which are used in tests +test.dependsOn ':brouter-map-creator:test' diff --git a/brouter-mapaccess/src/test/java/btools/mapaccess/IntegrityCheckTest.java b/brouter-mapaccess/src/test/java/btools/mapaccess/IntegrityCheckTest.java index fa3a0f9..6685895 100644 --- a/brouter-mapaccess/src/test/java/btools/mapaccess/IntegrityCheckTest.java +++ b/brouter-mapaccess/src/test/java/btools/mapaccess/IntegrityCheckTest.java @@ -1,28 +1,24 @@ package btools.mapaccess; -import java.io.File; -import java.net.URL; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; -import org.junit.Assert; import org.junit.Test; -import btools.mapaccess.PhysicalFile; +import java.io.File; +import java.io.IOException; public class IntegrityCheckTest { - private File workingDir; - @Test - public void integrityTest() throws Exception { - URL resulturl = this.getClass().getResource("/testtrack0.gpx"); - Assert.assertTrue("reference result not found: ", resulturl != null); - File resultfile = new File(resulturl.getFile()); - workingDir = resultfile.getParentFile(); - - File segmentDir = new File(workingDir, "/../../../../brouter-map-creator/build/resources/test/tmp/segments"); + public void integrityTest() throws IOException { + File workingDir = new File(".").getCanonicalFile(); + File segmentDir = new File(workingDir, "../brouter-map-creator/build/resources/test/tmp/segments"); File[] files = segmentDir.listFiles(); + assertNotNull("Missing segments", files); + for (File f : files) { - PhysicalFile.checkFileIntegrity(f); + assertNull(PhysicalFile.checkFileIntegrity(f)); } }