1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.internal; |
21 |
|
|
22 |
|
import java.io.ByteArrayOutputStream; |
23 |
|
|
24 |
|
import org.junit.Test; |
25 |
|
|
26 |
|
import static org.hamcrest.CoreMatchers.equalTo; |
27 |
|
import static org.junit.Assert.assertThat; |
28 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 4 |
Complexity Density: 0.15 |
|
29 |
|
public class LineWrapperOutputStreamTest |
30 |
|
{ |
31 |
|
|
32 |
|
private static final String NEWLINE = System.getProperty("line.separator", "\n"); |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
34 |
1 |
@Test... |
35 |
|
public void testAvoidWrapping() throws Exception |
36 |
|
{ |
37 |
1 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
38 |
1 |
LineWrapperOutputStream lwos = new LineWrapperOutputStream(baos, 10); |
39 |
1 |
lwos.write("12345".getBytes()); |
40 |
1 |
lwos.write("1234567890".getBytes(),5,4); |
41 |
1 |
lwos.close(); |
42 |
1 |
assertThat(baos.toString(), equalTo("123456789")); |
43 |
|
} |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
45 |
1 |
@Test... |
46 |
|
public void testExactWrapping() throws Exception |
47 |
|
{ |
48 |
1 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
49 |
1 |
LineWrapperOutputStream lwos = new LineWrapperOutputStream(baos, 10); |
50 |
1 |
lwos.write("789012345".getBytes(),4,5); |
51 |
1 |
lwos.write("67890".getBytes()); |
52 |
1 |
lwos.close(); |
53 |
1 |
assertThat(baos.toString(), equalTo("1234567890" + NEWLINE)); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
56 |
1 |
@Test... |
57 |
|
public void testMultilineWrapping() throws Exception |
58 |
|
{ |
59 |
1 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
60 |
1 |
LineWrapperOutputStream lwos = new LineWrapperOutputStream(baos, 10); |
61 |
1 |
lwos.write("12345".getBytes()); |
62 |
1 |
lwos.write("3456789012345678".getBytes(),3,10); |
63 |
1 |
lwos.write("6789012345".getBytes(),0,7); |
64 |
1 |
lwos.close(); |
65 |
1 |
assertThat(baos.toString(), equalTo("1234567890" + NEWLINE + "1234567890" + NEWLINE + "12")); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
68 |
1 |
@Test... |
69 |
|
public void testOnByteWrapping() throws Exception |
70 |
|
{ |
71 |
1 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
72 |
1 |
LineWrapperOutputStream lwos = new LineWrapperOutputStream(baos, 10); |
73 |
1 |
lwos.write("123456789".getBytes()); |
74 |
1 |
lwos.write("0".getBytes()[0]); |
75 |
1 |
lwos.write("12345".getBytes()); |
76 |
1 |
lwos.close(); |
77 |
1 |
assertThat(baos.toString(), equalTo("1234567890" + NEWLINE + "12345")); |
78 |
|
} |
79 |
|
} |