Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
66   283   20   4.71
0   124   0.3   14
14     1.43  
1    
 
  LoadRequiredModulesTest       Line # 29 66 20 90% 0.9
 
  (10)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, 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;
16   
17    import org.qedeq.base.test.QedeqTestCase;
18    import org.qedeq.kernel.bo.context.KernelContext;
19    import org.qedeq.kernel.bo.test.KernelFacade;
20    import org.qedeq.kernel.common.DefaultModuleAddress;
21    import org.qedeq.kernel.common.ModuleAddress;
22    import org.qedeq.kernel.common.SourceFileExceptionList;
23   
24    /**
25    * For testing of loading required QEDEQ modules.
26    *
27    * @author Michael Meyling
28    */
 
29    public class LoadRequiredModulesTest extends QedeqTestCase {
30   
 
31  10 toggle protected void setUp() throws Exception {
32  10 super.setUp();
33  10 KernelFacade.startup();
34    }
35   
 
36  10 toggle protected void tearDown() throws Exception {
37  10 KernelFacade.shutdown();
38  10 super.tearDown();
39    }
40   
 
41  0 toggle public LoadRequiredModulesTest() {
42  0 super();
43    }
44   
 
45  10 toggle public LoadRequiredModulesTest(final String name) {
46  10 super(name);
47    }
48   
49    /**
50    * Load following dependencies:
51    * <pre>
52    * 011 -> 012
53    * 011 -> 013 -> 012
54    * </pre>
55    *
56    * @throws Exception
57    */
 
58  1 toggle public void testLoadRequiredModules_01() throws Exception {
59  1 final ModuleAddress address = new DefaultModuleAddress(getFile("loadRequired/LRM011.xml"));
60  1 KernelContext.getInstance().loadRequiredModules(address);
61    }
62   
63    /**
64    * Load following dependencies:
65    * <pre>
66    * 021 -> 021
67    * </pre>
68    *
69    * @throws Exception
70    */
 
71  1 toggle public void testLoadRequiredModules_02() throws Exception {
72  1 try {
73  1 final ModuleAddress address = new DefaultModuleAddress(
74    getFile("loadRequired/LRM021.xml"));
75  1 KernelContext.getInstance().loadRequiredModules(address);
76  0 fail("021 -> 021 cycle");
77    } catch (SourceFileExceptionList e) {
78  1 assertEquals(1, e.size());
79  1 assertEquals(31, e.get(0).getSourceArea().getStartPosition().getRow());
80  1 assertEquals(15, e.get(0).getSourceArea().getStartPosition().getColumn());
81    // TODO mime 20071101: check if exception code and description is ok
82    }
83    }
84   
85    /**
86    * Load following dependencies:
87    * <pre>
88    * 031 -> 032 -> 031
89    * </pre>
90    *
91    * @throws Exception
92    */
 
93  1 toggle public void testLoadRequiredModules_03() throws Exception {
94  1 try {
95  1 final ModuleAddress address = new DefaultModuleAddress(
96    getFile("loadRequired/LRM031.xml"));
97  1 KernelContext.getInstance().loadRequiredModules(address);
98  0 fail("031 -> 032 -> 031 cycle");
99    } catch (SourceFileExceptionList e) {
100  1 assertEquals(1, e.size());
101    // e.printStackTrace();
102  1 assertEquals(31, e.get(0).getSourceArea().getStartPosition().getRow());
103  1 assertEquals(15, e.get(0).getSourceArea().getStartPosition().getColumn());
104    // TODO mime 20071101: check if exception code and description is ok
105    }
106    }
107   
108    /**
109    * Load following dependencies:
110    * <pre>
111    * 041 -> 042 -> 043
112    * 041 -> 043 -> 044
113    * 041 -> 044 -> 042
114    * </pre>
115    *
116    * @throws Exception
117    */
 
118  1 toggle public void testLoadRequiredModules_04() throws Exception {
119  1 try {
120  1 final ModuleAddress address = new DefaultModuleAddress(
121    getFile("loadRequired/LRM041.xml"));
122  1 KernelContext.getInstance().loadRequiredModules(address);
123  0 fail("041 -> 042 -> 043 -> 044 -> 042 cycle\n"
124    + "041 -> 043 -> 044 -> 042 -> 043 cycle\n"
125    + "041 -> 044 -> 042 -> 043 -> 044 cycle");
126    } catch (SourceFileExceptionList e) {
127  1 assertEquals(31, e.get(0).getSourceArea().getStartPosition().getRow());
128  1 assertEquals(15, e.get(0).getSourceArea().getStartPosition().getColumn());
129  1 assertEquals(3, e.size());
130  1 assertEquals(38, e.get(1).getSourceArea().getStartPosition().getRow());
131  1 assertEquals(15, e.get(1).getSourceArea().getStartPosition().getColumn());
132  1 assertEquals(45, e.get(2).getSourceArea().getStartPosition().getRow());
133  1 assertEquals(15, e.get(2).getSourceArea().getStartPosition().getColumn());
134    // TODO mime 20071101: check if exception code and description is ok
135    }
136    }
137   
138    /**
139    * Load following dependencies:
140    * <pre>
141    * 051 -> 052 -> 053 -> 056
142    * 051 -> 052 -> 054 -> 056
143    * 051 -> 052 -> 055 -> 053 -> 056
144    * 051 -> 052 -> 055 -> 057
145    * 051 -> 053 -> 056
146    * 051 -> 054 -> 056
147    * 051 -> 055 -> 057
148    * </pre>
149    *
150    * @throws Exception
151    */
 
152  1 toggle public void testLoadRequiredModules_05() throws Exception {
153  1 final ModuleAddress address = new DefaultModuleAddress(
154    getFile("loadRequired/LRM051.xml"));
155  1 KernelContext.getInstance().loadRequiredModules(address);
156    }
157   
158    /**
159    * Load following dependencies:
160    * <pre>
161    * 061 -> 062 -> 063 -> 066 -> 067
162    * 061 -> 062 -> 064 -> 066 -> 067
163    * 061 -> 062 -> 065 -> 063 -> 066 -> 067
164    * 061 -> 062 -> 065 -> 067
165    * 061 -> 063 -> 066 -> 067
166    * 061 -> 064 -> 066 -> 067
167    * 061 -> 065 -> 067
168    * </pre>
169    *
170    * @throws Exception
171    */
 
172  1 toggle public void testLoadRequiredModules_06() throws Exception {
173  1 final ModuleAddress address = new DefaultModuleAddress(getFile("loadRequired/LRM061.xml"));
174  1 KernelContext.getInstance().loadRequiredModules(address);
175    }
176   
177    /**
178    * Load following dependencies:
179    * <pre>
180    * 071 -> 072 -> 073 -> 076 -> 077
181    * 071 -> 072 -> 073 -> 076 -> 071 c
182    * 071 -> 072 -> 073 -> 075 -> 073 c
183    * 071 -> 072 -> 073 -> 075 -> 077
184    * 071 -> 072 -> 074 -> 076 -> 077
185    * 071 -> 072 -> 074 -> 076 -> 071 c
186    * 071 -> 072 -> 075 -> 073 -> 076 -> 077
187    * 071 -> 072 -> 075 -> 073 -> 075 c
188    * 071 -> 072 -> 075 -> 077
189    * 071 -> 073 -> 076 -> 077
190    * 071 -> 073 -> 076 -> 071 c
191    * 071 -> 073 -> 075 -> 073 c
192    * 071 -> 074 -> 076 -> 077
193    * 071 -> 074 -> 076 -> 071 c
194    * 071 -> 075 -> 073 -> 076 -> 077
195    * 071 -> 075 -> 073 -> 076 -> 071 c
196    * 071 -> 075 -> 073 -> 075 - >073 c
197    * </pre>
198    *
199    * @throws Exception
200    */
 
201  1 toggle public void testLoadRequiredModules_07() throws Exception {
202  1 try {
203  1 final ModuleAddress address = new DefaultModuleAddress(
204    getFile("loadRequired/LRM071.xml"));
205  1 KernelContext.getInstance().loadRequiredModules(address);
206  0 fail("see test method description");
207    } catch (SourceFileExceptionList e) {
208    // e.printStackTrace(System.out);
209  1 assertEquals(31, e.get(0).getSourceArea().getStartPosition().getRow());
210  1 assertEquals(15, e.get(0).getSourceArea().getStartPosition().getColumn());
211  1 assertEquals(4, e.size());
212  1 assertEquals(38, e.get(1).getSourceArea().getStartPosition().getRow());
213  1 assertEquals(15, e.get(1).getSourceArea().getStartPosition().getColumn());
214  1 assertEquals(45, e.get(2).getSourceArea().getStartPosition().getRow());
215  1 assertEquals(15, e.get(2).getSourceArea().getStartPosition().getColumn());
216  1 assertEquals(52, e.get(3).getSourceArea().getStartPosition().getRow());
217  1 assertEquals(15, e.get(3).getSourceArea().getStartPosition().getColumn());
218    // TODO mime 20071105: check if exception code and description is ok
219    }
220    }
221   
222    /**
223    * Load following dependencies:
224    * <pre>
225    * 081 -> 082 -> 083 -> 084 -> 085 -> 086 -> 087 -> 089
226    * </pre>
227    *
228    * @throws Exception
229    */
 
230  1 toggle public void testLoadRequiredModules_08() throws Exception {
231  1 final ModuleAddress address = new DefaultModuleAddress(getFile("loadRequired/LRM081.xml"));
232  1 KernelContext.getInstance().loadRequiredModules(address);
233    }
234   
235    /**
236    * Load following dependencies:
237    * <pre>
238    * 091 -> 092 -> 093 -> 094 -> 095 -> 096 -> 097 -> 099 -> 091
239    * </pre>
240    *
241    * @throws Exception
242    */
 
243  1 toggle public void testLoadRequiredModules_09() throws Exception {
244  1 try {
245  1 final ModuleAddress address = new DefaultModuleAddress(
246    getFile("loadRequired/LRM091.xml"));
247  1 KernelContext.getInstance().loadRequiredModules(address);
248  0 fail("091 -> 092 -> 093 -> 094 -> 095 -> 096 -> 097 -> 098 -> 099 -> 091 cycle\n");
249    } catch (SourceFileExceptionList e) {
250  1 assertEquals(31, e.get(0).getSourceArea().getStartPosition().getRow());
251  1 assertEquals(15, e.get(0).getSourceArea().getStartPosition().getColumn());
252  1 assertEquals(1, e.size());
253    // TODO mime 20071105: check if exception code and description is ok
254    }
255    }
256   
257    /**
258    * Load following dependencies:
259    * <pre>
260    * 101 -> 102
261    * 101 -> notThere
262    * 101 -> 103
263    * 101 -> alsoNotThere
264    * 101 -> 104
265    * </pre>
266    *
267    * @throws Exception
268    */
 
269  1 toggle public void testLoadRequiredModules_10() throws Exception {
270  1 try {
271  1 final ModuleAddress address = new DefaultModuleAddress(
272    getFile("loadRequired/LRM101.xml"));
273  1 KernelContext.getInstance().loadRequiredModules(address);
274  0 fail("two imports don't exist: \"notThere\" and \"alsoNotThere\"\n");
275    } catch (SourceFileExceptionList e) {
276  1 assertEquals(38, e.get(0).getSourceArea().getStartPosition().getRow());
277  1 assertEquals(15, e.get(0).getSourceArea().getStartPosition().getColumn());
278  1 assertEquals(2, e.size());
279    // TODO mime 20100820: check if exception code and description is ok
280    }
281    }
282   
283    }