Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
36   138   17   3.27
6   89   0.47   11
11     1.55  
1    
 
  QedeqBoTestCase       Line # 39 36 17 83% 0.8301887
 
  (96)
 
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.bo.test;
17   
18    import java.io.File;
19    import java.io.IOException;
20   
21    import org.qedeq.base.io.Parameters;
22    import org.qedeq.base.test.QedeqTestCase;
23    import org.qedeq.base.trace.Trace;
24    import org.qedeq.base.utility.YodaUtility;
25    import org.qedeq.kernel.bo.KernelContext;
26    import org.qedeq.kernel.bo.common.KernelServices;
27    import org.qedeq.kernel.bo.module.InternalKernelServices;
28    import org.qedeq.kernel.bo.module.InternalServiceCall;
29    import org.qedeq.kernel.bo.module.InternalServiceProcess;
30    import org.qedeq.kernel.bo.module.KernelQedeqBo;
31    import org.qedeq.kernel.bo.service.control.ServiceProcessManager;
32    import org.qedeq.kernel.se.visitor.InterruptException;
33   
34    /**
35    * Test generating LaTeX files for all known samples.
36    *
37    * @author Michael Meyling
38    */
 
39    public abstract class QedeqBoTestCase extends QedeqTestCase {
40   
41    /** Here should the result get into. */
42    private File genDir;
43   
44    /** Here are the documents within. */
45    private File docDir;
46   
 
47  600 toggle public QedeqBoTestCase() {
48  600 super();
49    }
50   
 
51  73 toggle public QedeqBoTestCase(final String name) {
52  73 super(name);
53    }
54   
 
55  471 toggle protected void setUp() throws Exception {
56  471 super.setUp();
57  471 docDir = new File("../QedeqDoc");
58  471 genDir = new File("../../../qedeq_gen");
59    // test if we are in the normal development environment, where a project with name
60    // "../QedeqDoc" exists, otherwise we assume to run within the release directory
61    // structure where the docs are in the directory ../doc
62  471 if (!docDir.exists()) {
63  471 docDir = getFile("doc");
64    // or are we testing automatically?
65  471 if (!docDir.exists()) {
66  0 throw new IOException("unknown source directory for QEDEQ modules");
67    }
68  471 genDir = new File(getOutdir(), "doc");
69    }
70  471 KernelFacade.startup();
71  471 Trace.setTraceOn(false); // disable trace because it leads to java heap space errors
72    }
73   
 
74  483 toggle protected void tearDown() throws Exception {
75  483 super.tearDown();
76  483 KernelFacade.shutdown();
77    }
78   
 
79  47 toggle public File getGenDir() {
80  47 return genDir;
81    }
82   
 
83  194 toggle public File getDocDir() {
84  194 return docDir;
85    }
86   
87    /**
88    * Get test input data file. Get file relative to {@link #getDocDir()}.
89    *
90    * @param fileName Relative file path.
91    * @return Test data file.
92    */
 
93  7 toggle public File getDocFile(final String fileName) {
94  7 return new File(getDocDir(), fileName);
95    }
96   
 
97  558 toggle public InternalKernelServices getInternalServices() {
98  558 final KernelContext c = KernelFacade.getKernelContext();
99  558 try {
100  558 return (InternalKernelServices) YodaUtility.getFieldValue(c, "services");
101    } catch (NoSuchFieldException e) {
102  0 e.printStackTrace();
103  0 throw new RuntimeException(e);
104    }
105    }
106   
 
107  1014 toggle public KernelServices getServices() {
108  1014 final KernelContext c = KernelFacade.getKernelContext();
109  1014 try {
110  1014 return (KernelServices) YodaUtility.getFieldValue(c, "services");
111    } catch (NoSuchFieldException e) {
112  0 e.printStackTrace();
113  0 throw new RuntimeException(e);
114    }
115    }
116   
 
117  70 toggle public InternalServiceCall createServiceCall(final String name, final KernelQedeqBo prop)
118    throws InterruptException {
119  70 InternalServiceProcess process = getInternalServices().createServiceProcess(name);
120  70 InternalServiceCall call = getInternalServices().createServiceCall(DummyPlugin.getInstance(), prop,
121    Parameters.EMPTY, Parameters.EMPTY, process, null);
122  70 return call;
123    }
124   
 
125  108 toggle public void endServiceCall(final InternalServiceCall call) {
126  108 if (call == null) {
127  23 return;
128    }
129  85 try {
130  85 ((ServiceProcessManager) YodaUtility.getFieldValue(getInternalServices(), "processManager"))
131    .endServiceCall(call);
132    } catch (NoSuchFieldException e) {
133  0 e.printStackTrace();
134  0 throw new RuntimeException(e);
135    }
136    }
137   
138    }