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

Method maxSizeMaintained

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

@throws Exception if the test fails

()

Source from the content-addressed store, hash-verified

396 * @throws Exception if the test fails
397 */
398 @Test
399 public void maxSizeMaintained() throws Exception {
400 final String html = DOCTYPE_HTML
401 + "<html><head><title>page 1</title>\n"
402 + "<script src='foo1.js' type='text/javascript'/>\n"
403 + "<script src='foo2.js' type='text/javascript'/>\n"
404 + "</head><body>abc</body></html>";
405
406 final WebClient client = getWebClient();
407 client.getCache().setMaxSize(1);
408
409 final MockWebConnection connection = new MockWebConnection();
410 client.setWebConnection(connection);
411
412 final URL pageUrl = new URL(URL_FIRST, "page1.html");
413 connection.setResponse(pageUrl, html);
414
415 final List<NameValuePair> headers =
416 Collections.singletonList(new NameValuePair(LAST_MODIFIED, "Sun, 15 Jul 2007 20:46:27 GMT"));
417 connection.setResponse(new URL(URL_FIRST, "foo1.js"), ";", 200, "ok", MimeType.TEXT_JAVASCRIPT, headers);
418 connection.setResponse(new URL(URL_FIRST, "foo2.js"), ";", 200, "ok", MimeType.TEXT_JAVASCRIPT, headers);
419
420 client.getPage(pageUrl);
421 assertEquals(1, client.getCache().getSize());
422
423 client.getCache().clear();
424 assertEquals(0, client.getCache().getSize());
425 }
426
427 /**
428 * TODO: improve CSS caching to cache a COPY of the object as stylesheet objects can be modified dynamically.

Callers

nothing calls this directly

Calls 9

getCacheMethod · 0.95
setWebConnectionMethod · 0.95
setResponseMethod · 0.95
getPageMethod · 0.95
setMaxSizeMethod · 0.80
getWebClientMethod · 0.65
assertEqualsMethod · 0.45
getSizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected