use of com.graphhopper.util.Downloader in project graphhopper by graphhopper.
the class GMTEDProviderTest method testFileNotFound.
@Test
public void testFileNotFound() {
File file = new File(instance.getCacheDir(), instance.getFileName(46, -20) + ".gh");
File zipFile = new File(instance.getCacheDir(), instance.getFileName(46, -20) + ".tif");
file.delete();
zipFile.delete();
instance.setDownloader(new Downloader("test GH") {
@Override
public void downloadFile(String url, String toFile) throws IOException {
throw new FileNotFoundException("xyz");
}
});
assertEquals(0, instance.getEle(46, -20), 1);
// file not found
assertTrue(file.exists());
assertEquals(1048676, file.length());
instance.setDownloader(new Downloader("test GH") {
@Override
public void downloadFile(String url, String toFile) throws IOException {
throw new SocketTimeoutException("xyz");
}
});
try {
instance.setSleep(30);
instance.getEle(16, -20);
fail();
} catch (Exception ex) {
}
file.delete();
zipFile.delete();
}
Aggregations