Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
33   108   12   3
0   71   0.36   11
11     1.09  
1    
 
  Context2SimpleXPathTest       Line # 30 33 12 97.7% 0.97727275
 
  (9)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, 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.xml.mapper;
17   
18    import org.qedeq.kernel.bo.module.KernelQedeqBo;
19    import org.qedeq.kernel.bo.test.QedeqBoTestCase;
20    import org.qedeq.kernel.se.common.DefaultModuleAddress;
21    import org.qedeq.kernel.se.common.ModuleAddress;
22    import org.qedeq.kernel.se.common.ModuleContext;
23    import org.qedeq.kernel.se.common.ModuleDataException;
24   
25    /**
26    * Test {@link org.qedeq.kernel.xml.mapper.Context2XPath}.
27    *
28    * @author Michael Meyling
29    */
 
30    public class Context2SimpleXPathTest extends QedeqBoTestCase {
31   
32    private KernelQedeqBo qedeq;
33   
 
34  9 toggle protected void setUp() throws Exception {
35  9 super.setUp();
36  9 final ModuleAddress address = new DefaultModuleAddress(getFile("mapper/Context2SimpleXPath001.xml"));
37  9 getServices().loadModule(address);
38  9 qedeq = getInternalServices().getKernelQedeqBo(address);
39  9 assertEquals(0, qedeq.getErrors().size());
40    }
41   
 
42  9 toggle protected void tearDown() throws Exception {
43  9 super.tearDown();
44    }
45   
 
46  1 toggle public void testGetXPath01() throws ModuleDataException {
47  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress());
48  1 assertEquals("/QEDEQ", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString());
49    }
50   
 
51  1 toggle public void testGetXPath02() throws ModuleDataException {
52  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0)");
53  1 assertEquals("/QEDEQ/CHAPTER", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString());
54    }
55   
 
56  1 toggle public void testGetXPath03() throws ModuleDataException {
57  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getHeader()");
58  1 assertEquals("/QEDEQ/HEADER", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString());
59    }
60   
 
61  1 toggle public void testGetXPath04() throws ModuleDataException {
62  1 assertNotNull(qedeq.getQedeq().getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode());
63  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode()");
64  1 assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString());
65    }
66   
 
67  1 toggle public void testGetXPath05() throws ModuleDataException {
68  1 assertNotNull(qedeq.getQedeq().getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2));
69  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2)");
70  1 assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString());
71    }
72   
 
73  1 toggle public void testGetXPath06() throws ModuleDataException {
74  1 assertNotNull(qedeq.getQedeq().getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode().getNodeType().getPredicateDefinition().getFormula().getElement().getList());
75  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode().getNodeType().getPredicateDefinition().getFormula().getElement().getList()");
76  1 assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]/DEFINITION_PREDICATE/FORMULA/EQUI", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString());
77    }
78   
 
79  1 toggle public void testGetXPath07() throws ModuleDataException {
80  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode().getNodeType().getPredicateDefinition().getFormula().getElement().getList().getElement(0).getList()");
81  1 assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]/DEFINITION_PREDICATE/FORMULA/EQUI/PREDCON", Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString());
82    }
83   
 
84  1 toggle public void testGetXPath08() {
85  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(99).getNode().getNodeType()");
86  1 try {
87  1 Context2SimpleXPath.getXPath(find, qedeq.getQedeq());
88  0 fail("ModuleDataException expected");
89    } catch (ModuleDataException e) {
90    // expected
91    }
92    }
93   
 
94  1 toggle public void testGetXPath09() throws ModuleDataException {
95  1 final ModuleContext find = new ModuleContext(qedeq.getModuleAddress(), "getChapterList().get(0).getSectionList().get(0).getSubsectionList().get(2).getNode().getNodeType().getUnknown()");
96  1 final boolean locationFailures = "true".equalsIgnoreCase(
97    System.getProperty("qedeq.test.xmlLocationFailures", "false"));
98  1 System.setProperty("qedeq.test.xmlLocationFailures", "false");
99  1 try {
100  1 assertEquals("/QEDEQ/CHAPTER/SECTION/SUBSECTIONS/NODE[3]",
101    Context2SimpleXPath.getXPath(find, qedeq.getQedeq()).toString());
102    } finally {
103  1 System.setProperty("qedeq.test.xmlLocationFailures", Boolean.toString(locationFailures));
104    }
105    }
106   
107   
108    }