Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
27   110   10   4.5
8   63   0.37   6
6     1.67  
1    
 
  DynamicHeuristicCheckerPluginTest       Line # 35 27 10 56.1% 0.5609756
 
  (1)
 
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.SixDynamicModel;
24    import org.qedeq.kernel.bo.module.KernelQedeqBo;
25    import org.qedeq.kernel.bo.test.QedeqBoTestCase;
26    import org.qedeq.kernel.se.common.ModuleAddress;
27    import org.qedeq.kernel.se.common.SourceFileExceptionList;
28    import org.qedeq.kernel.se.visitor.InterruptException;
29   
30    /**
31    * For testing model validity.
32    *
33    * @author Michael Meyling
34    */
 
35    public class DynamicHeuristicCheckerPluginTest extends QedeqBoTestCase {
36   
 
37  0 toggle public DynamicHeuristicCheckerPluginTest() {
38  0 super();
39    }
40   
 
41  1 toggle public DynamicHeuristicCheckerPluginTest(final String name) {
42  1 super(name);
43    }
44   
45    /**
46    * Call the model check for a module.
47    */
 
48  1 toggle public QedeqBo check(final Model model, final File dir, final String xml) throws IOException,
49    SourceFileExceptionList, InterruptException {
50  1 final File xmlFile = new File(dir, xml);
51  1 final ModuleAddress address = getServices().getModuleAddress(
52    UrlUtility.toUrl(xmlFile));
53  1 final KernelQedeqBo prop = (KernelQedeqBo) getServices().loadModule(
54    address);
55  1 if (prop.hasErrors()) {
56  0 throw prop.getErrors();
57    }
58  1 getServices().loadRequiredModules(prop.getModuleAddress());
59  1 if (prop.hasErrors()) {
60  0 throw prop.getErrors();
61    }
62  1 getServices().checkWellFormedness(prop.getModuleAddress());
63  1 if (prop.hasErrors()) {
64  0 throw prop.getErrors();
65    }
66  1 getInternalServices().getConfig().setServiceKeyValue(new HeuristicCheckerPlugin(), "model",
67    model.getClass().getName());
68  1 getServices().executePlugin(
69    "org.qedeq.kernel.bo.service.heuristic.DynamicHeuristicCheckerPlugin",
70    prop.getModuleAddress(), null);
71  1 if (prop.hasErrors()) {
72  0 throw prop.getErrors();
73    }
74  1 return prop;
75    }
76   
77    /**
78    * Test sample script for heuristic errors with default model.
79    *
80    * @throws Exception
81    */
 
82  1 toggle public void testQedeqSampleScript1() throws Exception {
83  1 final QedeqBo bo = check(new SixDynamicModel(), getDocDir(), "sample/qedeq_sample1.xml");
84  1 assertEquals(0, bo.getErrors().size());
85  1 assertEquals(0, bo.getWarnings().size());
86    }
87   
88    /**
89    * Test logic script for heuristic errors with default model.
90    *
91    * @throws Exception
92    */
 
93  0 toggle public void kestQedeqLogicScript2() throws Exception {
94  0 final QedeqBo bo = check(new SixDynamicModel(), getDocDir(), "math/qedeq_logic_v1.xml");
95  0 assertEquals(0, bo.getErrors().size());
96  0 assertEquals(0, bo.getWarnings().size());
97    }
98   
99    /**
100    * Test set theory script for heuristic errors with default model.
101    *
102    * @throws Exception
103    */
 
104  0 toggle public void kestQedeqSetTheoryScript1() throws Exception {
105  0 final QedeqBo bo = check(new SixDynamicModel(), getDocDir(), "math/qedeq_set_theory_v1.xml");
106  0 assertEquals(0, bo.getErrors().size());
107  0 assertEquals(52, bo.getWarnings().size());
108    }
109   
110    }