Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
17   81   7   2,43
0   59   0,41   1,75
7     1  
4    
 
 
  ObjectMethodsTest       Line # 17 17 7 100% 1.0
  ObjectMethodsTest.EmptyInterface       Line # 22 0 0 - -1.0
  ObjectMethodsTest.MockedClass       Line # 65 0 0 - -1.0
  ObjectMethodsTest.DummyProxy       Line # 68 0 0 - -1.0
 
  (6)
 
1    /*
2    * Copyright (c) 2001-2008 OFFIS, Tammo Freese.
3    * This program is made available under the terms of the MIT License.
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")
 
17    public class ObjectMethodsTest {
18    private MockControl<EmptyInterface> control;
19   
20    private EmptyInterface mock;
21   
 
22    private interface EmptyInterface {
23    }
24   
 
25  6 toggle @Before
26    public void setup() {
27  6 control = MockControl.createControl(EmptyInterface.class);
28  6 mock = control.getMock();
29    }
30   
 
31  1 toggle @Test
32    public void equalsBeforeActivation() {
33  1 assertEquals(mock, mock);
34  1 assertTrue(!mock.equals(null));
35    }
36   
 
37  1 toggle @Test
38    public void equalsAfterActivation() {
39  1 control.replay();
40  1 assertEquals(mock, mock);
41  1 assertTrue(!mock.equals(null));
42    }
43   
 
44  1 toggle @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   
 
52  1 toggle @Test
53    public void toStringBeforeActivation() {
54  1 assertEquals("EasyMock for " + EmptyInterface.class.toString(), mock
55    .toString());
56    }
57   
 
58  1 toggle @Test
59    public void toStringAfterActivation() {
60  1 control.replay();
61  1 assertEquals("EasyMock for " + EmptyInterface.class.toString(), mock
62    .toString());
63    }
64   
 
65    private static class MockedClass {
66    }
67   
 
68    private static class DummyProxy extends MockedClass {
69    }
70   
71    // if the class is no Proxy, ObjectMethodFilter should use the
72    // superclasses' name. This is needed for the class extension.
 
73  1 toggle @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    }