Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
93   412   78   1.29
6   308   0.84   72
72     1.08  
1    
 
  VisitorContextTest       Line # 76 93 78 89.5% 0.8947368
 
  (1)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.module;
17   
18    import java.io.File;
19    import java.lang.reflect.InvocationTargetException;
20   
21    import org.qedeq.base.io.SourceArea;
22    import org.qedeq.base.test.DynamicGetter;
23    import org.qedeq.base.test.QedeqTestCase;
24    import org.qedeq.base.trace.Trace;
25    import org.qedeq.kernel.base.list.Atom;
26    import org.qedeq.kernel.base.list.ElementList;
27    import org.qedeq.kernel.base.module.Author;
28    import org.qedeq.kernel.base.module.AuthorList;
29    import org.qedeq.kernel.base.module.Axiom;
30    import org.qedeq.kernel.base.module.Chapter;
31    import org.qedeq.kernel.base.module.ChapterList;
32    import org.qedeq.kernel.base.module.Formula;
33    import org.qedeq.kernel.base.module.FunctionDefinition;
34    import org.qedeq.kernel.base.module.Header;
35    import org.qedeq.kernel.base.module.Import;
36    import org.qedeq.kernel.base.module.ImportList;
37    import org.qedeq.kernel.base.module.Latex;
38    import org.qedeq.kernel.base.module.LatexList;
39    import org.qedeq.kernel.base.module.LinkList;
40    import org.qedeq.kernel.base.module.LiteratureItem;
41    import org.qedeq.kernel.base.module.LiteratureItemList;
42    import org.qedeq.kernel.base.module.Location;
43    import org.qedeq.kernel.base.module.LocationList;
44    import org.qedeq.kernel.base.module.Node;
45    import org.qedeq.kernel.base.module.PredicateDefinition;
46    import org.qedeq.kernel.base.module.Proof;
47    import org.qedeq.kernel.base.module.ProofList;
48    import org.qedeq.kernel.base.module.Proposition;
49    import org.qedeq.kernel.base.module.Qedeq;
50    import org.qedeq.kernel.base.module.Rule;
51    import org.qedeq.kernel.base.module.Section;
52    import org.qedeq.kernel.base.module.SectionList;
53    import org.qedeq.kernel.base.module.Specification;
54    import org.qedeq.kernel.base.module.Subsection;
55    import org.qedeq.kernel.base.module.SubsectionList;
56    import org.qedeq.kernel.base.module.SubsectionType;
57    import org.qedeq.kernel.base.module.Term;
58    import org.qedeq.kernel.base.module.UsedByList;
59    import org.qedeq.kernel.base.module.VariableList;
60    import org.qedeq.kernel.bo.service.QedeqBoFactoryTest;
61    import org.qedeq.kernel.common.DefaultModuleAddress;
62    import org.qedeq.kernel.common.ModuleAddress;
63    import org.qedeq.kernel.common.ModuleDataException;
64    import org.qedeq.kernel.visitor.QedeqNotNullTraverser;
65    import org.qedeq.kernel.visitor.QedeqVisitor;
66    import org.qedeq.kernel.xml.mapper.Context2SimpleXPath;
67    import org.qedeq.kernel.xml.tracker.SimpleXPath;
68    import org.qedeq.kernel.xml.tracker.XPathLocationParser;
69   
70   
71    /**
72    * Test context of {@link QedeqNotNullTraverser}.
73    *
74    * @author Michael Meyling
75    */
 
