- Timestamp:
- 2020-10-15T23:11:36+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java
r17197 r17211 13 13 import static org.hamcrest.CoreMatchers.is; 14 14 import static org.hamcrest.CoreMatchers.nullValue; 15 import static org.hamcrest.CoreMatchers.startsWith; 15 16 import static org.hamcrest.MatcherAssert.assertThat; 16 17 import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase; … … 23 24 import java.net.URL; 24 25 import java.nio.charset.StandardCharsets; 26 import java.nio.file.Files; 27 import java.nio.file.Path; 28 import java.nio.file.Paths; 25 29 import java.util.Collections; 26 30 import java.util.Map; … … 30 34 import java.util.stream.Collectors; 31 35 32 import org.junit.Assert;33 36 import org.junit.Before; 34 37 import org.junit.Rule; … … 339 342 @Test 340 343 public void testOpenUrlGzip() throws IOException { 341 final byte[] gpx = Utils.readBytesFromStream(getClass().getClassLoader().getResourceAsStream("tracks/tracks.gpx.gz")); 344 final Path path = Paths.get(TestUtils.getTestDataRoot(), "tracks/tracks.gpx.gz"); 345 final byte[] gpx = Files.readAllBytes(path); 342 346 localServer.stubFor(get(urlEqualTo("/trace/1613906/data")) 343 347 .willReturn(aResponse() … … 348 352 final URL url = new URL(localServer.url("/trace/1613906/data")); 349 353 try (BufferedReader x = HttpClient.create(url).connect().uncompress(true).getContentReader()) { 350 Assert.assertTrue(x.readLine().startsWith("<?xml version="));354 assertThat(x.readLine(), startsWith("<?xml version=")); 351 355 } 352 356 } … … 358 362 @Test 359 363 public void testOpenUrlBzip() throws IOException { 360 final byte[] gpx = Utils.readBytesFromStream(getClass().getClassLoader().getResourceAsStream("tracks/tracks.gpx.bz2")); 364 final Path path = Paths.get(TestUtils.getTestDataRoot(), "tracks/tracks.gpx.bz2"); 365 final byte[] gpx = Files.readAllBytes(path); 361 366 localServer.stubFor(get(urlEqualTo("/trace/785544/data")) 362 367 .willReturn(aResponse() … … 367 372 final URL url = new URL(localServer.url("/trace/785544/data")); 368 373 try (BufferedReader x = HttpClient.create(url).connect().uncompress(true).getContentReader()) { 369 Assert.assertTrue(x.readLine().startsWith("<?xml version="));374 assertThat(x.readLine(), startsWith("<?xml version=")); 370 375 } 371 376 } … … 377 382 @Test 378 383 public void testOpenUrlBzipAccordingToContentDisposition() throws IOException { 379 final byte[] gpx = Utils.readBytesFromStream(getClass().getClassLoader().getResourceAsStream("tracks/tracks.gpx.bz2")); 384 final Path path = Paths.get(TestUtils.getTestDataRoot(), "tracks/tracks.gpx.bz2"); 385 final byte[] gpx = Files.readAllBytes(path); 380 386 localServer.stubFor(get(urlEqualTo("/trace/1350010/data")) 381 387 .willReturn(aResponse() … … 388 394 try (BufferedReader x = HttpClient.create(url).connect() 389 395 .uncompress(true).uncompressAccordingToContentDisposition(true).getContentReader()) { 390 Assert.assertTrue(x.readLine().startsWith("<?xml version="));396 assertThat(x.readLine(), startsWith("<?xml version=")); 391 397 } 392 398 }
Note:
See TracChangeset
for help on using the changeset viewer.