Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
28   115   9   5.6
8   64   0.32   5
5     1.8  
1    
 
  HeuristicCheckerPluginTest       Line # 37 28 9 80.5% 0.80487806
 
  (4)
 
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    package org.qedeq.kernel.bo.service.heuristic;
16   
17    import java.io.File;
18    import java.io.IOException;
19   
20    import org.qedeq.base.io.UrlUtility;
21    import org.qedeq.kernel.bo.common.QedeqBo;
22    import org.qedeq.kernel.bo.logic.model.Model;
23    import org.qedeq.kernel.bo.logic.model.ThreeModel;
24    import org.qedeq.kernel.bo.logic.model.UnaryModel;
25    import org.qedeq.kernel.bo.module.KernelQedeqBo;
26    import org.qedeq.kernel.bo.test.KernelFacade;
27    import org.qedeq.kernel.bo.test.QedeqBoTestCase;
28    import org.qedeq.kernel.se.common.ModuleAddress;
29    import org.qedeq.kernel.se.common.SourceFileExceptionList;
30    import org.qedeq.kernel.se.visitor.InterruptException;
31   
32    /**
33    * For testing model validity.
34    *
35    * @author Michael Meyling
36    */
 
37    public class HeuristicCheckerPluginTest extends QedeqBoTestCase {
38   
39    /**
40    * Test with model.
41    */
 
42  4 toggle public QedeqBo check(final Model model, final File dir, final String xml) throws IOException,
43    SourceFileExceptionList, InterruptException {
44  4 final File xmlFile = new File(dir, xml);
45  4 final ModuleAddress address = KernelFacade.getKernelContext().getModuleAddress(
46    UrlUtility.toUrl(xmlFile));
47  4 final KernelQedeqBo prop = (KernelQedeqBo) KernelFacade.getKernelContext().loadModule(
48    address);
49  4 if (prop.hasErrors()) {
50  0 throw prop.getErrors();
51    }
52  4 KernelFacade.getKernelContext().loadRequiredModules(prop.getModuleAddress());
53  4 if (prop.hasErrors()) {
54  0 throw prop.getErrors();
55    }
56  4 KernelFacade.getKernelContext().checkWellFormedness(prop.getModuleAddress());
57  4 if (prop.hasErrors()) {
58  0 throw prop.getErrors();
59    }
60  4 getInternalServices().getConfig().setServiceKeyValue(new HeuristicCheckerPlugin(), "model",
61    model.getClass().getName());
62  4 getServices().executePlugin(
63    "org.qedeq.kernel.bo.service.heuristic.HeuristicCheckerPlugin", prop.getModuleAddress(),
64    null);
65  4 if (prop.hasErrors()) {
66  0 throw prop.getErrors();
67    }
68  4 return prop;
69    }
70   
71    /**
72    * Test logic script for heuristic errors with default model.
73    *
74    * @throws Exception
75    */
 
76  1 toggle public void testQedeqLogicScript1() throws Exception {
77  1 final QedeqBo bo = check(new ThreeModel(), getDocDir(), "math/qedeq_logic_v1.xml");
78  1 assertEquals(0, bo.getErrors().size());
79  1 assertEquals(0, bo.getWarnings().size());
80    }
81   
82    /**
83    * Test logic script for heuristic errors with zero model.
84    *
85    * @throws Exception
86    */
 
87  1 toggle public void testQedeqLogicScript2() throws Exception {
88  1 final QedeqBo bo = check(new UnaryModel(), getDocDir(), "math/qedeq_logic_v1.xml");
89  1 assertEquals(0, bo.getErrors().size());
90  1 assertEquals(0, bo.getWarnings().size());
91    }
92   
93    /**
94    * Test logic script for heuristic errors with default model.
95    *
96    * @throws Exception
97    */
 
98  1 toggle public void testQedeqSetTheoryScript1() throws Exception {
99  1 final QedeqBo bo = check(new ThreeModel(), getDocDir(), "math/qedeq_set_theory_v1.xml");
100  1 assertEquals(0, bo.getErrors().size());
101  1 assertEquals(46, bo.getWarnings().size());
102    }
103   
104    /**
105    * Test logic script for heuristic errors with zero model.
106    *
107    * @throws Exception
108    */
 
109  1 toggle public void testQedeqSetTheoryScript2() throws Exception {
110  1 final QedeqBo bo = check(new UnaryModel(), getDocDir(), "math/qedeq_set_theory_v1.xml");
111  1 assertEquals(0, bo.getErrors().size());
112  1 assertEquals(2, bo.getWarnings().size());
113    }
114   
115    }