1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.cache.filter; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertEquals; |
37 |
|
|
38 |
|
import info.magnolia.module.cache.util.GZipUtil; |
39 |
|
|
40 |
|
import java.io.IOException; |
41 |
|
|
42 |
|
import org.apache.commons.collections4.map.MultiValueMap; |
43 |
|
import org.junit.Test; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@version |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
50 |
|
public class InMemoryCachedPageTest { |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
52 |
1 |
@Test... |
53 |
|
public void testUnGZipIfContentIsGZipped() throws IOException { |
54 |
1 |
final String s = "hello"; |
55 |
1 |
final byte[] gzipped = GZipUtil.gzip(s.getBytes()); |
56 |
1 |
final MultiValueMap responseHeaders = new MultiValueMap(); |
57 |
1 |
responseHeaders.put("Content-Encoding", "gzip"); |
58 |
1 |
final InMemoryCachedEntry p = new InMemoryCachedEntry(gzipped, "text/plain", "cha", 1, responseHeaders, System.currentTimeMillis(), "originalUrl", -1); |
59 |
1 |
assertEquals(gzipped, p.getGzippedContent()); |
60 |
1 |
assertEquals("hello", new String(p.getPlainContent())); |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
63 |
1 |
@Test... |
64 |
|
public void testGZipIfContentIsNotGZipped() throws IOException { |
65 |
1 |
final InMemoryCachedEntry p = new InMemoryCachedEntry("hello".getBytes(), "foo/bar", "cha", 1, new MultiValueMap(), System.currentTimeMillis(), "originalUrl", -1); |
66 |
1 |
assertEquals("hello", new String(GZipUtil.ungzip(p.getGzippedContent()))); |
67 |
1 |
assertEquals("hello", new String(p.getPlainContent())); |
68 |
|
} |
69 |
|
} |