Extend unit test for async stream reader

This commit is contained in:
2019-02-05 20:48:26 +01:00
parent 90b7c5cb35
commit 7b212abdc3
2 changed files with 170 additions and 17 deletions

View File

@ -66,7 +66,7 @@ public class AsyncUraTripReader implements AutoCloseable {
this.future = CompletableFuture.runAsync(() -> {
ObjectMapper mapper = new ObjectMapper();
try (InputStream is = url.openStream();
try (InputStream is = getInputStream(url);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String version = null;
String line = br.readLine();
@ -124,4 +124,15 @@ public class AsyncUraTripReader implements AutoCloseable {
future.cancel(true);
}
}
/**
* Get input stream from given URL.
*
* @param url URL to read from.
* @return Input Stream.
* @throws IOException On errors.
*/
private static InputStream getInputStream(URL url) throws IOException {
return url.openStream();
}
}