Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
248   538   83   6.7
4   429   0.33   37
37     2.24  
1    
 
  KernelContextTest       Line # 34 248 83 83.4% 0.83391005
 
  (34)
 
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;
17   
18    import java.io.File;
19    import java.io.IOException;
20    import java.net.URL;
21   
22    import org.qedeq.kernel.bo.test.DummyServiceModule;
23    import org.qedeq.kernel.bo.test.QedeqBoTestCase;
24    import org.qedeq.kernel.se.common.DefaultModuleAddress;
25    import org.qedeq.kernel.se.common.ModuleAddress;
26    import org.qedeq.kernel.se.config.QedeqConfig;
27    import org.qedeq.kernel.se.visitor.InterruptException;
28   
29    /**
30    * Test class.
31    *
32    * @author Michael Meyling
33    */
 
34    public class KernelContextTest extends QedeqBoTestCase {
35   
36    private KernelContext kernel;
37   
 
38  34 toggle protected void setUp() {
39    // we don't use super here!
40  34 kernel = KernelContext.getInstance();
41  34 kernel.shutdown();
42    }
43   
 
44  34 toggle protected void tearDown() {
45    // we don't use super here!
46  34 kernel.shutdown();
47    }
48   
 
49  1 toggle public void testGetBuildId() {
50  1 assertNotNull(kernel.getBuildId());
51    }
52   
 
53  1 toggle public void testGetKernelVersion() {
54  1 assertNotNull(kernel.getKernelVersion());
55    }
56   
 
57  1 toggle public void testGetDedicationVersion() {
58  1 assertNotNull(kernel.getDedication());
59    }
60   
 
61  1 toggle public void testGetDescriptiveKernelVersion() {
62  1 assertNotNull(kernel.getDescriptiveKernelVersion());
63    }
64   
 
65  1 toggle public void testGetKernelCodeName() {
66  1 assertNotNull(kernel.getKernelCodeName());
67    }
68   
 
69  1 toggle public void testGetKernelVersionDirectory() {
70  1 assertNotNull(kernel.getKernelVersionDirectory());
71    }
72   
 
73  1 toggle public void testIsRuleVersionSupported() {
74  1 assertTrue(kernel.isRuleVersionSupported("1.01.00"));
75  1 assertTrue(kernel.isRuleVersionSupported(kernel.getMaximalRuleVersion()));
76  1 assertFalse(kernel.isRuleVersionSupported("1.00.00"));
77    }
78   
 
79  1 toggle public void testGetMaximalRuleVersion() {
80  1 assertEquals("1.01.00", kernel.getMaximalRuleVersion());
81    }
82   
 
83  1 toggle public void testIsSetConnectionTimeOutSupported() {
84  1 if (System.getProperty("java.runtime.version").compareTo("1.5") <= 0) {
85  0 assertFalse(kernel.isSetConnectionTimeOutSupported());
86    } else {
87  1 assertTrue(kernel.isSetConnectionTimeOutSupported());
88    }
89    }
90   
 
91  1 toggle public void testIsSetReadTimeoutSupported() {
92  1 if (System.getProperty("java.runtime.version").compareTo("1.5") <= 0) {
93  0 assertFalse(kernel.isSetReadTimeoutSupported());
94    } else {
95  1 assertTrue(kernel.isSetReadTimeoutSupported());
96    }
97    }
98   
 
99  1 toggle public void testGetConfig() throws IOException {
100  1 assertNull(kernel.getConfig());
101  1 final QedeqConfig config = getConfig();
102  1 kernel.init(config, new DummyServiceModule());
103  1 assertEquals(config, kernel.getConfig());
104    }
105   
 
106  1 toggle public void testInit() throws IOException {
107  1 try {
108  1 kernel.init(null, new DummyServiceModule());
109  0 fail("NullPointerException expected");
110    } catch (NullPointerException e) {
111    // expected
112    }
113  1 try {
114  1 kernel.init(getConfig(), null);
115  0 fail("NullPointerException expected");
116    } catch (NullPointerException e) {
117    // expected
118    }
119  1 kernel.init(getConfig(), new DummyServiceModule());
120  1 try {
121  1 kernel.init(getConfig(), new DummyServiceModule());
122  0 fail("IllegalStateException expected");
123    } catch (IllegalStateException e) {
124    // expected
125    }
126  1 kernel.shutdown();
127  1 kernel.init(getConfig(), new DummyServiceModule());
128    }
129   
 
130  1 toggle public void testStartup() throws IOException {
131  1 try {
132  1 kernel.startup();
133  0 fail("IllegalStateException expected");
134    } catch (IllegalStateException e) {
135    // expected
136    }
137  1 kernel.init(getConfig(), new DummyServiceModule());
138  1 kernel.startup();
139  1 kernel.shutdown();
140  1 try {
141  1 kernel.startup();
142  0 fail("IllegalStateException expected");
143    } catch (IllegalStateException e) {
144    // expected
145    }
146    }
147   
 
148  1 toggle public void testShutdown() throws IOException {
149  1 kernel.shutdown();
150  1 kernel.shutdown();
151  1 kernel.init(getConfig(), new DummyServiceModule());
152  1 kernel.shutdown();
153  1 kernel.init(getConfig(), new DummyServiceModule());
154  1 kernel.startup();
155  1 kernel.shutdown();
156  1 kernel.shutdown();
157    }
158   
 
159  1 toggle public void testRemoveAllModules() throws IOException {
160  1 try {
161  1 kernel.removeAllModules();
162  0 fail("IllegalStateException expected");
163    } catch (IllegalStateException e) {
164    // expected
165    }
166  1 kernel.init(getConfig(), new DummyServiceModule());
167  1 try {
168  1 kernel.removeAllModules();
169  0 fail("IllegalStateException expected");
170    } catch (IllegalStateException e) {
171    // expected
172    }
173  1 kernel.startup();
174  1 kernel.removeAllModules();
175    }
176   
 
177  1 toggle public void testRemoveModule() throws IOException {
178  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
179  1 try {
180  1 kernel.removeModule(address);
181  0 fail("IllegalStateException expected");
182    } catch (IllegalStateException e) {
183    // expected
184    }
185  1 kernel.init(getConfig(), new DummyServiceModule());
186  1 try {
187  1 kernel.removeModule(address);
188  0 fail("IllegalStateException expected");
189    } catch (IllegalStateException e) {
190    // expected
191    }
192  1 kernel.startup();
193  1 kernel.removeModule(address);
194    }
195   
 
196  1 toggle public void testClearLocalBuffer() throws IOException {
197  1 try {
198  1 kernel.clearLocalBuffer();
199  0 fail("IllegalStateException expected");
200    } catch (IllegalStateException e) {
201    // expected
202    }
203  1 kernel.init(getConfig(), new DummyServiceModule());
204  1 try {
205  1 kernel.clearLocalBuffer();
206  0 fail("IllegalStateException expected");
207    } catch (IllegalStateException e) {
208    // expected
209    }
210  1 kernel.startup();
211  1 kernel.clearLocalBuffer();
212    }
213   
 
214  1 toggle public void testLoadModule() throws IOException {
215  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
216  1 try {
217  1 kernel.loadModule(address);
218  0 fail("IllegalStateException expected");
219    } catch (IllegalStateException e) {
220    // expected
221    }
222  1 kernel.init(getConfig(), new DummyServiceModule());
223  1 try {
224  1 kernel.loadModule(address);
225  0 fail("IllegalStateException expected");
226    } catch (IllegalStateException e) {
227    // expected
228    }
229  1 kernel.startup();
230  1 kernel.loadModule(address);
231    }
232   
 
233  1 toggle public void testLoadAllModulesFromQedeq() throws IOException {
234  1 try {
235  1 kernel.loadAllModulesFromQedeq();
236  0 fail("IllegalStateException expected");
237    } catch (IllegalStateException e) {
238    // expected
239    }
240  1 kernel.init(getConfig(), new DummyServiceModule());
241  1 try {
242  1 kernel.loadAllModulesFromQedeq();
243  0 fail("IllegalStateException expected");
244    } catch (IllegalStateException e) {
245    // expected
246    }
247  1 kernel.startup();
248  1 kernel.loadAllModulesFromQedeq();
249    }
250   
 
251  1 toggle public void testLoadRequiredModules() throws IOException {
252  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
253  1 try {
254  1 kernel.loadRequiredModules(address);
255  0 fail("IllegalStateException expected");
256    } catch (IllegalStateException e) {
257    // expected
258    }
259  1 kernel.init(getConfig(), new DummyServiceModule());
260  1 try {
261  1 kernel.loadRequiredModules(address);
262  0 fail("IllegalStateException expected");
263    } catch (IllegalStateException e) {
264    // expected
265    }
266  1 kernel.startup();
267  1 kernel.loadRequiredModules(address);
268    }
269   
 
270  1 toggle public void testGetAllLoadedModules() throws IOException {
271  1 try {
272  1 kernel.getAllLoadedModules();
273  0 fail("IllegalStateException expected");
274    } catch (IllegalStateException e) {
275    // expected
276    }
277  1 kernel.init(getConfig(), new DummyServiceModule());
278  1 try {
279  1 kernel.getAllLoadedModules();
280  0 fail("IllegalStateException expected");
281    } catch (IllegalStateException e) {
282    // expected
283    }
284  1 kernel.startup();
285  1 kernel.getAllLoadedModules();
286    }
287   
 
288  1 toggle public void testGetQedeqBo() throws IOException {
289  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
290  1 try {
291  1 kernel.getQedeqBo(address);
292  0 fail("IllegalStateException expected");
293    } catch (IllegalStateException e) {
294    // expected
295    }
296  1 kernel.init(getConfig(), new DummyServiceModule());
297  1 try {
298  1 kernel.getQedeqBo(address);
299  0 fail("IllegalStateException expected");
300    } catch (IllegalStateException e) {
301    // expected
302    }
303  1 kernel.startup();
304  1 kernel.getQedeqBo(address);
305    }
306   
 
307  1 toggle public void testGetModuleAddress() throws IOException {
308  1 final URL address = new URL("http://qedeq.org/");
309  1 try {
310  1 kernel.getModuleAddress(address);
311  0 fail("IllegalStateException expected");
312    } catch (IllegalStateException e) {
313    // expected
314    }
315  1 kernel.init(getConfig(), new DummyServiceModule());
316  1 try {
317  1 kernel.getModuleAddress(address);
318  0 fail("IllegalStateException expected");
319    } catch (IllegalStateException e) {
320    // expected
321    }
322  1 kernel.startup();
323  1 kernel.getModuleAddress(address);
324    }
325   
 
326  1 toggle public void testGetModuleAddress2() throws IOException {
327  1 final String address = "http://qedeq.org/";
328  1 try {
329  1 kernel.getModuleAddress(address);
330  0 fail("IllegalStateException expected");
331    } catch (IllegalStateException e) {
332    // expected
333    }
334  1 kernel.init(getConfig(), new DummyServiceModule());
335  1 try {
336  1 kernel.getModuleAddress(address);
337  0 fail("IllegalStateException expected");
338    } catch (IllegalStateException e) {
339    // expected
340    }
341  1 kernel.startup();
342  1 kernel.getModuleAddress(address);
343    }
344   
 
345  1 toggle public void testGetModuleAddress3() throws IOException {
346  1 final File address = new File("qedeq.org");
347  1 try {
348  1 kernel.getModuleAddress(address);
349  0 fail("IllegalStateException expected");
350    } catch (IllegalStateException e) {
351    // expected
352    }
353  1 kernel.init(getConfig(), new DummyServiceModule());
354  1 try {
355  1 kernel.getModuleAddress(address);
356  0 fail("IllegalStateException expected");
357    } catch (IllegalStateException e) {
358    // expected
359    }
360  1 kernel.startup();
361  1 kernel.getModuleAddress(address);
362    }
363   
 
364  1 toggle public void testGetSource() throws IOException {
365  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
366  1 try {
367  1 kernel.getSource(address);
368  0 fail("IllegalStateException expected");
369    } catch (IllegalStateException e) {
370    // expected
371    }
372  1 kernel.init(getConfig(), new DummyServiceModule());
373  1 try {
374  1 kernel.getSource(address);
375  0 fail("IllegalStateException expected");
376    } catch (IllegalStateException e) {
377    // expected
378    }
379  1 kernel.startup();
380  1 kernel.getSource(address);
381    }
382   
 
383  1 toggle public void testCheckWellFormedness() throws IOException {
384  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
385  1 try {
386  1 kernel.checkWellFormedness(address);
387  0 fail("IllegalStateException expected");
388    } catch (IllegalStateException e) {
389    // expected
390    }
391  1 kernel.init(getConfig(), new DummyServiceModule());
392  1 try {
393  1 kernel.checkWellFormedness(address);
394  0 fail("IllegalStateException expected");
395    } catch (IllegalStateException e) {
396    // expected
397    }
398  1 kernel.startup();
399  1 kernel.checkWellFormedness(address);
400    }
401   
 
402  1 toggle public void testCheckFormallyProved() throws IOException {
403  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
404  1 try {
405  1 kernel.checkFormallyProved(address);
406  0 fail("IllegalStateException expected");
407    } catch (IllegalStateException e) {
408    // expected
409    }
410  1 kernel.init(getConfig(), new DummyServiceModule());
411  1 try {
412  1 kernel.checkFormallyProved(address);
413  0 fail("IllegalStateException expected");
414    } catch (IllegalStateException e) {
415    // expected
416    }
417  1 kernel.startup();
418  1 kernel.checkFormallyProved(address);
419    }
420   
 
421  1 toggle public void testGetPlugins() throws IOException {
422  1 try {
423  1 kernel.getPlugins();
424  0 fail("IllegalStateException expected");
425    } catch (IllegalStateException e) {
426    // expected
427    }
428  1 kernel.init(getConfig(), new DummyServiceModule());
429  1 kernel.getPlugins();
430  1 kernel.startup();
431  1 kernel.getPlugins();
432    }
433   
 
434  1 toggle public void testExecutePlugin() throws IOException, InterruptException {
435  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
436  1 try {
437  1 kernel.executePlugin("noname", address, null);
438  0 fail("IllegalStateException expected");
439    } catch (IllegalStateException e) {
440    // expected
441    }
442  1 kernel.init(getConfig(), new DummyServiceModule());
443  1 try {
444  1 kernel.executePlugin("noname", address, null);
445  0 fail("IllegalStateException expected");
446    } catch (IllegalStateException e) {
447    // expected
448    }
449  1 kernel.startup();
450  1 kernel.executePlugin("noname", address, null);
451    }
452   
 
453  1 toggle public void testClearAllPluginResults() throws IOException {
454  1 final ModuleAddress address = DefaultModuleAddress.MEMORY;
455  1 try {
456  1 kernel.clearAllPluginResults(address);
457  0 fail("IllegalStateException expected");
458    } catch (IllegalStateException e) {
459    // expected
460    }
461  1 kernel.init(getConfig(), new DummyServiceModule());
462  1 try {
463  1 kernel.clearAllPluginResults(address);
464  0 fail("IllegalStateException expected");
465    } catch (IllegalStateException e) {
466    // expected
467    }
468  1 kernel.startup();
469  1 kernel.clearAllPluginResults(address);
470    }
471   
 
472  1 toggle public void testGetServiceProcesses() throws IOException {
473  1 try {
474  1 kernel.getServiceProcesses();
475  0 fail("IllegalStateException expected");
476    } catch (IllegalStateException e) {
477    // expected
478    }
479  1 kernel.init(getConfig(), new DummyServiceModule());
480  1 try {
481  1 kernel.getServiceProcesses();
482  0 fail("IllegalStateException expected");
483    } catch (IllegalStateException e) {
484    // expected
485    }
486  1 kernel.startup();
487  1 kernel.getServiceProcesses();
488    }
489   
 
490  1 toggle public void testGetRunningServiceProcesses() throws IOException {
491  1 try {
492  1 kernel.getRunningServiceProcesses();
493  0 fail("IllegalStateException expected");
494    } catch (IllegalStateException e) {
495    // expected
496    }
497  1 kernel.init(getConfig(), new DummyServiceModule());
498  1 try {
499  1 kernel.getRunningServiceProcesses();
500  0 fail("IllegalStateException expected");
501    } catch (IllegalStateException e) {
502    // expected
503    }
504  1 kernel.startup();
505  1 kernel.getRunningServiceProcesses();
506    }
507   
 
508  1 toggle public void testStopAllPluginExecutions() throws IOException {
509  1 try {
510  1 kernel.stopAllPluginExecutions();
511  0 fail("IllegalStateException expected");
512    } catch (IllegalStateException e) {
513    // expected
514    }
515  1 kernel.init(getConfig(), new DummyServiceModule());
516  1 try {
517  1 kernel.stopAllPluginExecutions();
518  0 fail("IllegalStateException expected");
519    } catch (IllegalStateException e) {
520    // expected
521    }
522  1 kernel.startup();
523  1 kernel.stopAllPluginExecutions();
524    }
525   
 
526  28 toggle private QedeqConfig getConfig() throws IOException {
527  28 final File cf = new File(getOutdir(), "config/org.qedeq.properties");
528  28 cf.getParentFile().mkdirs();
529  28 cf.createNewFile();
530  28 final QedeqConfig config = new QedeqConfig(
531    cf,
532    "This file is part of the project *Hilbert II* - http://www.qedeq.org",
533    getOutdir());
534  28 config.setAutoReloadLastSessionChecked(false);
535  28 return config;
536    }
537   
538    }