76    public class VisitorContextTest extends QedeqTestCase implements QedeqVisitor {
77   
78    /** This class. */
79    private static final Class CLASS = VisitorContextTest.class;
80   
81    /** Traverse QEDEQ module with this traverser. */
82    private QedeqNotNullTraverser traverser;
83   
84    private Qedeq qedeq;
85   
86    private File moduleFile;
87   
 
88  1 toggle public void testContext() throws Exception {
89  1 moduleFile = QedeqBoFactoryTest.getQedeqFile("math/qedeq_set_theory_v1.xml");
90  1 final ModuleAddress globalContext = new DefaultModuleAddress(moduleFile);
91  1 qedeq = QedeqBoFactoryTest.loadQedeq(moduleFile);
92  1 traverser = new QedeqNotNullTraverser(globalContext, this);
93  1 traverser.accept(qedeq);
94    }
95   
 
96  1224 toggle public void visitEnter(final Atom atom) throws ModuleDataException {
97  1224 checkContext();
98    }
99   
 
100  1471 toggle public void visitEnter(final ElementList list) throws ModuleDataException {
101  1471 checkContext();
102    }
103   
 
104  1 toggle public void visitEnter(final Author author) throws ModuleDataException {
105  1 checkContext();
106    }
107   
 
108  1 toggle public void visitEnter(final AuthorList authorList) throws ModuleDataException {
109  1 checkContext();
110    }
111   
 
112  12 toggle public void visitEnter(final Axiom axiom) throws ModuleDataException {
113  12 checkContext();
114    }
115   
 
116  8 toggle public void visitEnter(final Chapter chapter) throws ModuleDataException {
117  8 checkContext();
118    }
119   
 
120  1 toggle public void visitEnter(final ChapterList chapterList) throws ModuleDataException {
121  1 checkContext();
122    }
123   
 
124  72 toggle public void visitEnter(final Formula formula) throws ModuleDataException {
125  72 checkContext();
126    }
127   
 
128  16 toggle public void visitEnter(final FunctionDefinition functionDefinition) throws ModuleDataException {
129  16 checkContext();
130    }
131   
 
132  1 toggle public void visitEnter(final Header header) throws ModuleDataException {
133  1 checkContext();
134    }
135   
 
136  1 toggle public void visitEnter(final Import imp) throws ModuleDataException {
137  1 checkContext();
138    }
139   
 
140  1 toggle public void visitEnter(final ImportList importList) throws ModuleDataException {
141  1 checkContext();
142    }
143   
 
144  522 toggle public void visitEnter(final Latex latex) throws ModuleDataException {
145  522 checkContext();
146    }
147   
 
148  267 toggle public void visitEnter(final LatexList latexList) throws ModuleDataException {
149  267 checkContext();
150    }
151   
 
152  1 toggle public void visitEnter(final LinkList linkList) throws ModuleDataException {
153  1 checkContext();
154    }
155   
 
156  3 toggle public void visitEnter(final LiteratureItem literatureItem) throws ModuleDataException {
157  3 checkContext();
158    }
159   
 
160  1 toggle public void visitEnter(final LiteratureItemList literatureItemList) throws ModuleDataException {
161  1 checkContext();
162    }
163   
 
164  3 toggle public void visitEnter(final Location location) throws ModuleDataException {
165  3 checkContext();
166    }
167   
 
168  2 toggle public void visitEnter(final LocationList locationList) throws ModuleDataException {
169  2 checkContext();
170    }
171   
 
172  90 toggle public void visitEnter(final Node authorList) throws ModuleDataException {
173  90 checkContext();
174    }
175   
 
176  7 toggle public void visitEnter(final PredicateDefinition predicateDefinition)
177    throws ModuleDataException {
178  7 checkContext();
179    }
180   
 
181  18 toggle public void visitEnter(final Proof proof) throws ModuleDataException {
182  18 checkContext();
183    }
184   
 
185  17 toggle public void visitEnter(final ProofList proofList) throws ModuleDataException {
186  17 checkContext();
187    }
188   
 
189  54 toggle public void visitEnter(final Proposition proposition) throws ModuleDataException {
190  54 checkContext();
191    }
192   
 
193  1 toggle public void visitEnter(final Qedeq qedeq) throws ModuleDataException {
194  1 checkContext();
195    }
196   
 
197  1 toggle public void visitEnter(final Rule rule) throws ModuleDataException {
198  1 checkContext();
199    }
200   
 
201  22 toggle public void visitEnter(final Section section) throws ModuleDataException {
202  22 checkContext();
203    }
204   
 
205  5 toggle public void visitEnter(final SectionList sectionList) throws ModuleDataException {
206  5 checkContext();
207    }
208   
 
209  2 toggle public void visitEnter(final Specification specification) throws ModuleDataException {
210  2 checkContext();
211    }
212   
 
213  1 toggle public void visitEnter(final Subsection subsection) throws ModuleDataException {
214  1 checkContext();
215    }
216   
 
217  14 toggle public void visitEnter(final SubsectionList subsectionList) throws ModuleDataException {
218  14 checkContext();
219    }
220   
 
221  0 toggle public void visitEnter(final SubsectionType subsectionType) throws ModuleDataException {
222  0 checkContext();
223    }
224   
 
225  16 toggle public void visitEnter(final Term term) throws ModuleDataException {
226  16 checkContext();
227    }
228   
 
229  0 toggle public void visitEnter(final UsedByList usedByList) throws ModuleDataException {
230  0 checkContext();
231    }
232   
 
233  20 toggle public void visitEnter(final VariableList variableList) throws ModuleDataException {
234  20 checkContext();
235    }
236   
 
237  1 toggle public void visitLeave(final Author author) throws ModuleDataException {
238  1 checkContext();
239    }
240   
 
241  1 toggle public void visitLeave(final AuthorList authorList) throws ModuleDataException {
242  1 checkContext();
243    }
244   
 
245  12 toggle public void visitLeave(final Axiom axiom) throws ModuleDataException {
246  12 checkContext();
247    }
248   
 
249  8 toggle public void visitLeave(final Chapter chapter) throws ModuleDataException {
250  8 checkContext();
251    }
252   
 
253  1 toggle public void visitLeave(final ChapterList chapterList) throws ModuleDataException {
254  1 checkContext();
255    }
256   
 
257  72 toggle public void visitLeave(final Formula formula) throws ModuleDataException {
258  72 checkContext();
259    }
260   
 
261  16 toggle public void visitLeave(final FunctionDefinition functionDefinition) throws ModuleDataException {
262  16 checkContext();
263    }
264   
 
265  1 toggle public void visitLeave(final Header header) throws ModuleDataException {
266  1 checkContext();
267    }
268   
 
269  1 toggle public void visitLeave(final Import imp) throws ModuleDataException {
270  1 checkContext();
271    }
272   
 
273  1 toggle public void visitLeave(final ImportList importList) throws ModuleDataException {
274  1 checkContext();
275    }
276   
 
277  522 toggle public void visitLeave(final Latex latex) throws ModuleDataException {
278  522 checkContext();
279    }
280   
 
281  267 toggle public void visitLeave(final LatexList latexList) throws ModuleDataException {
282  267 checkContext();
283    }
284   
 
285  1 toggle public void visitLeave(final LinkList linkList) throws ModuleDataException {
286  1 checkContext();
287    }
288   
 
289  3 toggle public void visitLeave(final LiteratureItem literatureItem) throws ModuleDataException {
290  3 checkContext();
291    }
292   
 
293  1 toggle public void visitLeave(final LiteratureItemList literatureItemList) throws ModuleDataException {
294  1 checkContext();
295    }
296   
 
297  3 toggle public void visitLeave(final Location location) throws ModuleDataException {
298  3 checkContext();
299    }
300   
 
301  2 toggle public void visitLeave(final LocationList locationList) throws ModuleDataException {
302  2 checkContext();
303    }
304   
 
305  90 toggle public void visitLeave(final Node authorList) throws ModuleDataException {
306  90 checkContext();
307    }
308   
 
309  7 toggle public void visitLeave(final PredicateDefinition predicateDefinition)
310    throws ModuleDataException {
311  7 checkContext();
312    }
313   
 
314  18 toggle public void visitLeave(final Proof proof) throws ModuleDataException {
315  18 checkContext();
316    }
317   
 
318  17 toggle public void visitLeave(final ProofList proofList) throws ModuleDataException {
319  17 checkContext();
320    }
321   
 
322  54 toggle public void visitLeave(final Proposition proposition) throws ModuleDataException {
323  54 checkContext();
324    }
325   
 
326  1 toggle public void visitLeave(final Qedeq qedeq) throws ModuleDataException {
327  1 checkContext();
328    }
329   
 
330  1 toggle public void visitLeave(final Rule rule) throws ModuleDataException {
331  1 checkContext();
332    }
333   
 
334  22 toggle public void visitLeave(final Section section) throws ModuleDataException {
335  22 checkContext();
336    }
337   
 
338  5 toggle public void visitLeave(final SectionList sectionList) throws ModuleDataException {
339  5 checkContext();
340    }
341   
 
342  2 toggle public void visitLeave(final Specification specification) throws ModuleDataException {
343  2 checkContext();
344    }
345   
 
346  1 toggle public void visitLeave(final Subsection subsection) throws ModuleDataException {
347  1 checkContext();
348    }
349   
 
350  14 toggle public void visitLeave(final SubsectionList subsectionList) throws ModuleDataException {
351  14 checkContext();
352    }
353   
 
354  0 toggle public void visitLeave(final SubsectionType subsectionType) throws ModuleDataException {
355  0 checkContext();
356    }
357   
 
358  16 toggle public void visitLeave(final Term term) throws ModuleDataException {
359  16 checkContext();
360    }
361   
 
362  0 toggle public void visitLeave(final UsedByList usedByList) throws ModuleDataException {
363  0 checkContext();
364    }
365   
 
366  20 toggle public void visitLeave(final VariableList variableList) throws ModuleDataException {
367  20 checkContext();
368    }
369   
 
370  1224 toggle public void visitLeave(final Atom atom) throws ModuleDataException {
371  1224 checkContext();
372    }
373   
 
374  1471 toggle public void visitLeave(final ElementList list) throws ModuleDataException {
375  1471 checkContext();
376    }
377   
 
378  7752 toggle private void checkContext() throws ModuleDataException {
379  7752 final String context = traverser.getCurrentContext().getLocationWithinModule();
380  7752 try {
381  7752 Trace.param(CLASS, "checkContext()",
382    "context > ", context);
383  7752 if (context.length() > 0) {
384  7750 DynamicGetter.get(qedeq, context);
385    }
386    } catch (RuntimeException e) {
387  0 System.err.println(context);
388  0 throw e;
389    } catch (IllegalAccessException e) {
390  0 throw new RuntimeException(e);
391    } catch (InvocationTargetException e) {
392  0 throw new RuntimeException(e);
393    }
394   
395  7752 SimpleXPath xpath = Context2SimpleXPath.getXPath(traverser.getCurrentContext(), qedeq);
396  7752 Trace.param(CLASS, "checkContext()",
397    "xpath < ", xpath);
398  7752 final SourceArea find = XPathLocationParser.findSourceArea(moduleFile,
399    xpath);
400  7752 if (find.getStartPosition() == null) {
401  0 System.out.println(traverser.getCurrentContext());
402  0 throw new RuntimeException("start not found: " + find + "\ncontext: "
403    + context);
404    }
405  7752 if (find.getEndPosition() == null) {
406  0 System.out.println(traverser.getCurrentContext());
407  0 throw new RuntimeException("end not found: " + find + "\ncontext: "
408    + context);
409    }
410    }
411   
412    }