1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit;
16
17 import static org.apache.http.client.utils.DateUtils.formatDate;
18
19 import java.util.ArrayList;
20 import java.util.Date;
21 import java.util.List;
22
23 import org.apache.commons.lang3.time.DateUtils;
24 import org.htmlunit.util.NameValuePair;
25 import org.junit.jupiter.api.Test;
26
27
28
29
30
31
32
33 public final class AbstractPageTest extends WebServerTestCase {
34
35
36
37
38
39 @Test
40 public void onlyCacheToCleanUpWebResponse() throws Exception {
41 try (WebClient webClient = getWebClient()) {
42 webClient.getOptions().setMaxInMemory(3);
43
44 final List<NameValuePair> headers = new ArrayList<>();
45 headers.add(new NameValuePair("Expires", formatDate(DateUtils.addHours(new Date(), 1))));
46 getMockWebConnection().setDefaultResponse("something", 200, "Ok", "unknown_type", headers);
47 startWebServer(getMockWebConnection());
48
49 webClient.getPage(URL_FIRST);
50 webClient.getPage(URL_FIRST);
51 }
52 }
53 }