OsmAnd/DataExtractionOSM/src/net/osmand/router/test/JUnitRouteTest.java

62 lines
1.7 KiB
Java
Raw Normal View History

2012-07-07 14:31:47 +02:00
package net.osmand.router.test;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
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;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
public class JUnitRouteTest {
static BinaryMapIndexReader[] rs;
@Before
public void setupFiles() throws IOException {
if(rs != null){
return;
}
BinaryRoutePlanner.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = false;
2012-07-09 01:09:05 +02:00
String obfdir = System.getenv("obfdir");
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$
rs[it++] = new BinaryMapIndexReader(raf, false);
}
}
@Test
public void runNL() throws SAXException, IOException, ParserConfigurationException {
RouterTestsSuite.test(getClass().getResourceAsStream("nl.test.xml"), rs, RoutingConfiguration.getDefault());
}
@Test
public void runNL2() throws SAXException, IOException, ParserConfigurationException {
RouterTestsSuite.test(getClass().getResourceAsStream("nl2.test.xml"), rs, RoutingConfiguration.getDefault());
}
}