1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.easymock.tests; |
18 |
|
|
19 |
|
import static org.easymock.EasyMock.*; |
20 |
|
import static org.junit.Assert.*; |
21 |
|
|
22 |
|
import java.lang.reflect.Method; |
23 |
|
|
24 |
|
import org.easymock.internal.ObjectMethodsFilter; |
25 |
|
import org.junit.Before; |
26 |
|
import org.junit.Test; |
27 |
|
|
28 |
|
|
29 |
|
@author |
30 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 7 |
Complexity Density: 0,44 |
|
31 |
|
public class ObjectMethodsTest { |
32 |
|
|
33 |
|
private EmptyInterface mock; |
34 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
35 |
|
private interface EmptyInterface { |
36 |
|
} |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
38 |
12
|
@Before... |
39 |
|
public void setup() { |
40 |
12
|
mock = createMock(EmptyInterface.class); |
41 |
|
} |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
43 |
2
|
@Test... |
44 |
|
public void equalsBeforeActivation() { |
45 |
2
|
assertEquals(mock, mock); |
46 |
2
|
assertTrue(!mock.equals(null)); |
47 |
|
} |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
49 |
2
|
@Test... |
50 |
|
public void equalsAfterActivation() { |
51 |
2
|
replay(mock); |
52 |
2
|
assertEquals(mock, mock); |
53 |
2
|
assertTrue(!mock.equals(null)); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
56 |
2
|
@Test... |
57 |
|
public void testHashCode() { |
58 |
2
|
final int hashCodeBeforeActivation = mock.hashCode(); |
59 |
2
|
replay(mock); |
60 |
2
|
final int hashCodeAfterActivation = mock.hashCode(); |
61 |
2
|
assertEquals(hashCodeBeforeActivation, hashCodeAfterActivation); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
64 |
2
|
@Test... |
65 |
|
public void toStringBeforeActivation() { |
66 |
2
|
assertEquals("EasyMock for " + EmptyInterface.class.toString(), mock.toString()); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
69 |
2
|
@Test... |
70 |
|
public void toStringAfterActivation() { |
71 |
2
|
replay(mock); |
72 |
2
|
assertEquals("EasyMock for " + EmptyInterface.class.toString(), mock.toString()); |
73 |
|
} |
74 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
75 |
|
private static class MockedClass { |
76 |
|
} |
77 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
78 |
|
private static class DummyProxy extends MockedClass { |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
83 |
2
|
@Test... |
84 |
|
public void toStringForClasses() throws Throwable { |
85 |
2
|
final ObjectMethodsFilter filter = new ObjectMethodsFilter(Object.class, null, null); |
86 |
2
|
final Method toString = Object.class.getMethod("toString", new Class[0]); |
87 |
2
|
assertEquals("EasyMock for " + MockedClass.class.toString(), filter.invoke(new DummyProxy(), |
88 |
|
toString, new Object[0])); |
89 |
|
} |
90 |
|
|
91 |
|
} |