1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.se.common; |
17 |
|
|
18 |
|
import org.qedeq.base.io.SourceArea; |
19 |
|
import org.qedeq.base.test.QedeqTestCase; |
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
@author |
25 |
|
|
|
|
| 91.6% |
Uncovered Elements: 11 (131) |
Complexity: 20 |
Complexity Density: 0.18 |
|
26 |
|
public class SourceFileExceptionListTest extends QedeqTestCase { |
27 |
|
|
28 |
|
private SourceFileExceptionList empty; |
29 |
|
|
30 |
|
private SourceFileExceptionList one; |
31 |
|
|
32 |
|
private SourceFileExceptionList two; |
33 |
|
|
34 |
|
private SourceFileExceptionList three; |
35 |
|
|
36 |
|
private SourceFileExceptionList four; |
37 |
|
|
38 |
|
private final Plugin plugin = new Plugin(){ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
0
|
public String getServiceDescription() {... |
40 |
0
|
return "i am doing nothing"; |
41 |
|
} |
42 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
43 |
0
|
public String getServiceId() {... |
44 |
0
|
return this.getClass().toString(); |
45 |
|
} |
46 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
0
|
public String getServiceAction() {... |
48 |
0
|
return "dummy"; |
49 |
|
} |
50 |
|
}; |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
0
|
public SourceFileExceptionListTest(){... |
53 |
0
|
super(); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
10
|
public SourceFileExceptionListTest(final String name){... |
57 |
10
|
super(name); |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
60 |
10
|
protected void setUp() throws Exception {... |
61 |
10
|
super.setUp(); |
62 |
10
|
empty = new SourceFileExceptionList(); |
63 |
10
|
final SourceFileException oneEx = new SourceFileException(plugin, 4711, |
64 |
|
"no big problem", new RuntimeException("something bad"), (SourceArea) null, (SourceArea) null); |
65 |
10
|
one = new SourceFileExceptionList(oneEx); |
66 |
10
|
one.add(oneEx); |
67 |
10
|
two = new SourceFileExceptionList(one); |
68 |
10
|
two.add(new SourceFileException(plugin, 815, |
69 |
|
"no big problem", new RuntimeException("something else"), (SourceArea) null, (SourceArea) null)); |
70 |
10
|
three = new SourceFileExceptionList(); |
71 |
10
|
three.add(two); |
72 |
10
|
three.add(two); |
73 |
10
|
three.add(new SourceFileException(plugin, 17234, |
74 |
|
"no big problem", new RuntimeException("something other"), (SourceArea) null, (SourceArea) null)); |
75 |
10
|
four = new SourceFileExceptionList(two); |
76 |
10
|
four.add(new SourceFileException(plugin, 815, |
77 |
|
"big problem", new RuntimeException("something else"), (SourceArea) null, (SourceArea) null)); |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
80 |
10
|
protected void tearDown() throws Exception {... |
81 |
10
|
empty = null; |
82 |
10
|
one = null; |
83 |
10
|
two = null; |
84 |
10
|
three = null; |
85 |
10
|
four = null; |
86 |
10
|
super.tearDown(); |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1
PASS
|
|
89 |
1
|
public void testContructor() {... |
90 |
1
|
assertEquals(0, empty.size()); |
91 |
1
|
SourceFileExceptionList sf1 = new SourceFileExceptionList((SourceFileException) null); |
92 |
1
|
assertEquals(0, sf1.size()); |
93 |
1
|
sf1.clear(); |
94 |
1
|
assertEquals(0, sf1.size()); |
95 |
1
|
SourceFileExceptionList sf2 = new SourceFileExceptionList((SourceFileExceptionList) null); |
96 |
1
|
assertEquals(0, sf1.size()); |
97 |
1
|
sf2.clear(); |
98 |
1
|
assertEquals(0, sf2.size()); |
99 |
|
} |
100 |
|
|
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
102 |
1
|
public void testClear() {... |
103 |
1
|
assertEquals(1, one.size()); |
104 |
1
|
one.clear(); |
105 |
1
|
assertEquals(0, one.size()); |
106 |
1
|
assertEquals(3, three.size()); |
107 |
1
|
three.clear(); |
108 |
1
|
assertEquals(0, three.size()); |
109 |
|
} |
110 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
111 |
1
|
public void testAdd1() {... |
112 |
1
|
assertEquals(1, one.size()); |
113 |
1
|
one.add((SourceFileException) null); |
114 |
1
|
assertEquals(1, one.size()); |
115 |
1
|
one.add(new SourceFileException(plugin, 4711, |
116 |
|
"no big problem", new RuntimeException("something bad"), (SourceArea) null, (SourceArea) null)); |
117 |
1
|
assertEquals(1, one.size()); |
118 |
1
|
one.add(new SourceFileException(plugin, 4711, |
119 |
|
"no big problem", new RuntimeException("something bad2"), (SourceArea) null, (SourceArea) null)); |
120 |
1
|
assertEquals(2, one.size()); |
121 |
|
} |
122 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1
PASS
|
|
123 |
1
|
public void testAdd2() {... |
124 |
1
|
assertEquals(1, one.size()); |
125 |
1
|
one.add((SourceFileExceptionList) null); |
126 |
1
|
assertEquals(1, one.size()); |
127 |
1
|
one.add(one); |
128 |
1
|
assertEquals(1, one.size()); |
129 |
1
|
one.add(two); |
130 |
1
|
assertEquals(2, one.size()); |
131 |
1
|
three.add(new SourceFileException(plugin, 4711, |
132 |
|
"no big problem", new RuntimeException("something bad2"), (SourceArea) null, (SourceArea) null)); |
133 |
1
|
one.add(three); |
134 |
1
|
assertEquals(4, one.size()); |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1
PASS
|
|
140 |
1
|
public void testSize() {... |
141 |
1
|
assertEquals(0, empty.size()); |
142 |
1
|
assertEquals(1, one.size()); |
143 |
1
|
assertEquals(2, two.size()); |
144 |
1
|
assertEquals(3, three.size()); |
145 |
1
|
assertEquals(3, four.size()); |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1
PASS
|
|
151 |
1
|
public void testEquals() {... |
152 |
1
|
assertEquals(empty, empty); |
153 |
1
|
assertEquals(one, one); |
154 |
1
|
assertEquals(two, two); |
155 |
1
|
assertEquals(three, three); |
156 |
1
|
assertFalse(empty.equals(null)); |
157 |
1
|
assertFalse(empty.equals(empty.toString())); |
158 |
1
|
assertFalse(empty.equals(one)); |
159 |
1
|
assertFalse(empty.equals(two)); |
160 |
1
|
assertFalse(empty.equals(three)); |
161 |
1
|
assertFalse(one.equals(null)); |
162 |
1
|
assertFalse(one.equals(one.toString())); |
163 |
1
|
assertFalse(one.equals(empty)); |
164 |
1
|
assertFalse(one.equals(two)); |
165 |
1
|
assertFalse(one.equals(three)); |
166 |
1
|
assertFalse(two.equals(null)); |
167 |
1
|
assertFalse(two.equals(two.toString())); |
168 |
1
|
assertFalse(two.equals(one)); |
169 |
1
|
assertFalse(two.equals(empty)); |
170 |
1
|
assertFalse(two.equals(three)); |
171 |
1
|
assertFalse(three.equals(null)); |
172 |
1
|
assertFalse(three.equals(three.toString())); |
173 |
1
|
assertFalse(three.equals(one)); |
174 |
1
|
assertFalse(three.equals(empty)); |
175 |
1
|
assertFalse(three.equals(one)); |
176 |
1
|
assertFalse(three.equals(four)); |
177 |
1
|
assertFalse(four.equals(three)); |
178 |
|
} |
179 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
180 |
1
|
public void testHashCode() {... |
181 |
1
|
assertFalse(empty.hashCode() == one.hashCode()); |
182 |
1
|
assertFalse(one.hashCode() == two.hashCode()); |
183 |
1
|
assertFalse(two.hashCode() == three.hashCode()); |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
|
|
| 81.2% |
Uncovered Elements: 3 (16) |
Complexity: 4 |
Complexity Density: 0.25 |
1
PASS
|
|
189 |
1
|
public void testGet() {... |
190 |
1
|
try { |
191 |
1
|
empty.get(0); |
192 |
0
|
fail("wrong index exception expected"); |
193 |
|
} catch (Exception e) { |
194 |
|
|
195 |
|
} |
196 |
1
|
try { |
197 |
1
|
three.get(3); |
198 |
0
|
fail("wrong index exception expected"); |
199 |
|
} catch (Exception e) { |
200 |
|
|
201 |
|
} |
202 |
1
|
try { |
203 |
1
|
two.get(-1); |
204 |
0
|
fail("wrong index exception expected"); |
205 |
|
} catch (Exception e) { |
206 |
|
|
207 |
|
} |
208 |
1
|
assertEquals(4711, one.get(0).getErrorCode()); |
209 |
1
|
assertEquals(4711, two.get(0).getErrorCode()); |
210 |
1
|
assertEquals(815, two.get(1).getErrorCode()); |
211 |
1
|
assertEquals(4711, three.get(0).getErrorCode()); |
212 |
1
|
assertEquals(815, three.get(1).getErrorCode()); |
213 |
1
|
assertEquals(17234, three.get(2).getErrorCode()); |
214 |
1
|
assertEquals(17234, three.toArray()[2].getErrorCode()); |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
220 |
1
|
public void testGetCause() {... |
221 |
1
|
assertTrue(one.getCause() instanceof SourceFileException); |
222 |
1
|
SourceFileException e = (SourceFileException) one.getCause(); |
223 |
1
|
assertEquals(4711, e.getErrorCode()); |
224 |
1
|
e = (SourceFileException) two.getCause(); |
225 |
1
|
assertEquals(4711, e.getErrorCode()); |
226 |
1
|
e = (SourceFileException) three.getCause(); |
227 |
1
|
assertEquals(4711, e.getErrorCode()); |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
233 |
1
|
public void testToString() {... |
234 |
1
|
assertEquals(three.toString(), "org.qedeq.kernel.se.common.SourceFileExceptionList\n" |
235 |
|
+ "0: \t4711: no big problem; something bad\n" |
236 |
|
+ "1: \t815: no big problem; something else\n" |
237 |
|
+ "2: \t17234: no big problem; something other"); |
238 |
|
} |
239 |
|
|
240 |
|
} |