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.entry; |
35 |
|
|
36 |
|
import static org.mockito.Mockito.*; |
37 |
|
|
38 |
|
import info.magnolia.module.cache.filter.CachedEntry; |
39 |
|
import info.magnolia.module.cache.filter.CachedError; |
40 |
|
|
41 |
|
import java.io.File; |
42 |
|
import java.io.FileInputStream; |
43 |
|
import java.io.FileOutputStream; |
44 |
|
import java.io.ObjectInputStream; |
45 |
|
import java.io.ObjectOutputStream; |
46 |
|
|
47 |
|
import javax.servlet.http.HttpServletResponse; |
48 |
|
|
49 |
|
import org.junit.Test; |
50 |
|
|
51 |
|
|
52 |
|
@link |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 2 |
Complexity Density: 0.13 |
|
54 |
|
public class SingleReplayCacheEntryWrapperTest { |
55 |
|
|
56 |
|
private CachedEntry delegate = new CachedError(0, "", 0); |
57 |
|
private SingleReplayCacheEntryWrapper wrapper = new SingleReplayCacheEntryWrapper(delegate); |
58 |
|
private HttpServletResponse response = mock(HttpServletResponse.class); |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void replayBeforeSerialization() throws Exception { |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
1 |
wrapper.replay(null, response, null); |
66 |
|
|
67 |
|
|
68 |
1 |
verify(response).sendError(0); |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
71 |
1 |
@Test... |
72 |
|
public void replayAfterSerialization() throws Exception { |
73 |
|
|
74 |
1 |
File file = File.createTempFile(this.getClass().getName(), "class"); |
75 |
1 |
FileOutputStream fileOutputStream = new FileOutputStream(file); |
76 |
1 |
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); |
77 |
1 |
FileInputStream fileInputStream = new FileInputStream(file); |
78 |
1 |
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); |
79 |
1 |
objectOutputStream.writeObject(wrapper); |
80 |
1 |
SingleReplayCacheEntryWrapper deserializedEntry = (SingleReplayCacheEntryWrapper) objectInputStream.readObject(); |
81 |
|
|
82 |
|
|
83 |
1 |
wrapper.replay(null, response, null); |
84 |
|
|
85 |
|
|
86 |
1 |
verify(response).sendError(0); |
87 |
|
|
88 |
|
|
89 |
1 |
objectInputStream.close(); |
90 |
1 |
objectOutputStream.close(); |
91 |
1 |
fileInputStream.close(); |
92 |
1 |
fileOutputStream.close(); |
93 |
|
} |
94 |
|
} |