Cleanup testcases (split, dependencies, assertions)
This commit is contained in:
parent
3787076839
commit
fd158dc0ce
4 changed files with 38 additions and 39 deletions
|
@ -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'
|
||||
|
|
|
@ -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<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
||||
List<OsmNodeNamed> 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,
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue