1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.bo.service.control; |
17 |
|
|
18 |
|
import java.io.File; |
19 |
|
import java.io.IOException; |
20 |
|
|
21 |
|
import javax.xml.parsers.ParserConfigurationException; |
22 |
|
|
23 |
|
import org.qedeq.base.io.UrlUtility; |
24 |
|
import org.qedeq.base.test.DynamicGetter; |
25 |
|
import org.qedeq.base.test.ObjectProxy; |
26 |
|
import org.qedeq.base.test.QedeqTestCase; |
27 |
|
import org.qedeq.base.trace.Trace; |
28 |
|
import org.qedeq.kernel.bo.module.InternalServiceCall; |
29 |
|
import org.qedeq.kernel.bo.service.control.DefaultKernelQedeqBo; |
30 |
|
import org.qedeq.kernel.bo.service.control.ModuleLabelsCreator; |
31 |
|
import org.qedeq.kernel.bo.test.DummyPlugin; |
32 |
|
import org.qedeq.kernel.bo.test.KernelFacade; |
33 |
|
import org.qedeq.kernel.bo.test.QedeqBoTestCase; |
34 |
|
import org.qedeq.kernel.se.base.module.Author; |
35 |
|
import org.qedeq.kernel.se.base.module.Qedeq; |
36 |
|
import org.qedeq.kernel.se.common.ModuleAddress; |
37 |
|
import org.qedeq.kernel.se.common.SourceFileException; |
38 |
|
import org.qedeq.kernel.se.common.SourceFileExceptionList; |
39 |
|
import org.qedeq.kernel.xml.handler.common.SaxDefaultHandler; |
40 |
|
import org.qedeq.kernel.xml.handler.module.QedeqHandler; |
41 |
|
import org.qedeq.kernel.xml.parser.SaxParser; |
42 |
|
import org.xml.sax.SAXException; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@author |
48 |
|
|
|
|
| 80.7% |
Uncovered Elements: 17 (88) |
Complexity: 23 |
Complexity Density: 0.37 |
|
49 |
|
public class QedeqBoFactoryTest extends QedeqBoTestCase { |
50 |
|
|
51 |
|
|
52 |
|
private static final Class CLASS = QedeqBoFactoryTest.class; |
53 |
|
|
54 |
|
private Qedeq ok; |
55 |
|
|
56 |
|
private Qedeq error; |
57 |
|
|
58 |
|
private File okFile; |
59 |
|
|
60 |
|
private File errorFile; |
61 |
|
|
62 |
|
private InternalServiceCall call; |
63 |
|
|
|
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
|
64 |
6
|
protected void setUp() throws Exception {... |
65 |
6
|
super.setUp(); |
66 |
6
|
try { |
67 |
6
|
okFile = getFile("qedeq_sample1.xml"); |
68 |
6
|
errorFile = getFile("qedeq_error_sample_12.xml"); |
69 |
6
|
ok = (Qedeq) ObjectProxy.createProxy(createQedeqFromFile(okFile)); |
70 |
6
|
ok.getHeader().getAuthorList().get(0); |
71 |
6
|
assertTrue(DynamicGetter.get(ok, "getHeader().getAuthorList().get(0)") instanceof Author); |
72 |
6
|
ok = (Qedeq) ObjectProxy.createProxy(ok); |
73 |
6
|
error = (Qedeq) ObjectProxy.createProxy(createQedeqFromFile(errorFile)); |
74 |
|
} catch (Exception e) { |
75 |
0
|
e.printStackTrace(System.out); |
76 |
0
|
super.tearDown(); |
77 |
0
|
throw e; |
78 |
|
} |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
81 |
6
|
protected void tearDown() throws Exception {... |
82 |
6
|
ok = null; |
83 |
6
|
error = null; |
84 |
6
|
endServiceCall(call); |
85 |
6
|
super.tearDown(); |
86 |
|
} |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
0
|
public QedeqBoFactoryTest() {... |
89 |
0
|
super(); |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
6
|
public QedeqBoFactoryTest(final String name) {... |
93 |
6
|
super(name); |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
|
|
| 75% |
Uncovered Elements: 4 (16) |
Complexity: 2 |
Complexity Density: 0.12 |
1
PASS
|
|
99 |
1
|
public void testCreateStringQedeq1() throws Exception {... |
100 |
1
|
final String method = "testCreateStringQedeq()"; |
101 |
1
|
final ModuleAddress address = getServices().getModuleAddress( |
102 |
|
UrlUtility.toUrl(errorFile.getCanonicalFile())); |
103 |
1
|
final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) KernelFacade |
104 |
|
.getKernelContext().getQedeqBo(address); |
105 |
1
|
try { |
106 |
1
|
QedeqBoFactoryAssert.createQedeq(prop, error); |
107 |
|
|
108 |
|
|
109 |
0
|
final ModuleLabelsCreator creator = new ModuleLabelsCreator(DummyPlugin.getInstance(), prop); |
110 |
0
|
call = createServiceCall("testCreateStringQedeq1", prop); |
111 |
0
|
creator.createLabels(call.getInternalServiceProcess()); |
112 |
0
|
fail("SourceFileExceptionList expected"); |
113 |
|
} catch (SourceFileExceptionList e) { |
114 |
1
|
SourceFileException sf = e.get(0); |
115 |
1
|
assertEquals(221, sf.getSourceArea().getStartPosition().getRow()); |
116 |
1
|
assertEquals(9, sf.getSourceArea().getStartPosition().getColumn()); |
117 |
1
|
assertEquals(267, sf.getSourceArea().getEndPosition().getRow()); |
118 |
1
|
assertEquals(16, sf.getSourceArea().getEndPosition().getColumn()); |
119 |
1
|
Trace.trace(CLASS, this, method, e); |
120 |
|
} finally { |
121 |
1
|
endServiceCall(call); |
122 |
|
} |
123 |
|
|
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
@throws |
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
131 |
1
|
public void testCreateStringQedeq2() throws Exception {... |
132 |
1
|
loadQedeqAndAssertContext("project/qedeq_basic_concept.xml"); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
@throws |
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
140 |
1
|
public void testCreateStringQedeq3() throws Exception {... |
141 |
1
|
loadQedeqAndAssertContext("project/qedeq_logic_language.xml"); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
@throws |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
149 |
1
|
public void testCreateStringQedeq4() throws Exception {... |
150 |
1
|
loadQedeqAndAssertContext("sample/qedeq_sample1.xml"); |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
@throws |
157 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
1
PASS
|
|
158 |
1
|
public void testCreateStringQedeq5() throws Exception {... |
159 |
1
|
if (slow()) { |
160 |
1
|
loadQedeqAndAssertContext("math/qedeq_set_theory_v1.xml"); |
161 |
|
} |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
@throws |
168 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
1
PASS
|
|
169 |
1
|
public void testCreateStringQedeq6() throws Exception {... |
170 |
1
|
if (slow()) { |
171 |
1
|
loadQedeqAndAssertContext("math/qedeq_logic_v1.xml"); |
172 |
|
} |
173 |
|
} |
174 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
175 |
5
|
public void loadQedeqAndAssertContext(final String name) throws Exception,... |
176 |
|
ParserConfigurationException, SAXException, |
177 |
|
SourceFileExceptionList { |
178 |
5
|
loadQedeqAndAssertContext(getQedeqFile(name)); |
179 |
|
} |
180 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
181 |
16
|
public static final void loadQedeqAndAssertContext(final File file) throws Exception,... |
182 |
|
ParserConfigurationException, SAXException, |
183 |
|
SourceFileExceptionList { |
184 |
16
|
final ModuleAddress address = KernelFacade.getKernelContext().getModuleAddress( |
185 |
|
UrlUtility.toUrl(file.getCanonicalFile())); |
186 |
16
|
final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) KernelFacade |
187 |
|
.getKernelContext().getQedeqBo(address); |
188 |
16
|
QedeqBoFactoryAssert.createQedeq(prop, createQedeqFromFile(file)); |
189 |
|
} |
190 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
191 |
0
|
public static Qedeq loadQedeq(final String name) throws IOException,... |
192 |
|
ParserConfigurationException, SAXException, |
193 |
|
SourceFileExceptionList { |
194 |
0
|
return loadQedeq(getQedeqFile(name)); |
195 |
|
} |
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
197 |
1
|
public static Qedeq loadQedeq(final File file) throws ParserConfigurationException, SAXException,... |
198 |
|
SourceFileExceptionList { |
199 |
1
|
return createQedeqFromFile(file); |
200 |
|
} |
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
202 |
29
|
public static final Qedeq createQedeqFromFile(final File file)... |
203 |
|
throws ParserConfigurationException, SAXException, SourceFileExceptionList { |
204 |
29
|
SaxDefaultHandler handler = new SaxDefaultHandler(new DummyPlugin()); |
205 |
29
|
QedeqHandler simple = new QedeqHandler(handler); |
206 |
29
|
handler.setBasisDocumentHandler(simple); |
207 |
29
|
SaxParser parser = new SaxParser(DummyPlugin.getInstance(), handler); |
208 |
29
|
parser.parse(file, null); |
209 |
29
|
return simple.getQedeq(); |
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
@param |
216 |
|
|
217 |
|
@return |
218 |
|
@throws |
219 |
|
|
|
|
| 73.3% |
Uncovered Elements: 4 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
220 |
6
|
public static File getQedeqFile(final String relativePath) throws IOException {... |
221 |
6
|
File docDir = new File("../QedeqDoc"); |
222 |
|
|
223 |
|
|
224 |
|
|
225 |
6
|
if (!docDir.exists()) { |
226 |
6
|
docDir = new File("../doc"); |
227 |
6
|
if (!docDir.exists()) { |
228 |
6
|
docDir = (new QedeqTestCase(){ }).getFile("doc"); |
229 |
6
|
if (!docDir.exists()) { |
230 |
0
|
throw new IOException("unknown source directory for QEDEQ modules"); |
231 |
|
} |
232 |
|
} |
233 |
|
} |
234 |
6
|
final File qedeqFile = new File(docDir, relativePath); |
235 |
6
|
return qedeqFile; |
236 |
|
} |
237 |
|
|
238 |
|
} |