Merge pull request #473 from zod/move-testcases

Move testcases from brouter-server
This commit is contained in:
afischerdev 2022-10-23 12:40:38 +02:00 committed by GitHub
commit 00a2183153
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 59 deletions

View file

@ -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'

View file

@ -1,50 +1,46 @@
package btools.server;
import java.util.*;
package btools.router;
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;
import btools.router.*;
import btools.mapaccess.*;
public class RouterTest {
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<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
List<OsmNodeNamed> wplist = new ArrayList<>();
OsmNodeNamed n;
n = new OsmNodeNamed();
n.name = "from";
@ -60,7 +56,6 @@ public class RouterTest {
RoutingContext rctx = new RoutingContext();
rctx.localFunction = wd + "/../../../../misc/profiles2/trekking.brf";
// c.setAlternativeIdx( 1 );
RoutingEngine re = new RoutingEngine(
wd + "/" + trackname,

View file

@ -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'

View file

@ -0,0 +1,25 @@
package btools.mapaccess;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
public class IntegrityCheckTest {
@Test
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) {
assertNull(PhysicalFile.checkFileIntegrity(f));
}
}
}

View file

@ -1,29 +0,0 @@
package btools.server;
import java.io.File;
import java.net.URL;
import org.junit.Assert;
import org.junit.Test;
import btools.mapaccess.PhysicalFile;
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");
File[] files = segmentDir.listFiles();
for (File f : files) {
PhysicalFile.checkFileIntegrity(f);
}
}
}