1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.bo.log; |
17 |
|
|
18 |
|
import java.io.ByteArrayOutputStream; |
19 |
|
import java.io.PrintStream; |
20 |
|
|
21 |
|
import org.qedeq.kernel.bo.test.QedeqBoTestCase; |
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
@author |
27 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (87) |
Complexity: 20 |
Complexity Density: 0.3 |
|
28 |
|
public class QedeqLogTest extends QedeqBoTestCase { |
29 |
|
|
30 |
|
private QedeqLog listener; |
31 |
|
private LogListenerImpl listenerBasis; |
32 |
|
private ByteArrayOutputStream out; |
33 |
|
private LogListener thrower; |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
35 |
11
|
protected void setUp() throws Exception {... |
36 |
11
|
super.setUp(); |
37 |
11
|
out = new ByteArrayOutputStream(); |
38 |
11
|
listenerBasis = new LogListenerImpl(new PrintStream(out)); |
39 |
11
|
listener = QedeqLog.getInstance(); |
40 |
11
|
listener.addLog(listenerBasis); |
41 |
11
|
thrower = new LogListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
3
|
public void logMessage(String text) {... |
43 |
3
|
throw new RuntimeException("Boo! This test exception is ok!"); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
1
|
public void logRequest(String text, String url) {... |
47 |
1
|
throw new RuntimeException("Boo! This test exception is ok!"); |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
1
|
public void logSuccessfulReply(String text, String url) {... |
51 |
1
|
throw new RuntimeException("Boo! This test exception is ok!"); |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
2
|
public void logFailureReply(String text, String url,... |
55 |
|
String description) { |
56 |
2
|
throw new RuntimeException("Boo! This test exception is ok!"); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
1
|
public void logMessageState(String text, String url) {... |
60 |
1
|
throw new RuntimeException("Boo! This test exception is ok!"); |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
1
|
public void logFailureState(String text, String url,... |
64 |
|
String description) { |
65 |
1
|
throw new RuntimeException("Boo! This test exception is ok!"); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
1
|
public void logSuccessfulState(String text, String url) {... |
69 |
1
|
throw new RuntimeException("Boo! This test exception is ok!"); |
70 |
|
} |
71 |
|
}; |
72 |
11
|
listener.addLog(thrower); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
75 |
11
|
public void tearDown() throws Exception {... |
76 |
11
|
listener.removeLog(thrower); |
77 |
11
|
listener.removeLog(listenerBasis); |
78 |
11
|
super.tearDown(); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
81 |
1
|
public void testLogFailureReply() throws Exception{... |
82 |
1
|
listener.logFailureReply("failure and error", "http://mysite.org/mymodule.xml", "was this logged?"); |
83 |
1
|
System.out.println(out.toString("UTF-8")); |
84 |
1
|
assertTrue(out.toString("UTF-8").trim().endsWith("was this logged?")); |
85 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("reply")); |
86 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("failure and error")); |
87 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
90 |
1
|
public void testLogSuccessfulReply() throws Exception{... |
91 |
1
|
listener.logSuccessfulReply("successfully loaded", "http://mysite.org/mymodule.xml"); |
92 |
|
|
93 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("successfully loaded")); |
94 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
95 |
|
} |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
97 |
1
|
public void testLogMessageState() throws Exception{... |
98 |
1
|
listener.logMessageState("loading 10 percent complete", "http://mysite.org/mymodule.xml"); |
99 |
|
|
100 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("loading 10 percent complete")); |
101 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
102 |
|
} |
103 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1
PASS
|
|
104 |
1
|
public void testLogFailureState() throws Exception{... |
105 |
1
|
listener.logFailureState("error state occured", "http://mysite.org/mymodule.xml", "was this logged?"); |
106 |
|
|
107 |
1
|
assertTrue(out.toString("UTF-8").trim().endsWith("was this logged?")); |
108 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("failure")); |
109 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("error state occured")); |
110 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1
PASS
|
|
113 |
1
|
public void testLogSuccesfulState() throws Exception{... |
114 |
1
|
listener.logSuccessfulState("we are the champions", "http://mysite.org/mymodule.xml"); |
115 |
|
|
116 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("success")); |
117 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("we are the champions")); |
118 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
119 |
|
} |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
121 |
1
|
public void testLogRequest() throws Exception{... |
122 |
1
|
listener.logRequest("validate", "http://mysite.org/mymodule.xml"); |
123 |
|
|
124 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("validate")); |
125 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
128 |
1
|
public void testLogMessage() throws Exception{... |
129 |
1
|
listener.logMessage("we are on a yellow submarine"); |
130 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("we are on a yellow submarine")); |
131 |
|
} |
132 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
133 |
1
|
public void testRemoveLog() throws Exception{... |
134 |
1
|
listener.removeLog(null); |
135 |
1
|
listener.logMessage("we are on a yellow submarine"); |
136 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("we are on a yellow submarine")); |
137 |
|
} |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
139 |
1
|
public void testRemoveLog2() throws Exception{... |
140 |
1
|
listener.removeLog(listenerBasis); |
141 |
1
|
listener.logMessage("we are on a yellow submarine"); |
142 |
1
|
assertEquals(0, out.size()); |
143 |
|
} |
144 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1
PASS
|
|
145 |
1
|
public void testAddLog() throws Exception {... |
146 |
1
|
ByteArrayOutputStream out2 = new ByteArrayOutputStream(); |
147 |
1
|
listener.addLog(new LogListenerImpl(new PrintStream(out2))); |
148 |
1
|
listener.logFailureReply("failure", "http://mysite.org/mymodule.xml", "was this logged?"); |
149 |
1
|
assertTrue(out.toString("UTF-8").trim().endsWith("was this logged?")); |
150 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("reply")); |
151 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("failure")); |
152 |
1
|
assertTrue(0 <= out.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
153 |
1
|
assertTrue(out2.toString("UTF-8").trim().endsWith("was this logged?")); |
154 |
1
|
assertTrue(0 <= out2.toString("UTF-8").indexOf("reply")); |
155 |
1
|
assertTrue(0 <= out2.toString("UTF-8").indexOf("failure")); |
156 |
1
|
assertTrue(0 <= out2.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
157 |
|
} |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
159 |
1
|
public void testConstructor() throws Exception {... |
160 |
1
|
ByteArrayOutputStream out2 = new ByteArrayOutputStream(); |
161 |
1
|
LogListenerImpl listener2 = new LogListenerImpl(new PrintStream(out2)); |
162 |
1
|
listener2.logFailureReply("failure", "http://mysite.org/mymodule.xml", "was this logged?"); |
163 |
|
|
164 |
1
|
assertTrue(out2.toString("UTF-8").trim().endsWith("was this logged?")); |
165 |
1
|
assertTrue(0 <= out2.toString("UTF-8").indexOf("reply")); |
166 |
1
|
assertTrue(0 <= out2.toString("UTF-8").indexOf("failure")); |
167 |
1
|
assertTrue(0 <= out2.toString("UTF-8").indexOf("http://mysite.org/mymodule.xml")); |
168 |
|
} |
169 |
|
|
170 |
|
} |