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.rest.delivery.jcr; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertTrue; |
37 |
|
import static org.mockito.Matchers.any; |
38 |
|
import static org.mockito.Matchers.anyByte; |
39 |
|
import static org.mockito.Matchers.anyInt; |
40 |
|
import static org.mockito.Mockito.*; |
41 |
|
|
42 |
|
import java.io.OutputStream; |
43 |
|
|
44 |
|
import javax.json.stream.JsonGenerator; |
45 |
|
|
46 |
|
import org.junit.Before; |
47 |
|
import org.junit.Test; |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.43 |
|
49 |
|
public class OutputStreamWrapperTest { |
50 |
|
private OutputStreamWrapper outputStreamWrapper; |
51 |
|
private OutputStream outputStream; |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
53 |
3 |
@Before... |
54 |
|
public void setUp() throws Exception { |
55 |
3 |
JsonGenerator jsonGenerator = mock(JsonGenerator.class); |
56 |
3 |
outputStream = mock(OutputStream.class); |
57 |
3 |
outputStreamWrapper = new OutputStreamWrapper(outputStream, jsonGenerator); |
58 |
|
} |
59 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
1PASS
|
|
60 |
|
@Test... |
61 |
|
public void isWrapped() throws Exception { |
62 |
|
|
63 |
|
boolean isWrapped = OutputStreamWrapper.isWrapped(outputStreamWrapper); |
64 |
|
|
65 |
|
|
66 |
|
assertTrue(isWrapped); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
69 |
1 |
@Test... |
70 |
|
public void writingByteOfOutputStreamWrapperDelegatesToWrappedOutputStream() throws Exception { |
71 |
|
|
72 |
1 |
outputStreamWrapper.write(anyByte()); |
73 |
|
|
74 |
|
|
75 |
1 |
verify(outputStream, only()).write(anyByte()); |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
78 |
1 |
@Test... |
79 |
|
public void writingBytesWithOffsetAndLenOfOutputStreamWrapperDelegatesToWrappedOutputStream() throws Exception { |
80 |
|
|
81 |
1 |
outputStreamWrapper.write(any(byte[].class), anyInt(), anyInt()); |
82 |
|
|
83 |
|
|
84 |
1 |
verify(outputStream, only()).write(any(byte[].class), anyInt(), anyInt()); |
85 |
|
} |
86 |
|
} |