Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
15   98   6   3
0   38   0.4   5
5     1.2  
1    
 
  YodaUtilityTest       Line # 25 15 6 95% 0.95
 
  (5)
 
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   
16    package org.qedeq.base.utility;
17   
18    import org.qedeq.base.test.QedeqTestCase;
19   
20    /**
21    * Test {@link YodaUtility}.
22    *
23    * @author Michael Meyling
24    */
 
25    public class YodaUtilityTest extends QedeqTestCase {
26   
27    /** Very secret number, which is read by yoda with the help of the force. */
28    private final static int secret = 967123;
29   
30    /** Very secret number, which is changed by yoda with the help of the force. */
31    private int changeMe = 815;
32   
33    /**
34    * Test {@link YodaUtility#getFieldValue(Object, String)}.
35    *
36    * @throws Exception
37    */
 
38  1 toggle public void testGetFieldValue() throws Exception {
39  1 assertEquals(new Integer(secret), YodaUtility.getFieldValue(this, "secret"));
40  1 assertEquals(getOutdir(), YodaUtility.getFieldValue(this, "outdir"));
41    }
42   
43    /**
44    * Test {@link YodaUtility#getField(Object, String)}.
45    *
46    * @throws Exception
47    */
 
48  1 toggle public void testGetField() throws Exception {
49  1 assertEquals(this.getClass().getDeclaredField("secret"),
50    YodaUtility.getField(this, "secret"));
51    }
52   
53    /**
54    * Test {@link YodaUtility#executeMethod(Object, String, Class[], Object[])}.
55    *
56    * @throws Exception
57    */
 
58  1 toggle public void testExecuteMethod() throws Exception {
59  1 assertEquals(getOutdir(), YodaUtility.executeMethod(this, "getOutdir",
60    new Class[]{}, new Object[]{}));
61    }
62   
63    /**
64    * Test {@link YodaUtility#existsMethod(Class, String, Class[])}.
65    *
66    * @throws Exception
67    */
 
68  1 toggle public void testExistsMethod() throws Exception {
69  1 assertTrue(YodaUtility.existsMethod(this.getClass(), "getOutdir",
70    new Class[]{}));
71  1 assertFalse(YodaUtility.existsMethod(this.getClass(), "getOutdir",
72    new Class[]{Integer.TYPE}));
73  1 assertFalse(YodaUtility.existsMethod(this.getClass(), "getTevqOutdir",
74    new Class[]{}));
75  1 assertTrue(YodaUtility.existsMethod(this.getClass(), "testExistsMethod",
76    new Class[]{}));
77    }
78   
79    /**
80    * Test {@link YodaUtility#getFieldValue(Object, String)}.
81    *
82    * @throws Exception
83    */
 
84  1 toggle public void testSetFieldValue() throws Exception {
85  1 try {
86  1 YodaUtility.setFieldContent(this, "secret", new Integer(37846));
87    // System.out.println("secret=" + secret);
88  0 fail("Exception expected");
89    } catch (Exception e) {
90    // expected;
91    }
92  1 changeMe = 0;
93  1 YodaUtility.setFieldContent(this, "changeMe", new Integer(37846));
94  1 assertEquals(37846, changeMe);;
95    }
96   
97   
98    }