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.io.SourcePosition; |
20 |
|
import org.qedeq.base.test.QedeqTestCase; |
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
@author |
26 |
|
|
|
|
| 91.6% |
Uncovered Elements: 9 (107) |
Complexity: 18 |
Complexity Density: 0.2 |
|
27 |
|
public class SourceFileExceptionTest extends QedeqTestCase { |
28 |
|
|
29 |
|
private SourceFileException one; |
30 |
|
private SourceFileException two; |
31 |
|
private SourceFileException three; |
32 |
|
private SourceFileException four; |
33 |
|
private SourceFileException five; |
34 |
|
private SourceFileException six; |
35 |
|
private SourceFileException seven; |
36 |
|
|
37 |
|
private final Plugin plugin = new Plugin(){ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
38 |
0
|
public String getServiceDescription() {... |
39 |
0
|
return "i am doing nothing"; |
40 |
|
} |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
0
|
public String getServiceId() {... |
43 |
0
|
return this.getClass().toString(); |
44 |
|
} |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
0
|
public String getServiceAction() {... |
47 |
0
|
return "dummy"; |
48 |
|
} |
49 |
|
}; |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
0
|
public SourceFileExceptionTest(){... |
52 |
0
|
super(); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
10
|
public SourceFileExceptionTest(final String name){... |
56 |
10
|
super(name); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
59 |
10
|
protected void setUp() throws Exception {... |
60 |
10
|
super.setUp(); |
61 |
10
|
one = new SourceFileException(plugin, 4711, |
62 |
|
"no big problem", new RuntimeException("something bad"), (SourceArea) null, |
63 |
|
(SourceArea) null); |
64 |
10
|
two = new SourceFileException(plugin, 815, |
65 |
|
"no big problem", new RuntimeException("something else"), new SourceArea("test"), |
66 |
|
new SourceArea("toast")); |
67 |
10
|
three = new SourceFileException(plugin, 17234, |
68 |
|
"no big problem", new RuntimeException("something other"), |
69 |
|
new SourceArea("test", new SourcePosition(1, 2), new SourcePosition(3, 17)), |
70 |
|
new SourceArea("toast", new SourcePosition(13, 7), new SourcePosition(14, 19))); |
71 |
10
|
four = new SourceFileException(plugin, 17234, |
72 |
|
"no big problem", null, |
73 |
|
new SourceArea("test", new SourcePosition(1, 2), new SourcePosition(3, 17)), |
74 |
|
new SourceArea("toast", new SourcePosition(13, 7), new SourcePosition(14, 19))); |
75 |
10
|
five = new SourceFileException(plugin, 17234, |
76 |
|
"one big problem", null, |
77 |
|
new SourceArea("test", SourcePosition.BEGIN, new SourcePosition(3, 17)), |
78 |
|
new SourceArea("toast", new SourcePosition(13, 7), SourcePosition.BEGIN)); |
79 |
10
|
six = new SourceFileException(plugin, |
80 |
|
new IllegalModuleDataException(107, "I am a bug!", new ModuleContext( |
81 |
|
new DefaultModuleAddress()), new ModuleContext(new DefaultModuleAddress(true, "bee")), |
82 |
|
new RuntimeException("I am the next reason.")), null, null); |
83 |
10
|
seven = new SourceFileException(null, 17234, |
84 |
|
"no big problem", new RuntimeException("no big problem"), |
85 |
|
new SourceArea("test", new SourcePosition(1, 2), new SourcePosition(3, 17)), |
86 |
|
new SourceArea("toast", new SourcePosition(13, 7), new SourcePosition(14, 19))); |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
89 |
10
|
protected void tearDown() throws Exception {... |
90 |
10
|
one = null; |
91 |
10
|
two = null; |
92 |
10
|
three = null; |
93 |
10
|
four = null; |
94 |
10
|
five = null; |
95 |
10
|
six = null; |
96 |
10
|
seven = null; |
97 |
10
|
super.tearDown(); |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 2 |
Complexity Density: 0.22 |
1
PASS
|
|
103 |
1
|
public void testConstructor() {... |
104 |
1
|
assertEquals("no big problem; something bad", one.getMessage()); |
105 |
1
|
assertEquals(4711, one.getErrorCode()); |
106 |
1
|
assertNull(four.getCause()); |
107 |
1
|
assertEquals(1, three.getSourceArea().getStartPosition().getRow()); |
108 |
1
|
assertEquals(19, three.getReferenceArea().getEndPosition().getColumn()); |
109 |
1
|
try { |
110 |
1
|
new SourceFileException(null, null, null, null); |
111 |
0
|
fail("Exception expected"); |
112 |
|
} catch (Exception e) { |
113 |
|
|
114 |
|
} |
115 |
1
|
assertEquals(107, six.getErrorCode()); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
118 |
1
|
public void testGetMessage() {... |
119 |
1
|
assertEquals("no big problem; something else", two.getMessage()); |
120 |
1
|
assertEquals("no big problem", four.getMessage()); |
121 |
1
|
assertEquals("no big problem", seven.getMessage()); |
122 |
|
} |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
124 |
1
|
public void testGetCause() {... |
125 |
1
|
assertEquals("something bad", one.getCause().getMessage()); |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
128 |
1
|
public void testToString() {... |
129 |
1
|
assertEquals("\t4711: no big problem; something bad", one.toString()); |
130 |
1
|
assertEquals("test:1:2:3:17\n\t17234: no big problem; something other", three.toString()); |
131 |
|
} |
132 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
133 |
1
|
public void testGetDescription() {... |
134 |
1
|
assertEquals("\t4711: no big problem; something bad", one.getDescription()); |
135 |
1
|
assertEquals("test:1:2:3:17\n\t17234: no big problem; something other", three.getDescription()); |
136 |
1
|
assertEquals("test:1:2:3:17\n\t17234: no big problem", four.getDescription()); |
137 |
|
} |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
139 |
1
|
public void testGetPlugin() {... |
140 |
1
|
assertEquals(plugin, one.getService()); |
141 |
1
|
assertNull(seven.getService()); |
142 |
|
} |
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
144 |
1
|
public void testGetSourceArea() {... |
145 |
1
|
assertEquals(null, one.getSourceArea()); |
146 |
1
|
assertEquals(new SourceArea("test"), two.getSourceArea()); |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
149 |
1
|
public void testGetRefrenceArea() {... |
150 |
1
|
assertEquals(null, one.getReferenceArea()); |
151 |
1
|
assertEquals(new SourceArea("toast"), two.getReferenceArea()); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.04 |
1
PASS
|
|
157 |
1
|
public void testHashCode() {... |
158 |
1
|
assertFalse(one.hashCode() == two.hashCode()); |
159 |
1
|
assertFalse(three.hashCode() == two.hashCode()); |
160 |
1
|
assertFalse(three.hashCode() == four.hashCode()); |
161 |
1
|
assertFalse(five.hashCode() == four.hashCode()); |
162 |
1
|
assertFalse(six.hashCode() == five.hashCode()); |
163 |
1
|
assertFalse(six.hashCode() == seven.hashCode()); |
164 |
1
|
assertFalse(one.hashCode() == three.hashCode()); |
165 |
1
|
assertFalse(one.hashCode() == four.hashCode()); |
166 |
1
|
assertFalse(one.hashCode() == five.hashCode()); |
167 |
1
|
assertFalse(one.hashCode() == six.hashCode()); |
168 |
1
|
assertFalse(one.hashCode() == seven.hashCode()); |
169 |
1
|
assertFalse(two.hashCode() == four.hashCode()); |
170 |
1
|
assertFalse(two.hashCode() == five.hashCode()); |
171 |
1
|
assertFalse(two.hashCode() == six.hashCode()); |
172 |
1
|
assertFalse(two.hashCode() == seven.hashCode()); |
173 |
1
|
assertFalse(three.hashCode() == five.hashCode()); |
174 |
1
|
assertFalse(three.hashCode() == six.hashCode()); |
175 |
1
|
assertFalse(three.hashCode() == seven.hashCode()); |
176 |
1
|
assertFalse(four.hashCode() == five.hashCode()); |
177 |
1
|
assertFalse(four.hashCode() == six.hashCode()); |
178 |
1
|
assertFalse(four.hashCode() == seven.hashCode()); |
179 |
1
|
assertFalse(five.hashCode() == six.hashCode()); |
180 |
1
|
assertFalse(five.hashCode() == seven.hashCode()); |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1
PASS
|
|
186 |
1
|
public void testEqualsObject() {... |
187 |
1
|
assertEquals(one, one); |
188 |
1
|
assertEquals(two, two); |
189 |
1
|
assertEquals(three, three); |
190 |
1
|
assertEquals(four, four); |
191 |
1
|
assertEquals(five, five); |
192 |
1
|
assertFalse(one.equals(null)); |
193 |
1
|
assertFalse(one.equals(one.toString())); |
194 |
1
|
assertFalse(one.equals(two)); |
195 |
1
|
assertFalse(one.equals(three)); |
196 |
1
|
assertFalse(one.equals(four)); |
197 |
1
|
assertFalse(one.equals(five)); |
198 |
1
|
assertFalse(two.equals(null)); |
199 |
1
|
assertFalse(two.equals(two.toString())); |
200 |
1
|
assertFalse(two.equals(one)); |
201 |
1
|
assertFalse(two.equals(three)); |
202 |
1
|
assertFalse(two.equals(four)); |
203 |
1
|
assertFalse(two.equals(five)); |
204 |
1
|
assertFalse(three.equals(null)); |
205 |
1
|
assertFalse(three.equals(one)); |
206 |
1
|
assertFalse(three.equals(two)); |
207 |
1
|
assertFalse(three.equals(four)); |
208 |
1
|
assertFalse(three.equals(five)); |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
} |