OsmAnd/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java

80 lines
2.2 KiB
Java
Raw Normal View History

package net.osmand.router;
2012-07-07 14:31:47 +02:00
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
2012-07-09 01:09:05 +02:00
import net.osmand.Algoritms;
2012-07-07 14:31:47 +02:00
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.router.BinaryRoutePlanner;
import net.osmand.router.RoutingConfiguration;
import net.osmand.swing.DataExtractionSettings;
2012-07-13 09:51:00 +02:00
import net.osmand.swing.NativeSwingRendering;
2012-07-07 14:31:47 +02:00
import org.junit.Before;
import org.junit.Test;
public class JUnitRouteTest {
static BinaryMapIndexReader[] rs;
2012-09-29 01:52:28 +02:00
static NativeSwingRendering lib;
2012-07-07 14:31:47 +02:00
@Before
public void setupFiles() throws IOException {
if(rs != null){
return;
}
2012-09-29 22:52:40 +02:00
// test without native because it is not present on the server
// lib = NativeSwingRendering.getDefaultFromSettings();
2012-08-26 18:39:48 +02:00
BinaryRoutePlanner.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = true;
2012-07-09 01:16:44 +02:00
String obfdir = System.getenv("OBF_DIR");
2012-07-09 01:09:05 +02:00
if(Algoritms.isEmpty(obfdir)){
obfdir = DataExtractionSettings.getSettings().getBinaryFilesDir();
}
2012-07-07 14:31:47 +02:00
List<File> files = new ArrayList<File>();
2012-07-09 01:09:05 +02:00
for (File f : new File(obfdir).listFiles()) {
2012-07-07 14:31:47 +02:00
if (f.getName().endsWith(".obf")) {
files.add(f);
}
}
rs = new BinaryMapIndexReader[files.size()];
int it = 0;
for (File f : files) {
RandomAccessFile raf = new RandomAccessFile(f, "r"); //$NON-NLS-1$ //$NON-NLS-2$
2012-08-25 20:39:45 +02:00
rs[it++] = new BinaryMapIndexReader(raf);
2012-07-07 14:31:47 +02:00
}
}
2012-07-19 01:14:20 +02:00
@Test
2012-09-28 09:31:36 +02:00
public void runCZ() throws Exception {
2012-07-19 01:14:20 +02:00
RouterTestsSuite.test(lib, getClass().getResourceAsStream("cz.test.xml"), rs, RoutingConfiguration.getDefault());
}
2012-07-07 14:31:47 +02:00
@Test
2012-09-28 09:31:36 +02:00
public void runNL() throws Exception {
2012-07-13 09:51:00 +02:00
RouterTestsSuite.test(lib, getClass().getResourceAsStream("nl.test.xml"), rs, RoutingConfiguration.getDefault());
2012-07-07 14:31:47 +02:00
}
@Test
2012-09-28 09:31:36 +02:00
public void runNL2() throws Exception {
2012-07-13 09:51:00 +02:00
RouterTestsSuite.test(lib, getClass().getResourceAsStream("nl2.test.xml"), rs, RoutingConfiguration.getDefault());
2012-07-07 14:31:47 +02:00
}
2012-07-21 17:20:44 +02:00
@Test
2012-09-28 09:31:36 +02:00
public void runNLLeid() throws Exception {
2012-07-21 17:20:44 +02:00
RouterTestsSuite.test(lib, getClass().getResourceAsStream("nl_leid.test.xml"), rs, RoutingConfiguration.getDefault());
}
2012-07-15 00:20:13 +02:00
@Test
2012-09-28 09:31:36 +02:00
public void runBLR() throws Exception {
2012-07-15 00:20:13 +02:00
RouterTestsSuite.test(lib, getClass().getResourceAsStream("blr.test.xml"), rs, RoutingConfiguration.getDefault());
}
2012-07-07 14:31:47 +02:00
}