|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
25 | 25 |
|
26 | 26 |
|
27 | 27 | /**
|
| 28 | + * Tests for {@link CacheControl}. |
28 | 29 | * @author Brian Clozel
|
29 | 30 | */
|
30 |
| -public class CacheControlTests { |
| 31 | +class CacheControlTests { |
31 | 32 |
|
32 | 33 | @Test
|
33 |
| - public void emptyCacheControl() throws Exception { |
| 34 | + void emptyCacheControl() { |
34 | 35 | CacheControl cc = CacheControl.empty();
|
35 | 36 | assertThat(cc.getHeaderValue()).isNull();
|
36 | 37 | }
|
37 | 38 |
|
38 | 39 | @Test
|
39 |
| - public void maxAge() throws Exception { |
| 40 | + void maxAge() { |
40 | 41 | CacheControl cc = CacheControl.maxAge(1, TimeUnit.HOURS);
|
41 | 42 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600");
|
42 | 43 | }
|
43 | 44 |
|
44 | 45 | @Test
|
45 |
| - public void maxAge_duration() throws Exception { |
| 46 | + void maxAge_duration() { |
46 | 47 | CacheControl cc = CacheControl.maxAge(Duration.ofHours(1));
|
47 | 48 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600");
|
48 | 49 | }
|
49 | 50 |
|
50 | 51 | @Test
|
51 |
| - public void maxAgeAndDirectives() throws Exception { |
| 52 | + void maxAgeAndDirectives() { |
52 | 53 | CacheControl cc = CacheControl.maxAge(3600, TimeUnit.SECONDS).cachePublic().noTransform();
|
53 | 54 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600, no-transform, public");
|
54 | 55 | }
|
55 | 56 |
|
56 | 57 | @Test
|
57 |
| - public void maxAgeAndSMaxAge() throws Exception { |
| 58 | + void maxAgeAndSMaxAge() { |
58 | 59 | CacheControl cc = CacheControl.maxAge(1, TimeUnit.HOURS).sMaxAge(30, TimeUnit.MINUTES);
|
59 | 60 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600, s-maxage=1800");
|
60 | 61 | }
|
61 | 62 |
|
62 | 63 | @Test
|
63 |
| - public void maxAgeAndSMaxAge_duration() throws Exception { |
| 64 | + void maxAgeAndSMaxAge_duration() { |
64 | 65 | CacheControl cc = CacheControl.maxAge(Duration.ofHours(1)).sMaxAge(Duration.ofMinutes(30));
|
65 | 66 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600, s-maxage=1800");
|
66 | 67 | }
|
67 | 68 |
|
68 | 69 | @Test
|
69 |
| - public void noCachePrivate() throws Exception { |
| 70 | + void noCachePrivate() { |
70 | 71 | CacheControl cc = CacheControl.noCache().cachePrivate();
|
71 | 72 | assertThat(cc.getHeaderValue()).isEqualTo("no-cache, private");
|
72 | 73 | }
|
73 | 74 |
|
74 | 75 | @Test
|
75 |
| - public void noStore() throws Exception { |
| 76 | + void noStore() { |
76 | 77 | CacheControl cc = CacheControl.noStore();
|
77 | 78 | assertThat(cc.getHeaderValue()).isEqualTo("no-store");
|
78 | 79 | }
|
79 | 80 |
|
80 | 81 | @Test
|
81 |
| - public void staleIfError() throws Exception { |
| 82 | + void staleIfError() { |
82 | 83 | CacheControl cc = CacheControl.maxAge(1, TimeUnit.HOURS).staleIfError(2, TimeUnit.HOURS);
|
83 | 84 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600, stale-if-error=7200");
|
84 | 85 | }
|
85 | 86 |
|
86 | 87 | @Test
|
87 |
| - public void staleIfError_duration() throws Exception { |
| 88 | + void staleIfError_duration() { |
88 | 89 | CacheControl cc = CacheControl.maxAge(Duration.ofHours(1)).staleIfError(2, TimeUnit.HOURS);
|
89 | 90 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600, stale-if-error=7200");
|
90 | 91 | }
|
91 | 92 |
|
92 | 93 | @Test
|
93 |
| - public void staleWhileRevalidate() throws Exception { |
| 94 | + void staleWhileRevalidate() { |
94 | 95 | CacheControl cc = CacheControl.maxAge(1, TimeUnit.HOURS).staleWhileRevalidate(2, TimeUnit.HOURS);
|
95 | 96 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600, stale-while-revalidate=7200");
|
96 | 97 | }
|
97 | 98 |
|
98 | 99 | @Test
|
99 |
| - public void staleWhileRevalidate_duration() throws Exception { |
| 100 | + void staleWhileRevalidate_duration() { |
100 | 101 | CacheControl cc = CacheControl.maxAge(Duration.ofHours(1)).staleWhileRevalidate(2, TimeUnit.HOURS);
|
101 | 102 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600, stale-while-revalidate=7200");
|
102 | 103 | }
|
103 | 104 |
|
104 | 105 | @Test
|
105 |
| - public void immutable() throws Exception { |
| 106 | + void immutable() { |
106 | 107 | CacheControl cc = CacheControl.maxAge(Duration.ofHours(1)).immutable();
|
107 | 108 | assertThat(cc.getHeaderValue()).isEqualTo("max-age=3600, immutable");
|
108 | 109 | }
|
|
0 commit comments