1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.base.utility; |
17 |
|
|
18 |
|
import org.qedeq.base.test.QedeqTestCase; |
19 |
|
|
20 |
|
|
21 |
|
@link |
22 |
|
|
23 |
|
@author |
24 |
|
|
|
|
| 86.9% |
Uncovered Elements: 8 (61) |
Complexity: 19 |
Complexity Density: 0.37 |
|
25 |
|
public class YodaUtilityTest extends QedeqTestCase { |
26 |
|
|
27 |
|
|
28 |
|
private static final int secret = 967123; |
29 |
|
|
30 |
|
|
31 |
|
private int changeMe = 815; |
32 |
|
|
33 |
|
|
34 |
|
@link |
35 |
|
|
36 |
|
@throws |
37 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
1
PASS
|
|
38 |
1
|
public void testGetFieldValue() throws Exception {... |
39 |
1
|
assertEquals(new Integer(secret), YodaUtility.getFieldValue(this, "secret")); |
40 |
1
|
assertEquals(getOutdir(), YodaUtility.getFieldValue(this, "outdir")); |
41 |
1
|
try { |
42 |
1
|
YodaUtility.getFieldValue(this, "unknown"); |
43 |
0
|
fail("Exception expected"); |
44 |
|
} catch (NoSuchFieldException e) { |
45 |
|
|
46 |
|
} |
47 |
|
} |
48 |
|
|
49 |
|
|
50 |
|
@link |
51 |
|
|
52 |
|
@throws |
53 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
1
PASS
|
|
54 |
1
|
public void testGetField() throws Exception {... |
55 |
1
|
assertEquals(this.getClass().getDeclaredField("secret"), |
56 |
|
YodaUtility.getField(this, "secret")); |
57 |
1
|
assertEquals(QedeqTestCase.class.getDeclaredField("outdir"), |
58 |
|
YodaUtility.getField(this, "outdir")); |
59 |
1
|
try { |
60 |
1
|
YodaUtility.getField(this, "unknown"); |
61 |
0
|
fail("Exception expected"); |
62 |
|
} catch (NoSuchFieldException e) { |
63 |
|
|
64 |
|
} |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
@link |
69 |
|
|
70 |
|
@throws |
71 |
|
|
|
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 4 |
Complexity Density: 0.33 |
1
PASS
|
|
72 |
1
|
public void testExecuteMethod() throws Exception {... |
73 |
1
|
assertEquals(getOutdir(), YodaUtility.executeMethod(this, "getOutdir", |
74 |
|
new Class[]{}, new Object[]{})); |
75 |
1
|
try { |
76 |
1
|
YodaUtility.executeMethod(this, "getoutdir", |
77 |
|
new Class[]{}, new Object[]{}); |
78 |
0
|
fail("exception expected"); |
79 |
|
} catch (NoSuchMethodException e) { |
80 |
|
|
81 |
|
} |
82 |
1
|
final String time = "" + System.currentTimeMillis(); |
83 |
1
|
assertEquals(myTestMethod(time), |
84 |
|
YodaUtility.executeMethod(this, "myTestMethod", |
85 |
|
new Class[]{String.class}, new Object[]{ time})); |
86 |
1
|
try { |
87 |
1
|
YodaUtility.executeMethod(this, "myTestMethodi", |
88 |
|
new Class[]{String.class}, new Object[]{ time}); |
89 |
0
|
fail("exception expected"); |
90 |
|
} catch (NoSuchMethodException e) { |
91 |
|
|
92 |
|
} |
93 |
1
|
try { |
94 |
1
|
YodaUtility.executeMethod(this, "myTestMethod", |
95 |
|
new Class[]{}, new Object[]{}); |
96 |
0
|
fail("exception expected"); |
97 |
|
} catch (NoSuchMethodException e) { |
98 |
|
|
99 |
|
} |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
2
|
private String myTestMethod(final String my) {... |
103 |
2
|
return my + "done!"; |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
@link |
108 |
|
|
109 |
|
@throws |
110 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 5 |
Complexity Density: 0.42 |
1
PASS
|
|
111 |
1
|
public void testExecuteMethod2() throws Exception {... |
112 |
1
|
try { |
113 |
1
|
YodaUtility.executeMethod(this.getClass().getName(), "getOutdir", |
114 |
|
new Class[]{}, new Object[]{}); |
115 |
0
|
fail("exception expected"); |
116 |
|
} catch (NoSuchMethodException e) { |
117 |
|
|
118 |
|
} |
119 |
1
|
try { |
120 |
1
|
YodaUtility.executeMethod(this.getClass().getName(), "getoutdir", |
121 |
|
new Class[]{}, new Object[]{}); |
122 |
0
|
fail("exception expected"); |
123 |
|
} catch (NoSuchMethodException e) { |
124 |
|
|
125 |
|
} |
126 |
1
|
final String time = "" + System.currentTimeMillis(); |
127 |
1
|
assertEquals(myStaticTestMethod(time), |
128 |
|
YodaUtility.executeMethod(this.getClass().getName(), "myStaticTestMethod", |
129 |
|
new Class[]{String.class}, new Object[]{ time})); |
130 |
1
|
try { |
131 |
1
|
YodaUtility.executeMethod(this.getClass().getName(), "myStaticTestMethodi", |
132 |
|
new Class[]{String.class}, new Object[]{ time}); |
133 |
|
} catch (NoSuchMethodException e) { |
134 |
|
|
135 |
|
} |
136 |
1
|
try { |
137 |
1
|
YodaUtility.executeMethod(this.getClass().getName(), "myStaticTestMethod", |
138 |
|
new Class[]{}, new Object[]{}); |
139 |
|
} catch (NoSuchMethodException e) { |
140 |
|
|
141 |
|
} |
142 |
|
} |
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
144 |
2
|
private static String myStaticTestMethod(final String my) {... |
145 |
2
|
return my + "done!"; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
@link |
150 |
|
|
151 |
|
@throws |
152 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1
PASS
|
|
153 |
1
|
public void testExistsMethod() throws Exception {... |
154 |
1
|
assertTrue(YodaUtility.existsMethod(this.getClass(), "getOutdir", |
155 |
|
new Class[]{})); |
156 |
1
|
assertFalse(YodaUtility.existsMethod(this.getClass(), "getOutdir", |
157 |
|
new Class[]{Integer.TYPE})); |
158 |
1
|
assertFalse(YodaUtility.existsMethod(this.getClass(), "getTevqOutdir", |
159 |
|
new Class[]{})); |
160 |
1
|
assertTrue(YodaUtility.existsMethod(this.getClass(), "testExistsMethod", |
161 |
|
new Class[]{})); |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
|
@link |
166 |
|
|
167 |
|
@throws |
168 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
1
PASS
|
|
169 |
1
|
public void testSetFieldValue() throws Exception {... |
170 |
1
|
try { |
171 |
1
|
YodaUtility.setFieldContent(this, "secret", new Integer(37846)); |
172 |
|
|
173 |
0
|
fail("Exception expected"); |
174 |
|
} catch (Exception e) { |
175 |
|
|
176 |
|
} |
177 |
1
|
changeMe = 0; |
178 |
1
|
YodaUtility.setFieldContent(this, "changeMe", new Integer(37846)); |
179 |
1
|
assertEquals(37846, changeMe);; |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
@link |
184 |
|
|
185 |
|
@throws |
186 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1
PASS
|
|
187 |
1
|
public void testExistsMethod2() throws Exception {... |
188 |
1
|
assertTrue(YodaUtility.existsMethod(this.getClass().getName(), "getOutdir", |
189 |
|
new Class[]{})); |
190 |
1
|
assertFalse(YodaUtility.existsMethod(this.getClass().getName(), "getOutdir", |
191 |
|
new Class[]{Integer.TYPE})); |
192 |
1
|
assertFalse(YodaUtility.existsMethod(this.getClass().getName(), "getTevqOutdir", |
193 |
|
new Class[]{})); |
194 |
1
|
assertTrue(YodaUtility.existsMethod(this.getClass().getName(), "testExistsMethod2", |
195 |
|
new Class[]{})); |
196 |
1
|
assertFalse(YodaUtility.existsMethod("this.is.a.non.existing.Class", "getOutdir", |
197 |
|
new Class[]{})); |
198 |
|
} |
199 |
|
|
200 |
|
} |