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