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