MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / cssFromCacheIsUsed

Method cssFromCacheIsUsed

src/test/java/org/htmlunit/CacheTest.java:503–532  ·  view source on GitHub ↗

@throws Exception if the test fails

()

Source from the content-addressed store, hash-verified

501 * @throws Exception if the test fails
502 */
503 @Test
504 public void cssFromCacheIsUsed() throws Exception {
505 final String html = DOCTYPE_HTML
506 + "<html><head><title>page 1</title>\n"
507 + "<link rel='stylesheet' type='text/css' href='foo.css' />\n"
508 + "<link rel='stylesheet' type='text/css' href='foo.css' />\n"
509 + "</head>\n"
510 + "<body>x</body>\n"
511 + "</html>";
512
513 final String css = ".x { color: red; }";
514
515 final WebClient client = getWebClient();
516
517 final MockWebConnection connection = new MockWebConnection();
518 client.setWebConnection(connection);
519
520 final URL pageUrl = new URL(URL_FIRST, "page1.html");
521 connection.setResponse(pageUrl, html);
522
523 final URL cssUrl = new URL(URL_FIRST, "foo.css");
524 final List<NameValuePair> headers = new ArrayList<>();
525 headers.add(new NameValuePair(LAST_MODIFIED, "Sun, 15 Jul 2007 20:46:27 GMT"));
526 connection.setResponse(cssUrl, css, 200, "OK", MimeType.TEXT_CSS, headers);
527
528 client.getPage(pageUrl);
529
530 assertEquals(2, connection.getRequestCount());
531 assertEquals(1, client.getCache().getSize());
532 }
533
534 /**
535 * @throws Exception if the test fails

Callers

nothing calls this directly

Calls 9

setWebConnectionMethod · 0.95
setResponseMethod · 0.95
getPageMethod · 0.95
getRequestCountMethod · 0.95
getCacheMethod · 0.95
getWebClientMethod · 0.65
addMethod · 0.45
assertEqualsMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected