Skip to content

Commit

Permalink
[java] Inlining a private method that has a single use only
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Apr 12, 2020
1 parent 29be5ab commit fc2271d
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ public void dealsWithUtf16() {

@Test
public void manifestHasCorrectMimeType() throws IOException {
assertUrlHasContentType(server.whereIs("html5/test.appcache"), APPCACHE_MIME_TYPE);
String url = server.whereIs("html5/test.appcache");
HttpClient.Factory factory = HttpClient.Factory.createDefault();
HttpClient client = factory.createClient(new URL(url));
HttpResponse response = client.execute(new HttpRequest(HttpMethod.GET, url));

System.out.printf("Content for %s was %s\n", url, string(response));

assertTrue(StreamSupport.stream(response.getHeaders("Content-Type").spliterator(), false)
.anyMatch(header -> header.contains(APPCACHE_MIME_TYPE)));
}

@Test
Expand All @@ -137,14 +145,4 @@ public void uploadsFile() throws Throwable {
d -> d.findElement(By.xpath("//body")).getText().equals(FILE_CONTENTS));
}

private void assertUrlHasContentType(String url, String appcacheMimeType) throws IOException {
HttpClient.Factory factory = HttpClient.Factory.createDefault();
HttpClient client = factory.createClient(new URL(url));
HttpResponse response = client.execute(new HttpRequest(HttpMethod.GET, url));

System.out.printf("Content for %s was %s\n", url, string(response));

assertTrue(StreamSupport.stream(response.getHeaders("Content-Type").spliterator(), false)
.anyMatch(header -> header.contains(appcacheMimeType)));
}
}

0 comments on commit fc2271d

Please sign in to comment.