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