1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.easymock.tests; |
18 |
|
|
19 |
|
import static org.junit.Assert.*; |
20 |
|
|
21 |
|
import org.easymock.Capture; |
22 |
|
import org.easymock.CaptureType; |
23 |
|
import org.easymock.internal.Invocation; |
24 |
|
import org.easymock.internal.LastControl; |
25 |
|
import org.easymock.internal.matchers.Captures; |
26 |
|
import org.junit.After; |
27 |
|
import org.junit.Before; |
28 |
|
import org.junit.Test; |
29 |
|
|
30 |
|
|
31 |
|
@author |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 4 |
Complexity Density: 0,25 |
|
33 |
|
public class CapturesMatcherTest { |
34 |
|
|
35 |
|
private final Capture<String> capture = new Capture<String>(CaptureType.ALL); |
36 |
|
|
37 |
|
private final Captures<String> matcher = new Captures<String>(capture); |
38 |
|
|
39 |
|
private StringBuffer buffer; |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
41 |
2
|
@Before... |
42 |
|
public void setUp() throws Exception { |
43 |
2
|
LastControl.pushCurrentInvocation(new Invocation(this, getClass().getMethod("test"), new Object[0])); |
44 |
2
|
buffer = new StringBuffer(); |
45 |
|
} |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
2
|
@After... |
48 |
|
public void tearDown() { |
49 |
2
|
LastControl.popCurrentInvocation(); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
52 |
2
|
@Test... |
53 |
|
public void test() throws Exception { |
54 |
|
|
55 |
2
|
matcher.appendTo(buffer); |
56 |
2
|
assertEquals("capture(Nothing captured yet)", buffer.toString()); |
57 |
|
|
58 |
2
|
assertTrue(matcher.matches(null)); |
59 |
|
|
60 |
2
|
matcher.validateCapture(); |
61 |
|
|
62 |
2
|
clearBuffer(); |
63 |
2
|
matcher.appendTo(buffer); |
64 |
2
|
assertEquals("capture(null)", buffer.toString()); |
65 |
|
|
66 |
2
|
assertTrue(matcher.matches("s")); |
67 |
|
|
68 |
2
|
matcher.validateCapture(); |
69 |
|
|
70 |
2
|
clearBuffer(); |
71 |
2
|
matcher.appendTo(buffer); |
72 |
2
|
assertEquals("capture([null, s])", buffer.toString()); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
4
|
private void clearBuffer() {... |
76 |
4
|
buffer.delete(0, buffer.length()); |
77 |
|
} |
78 |
|
} |