Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
35   94   9   7
2   73   0,26   2,5
5     1,8  
2    
 
 
  DefaultMatcherTest       Line # 14 35 9 88,1% 0.88095236
  DefaultMatcherTest.ArrayInterface       Line # 16 0 0 - -1.0
 
  (4)
 
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 org.easymock.MockControl;
10    import org.junit.Before;
11    import org.junit.Test;
12   
13    @SuppressWarnings("deprecation")
 
14    public class DefaultMatcherTest {
15   
 
16    public static interface ArrayInterface {
17    void methodA(int[] argument);
18   
19    void methodB(int[] argument);
20    }
21   
22    private MockControl<ArrayInterface> control;
23   
24    private ArrayInterface mock;
25   
 
26  4 toggle @Before
27    public void setup() {
28  4 control = MockControl.createControl(ArrayInterface.class);
29  4 mock = control.getMock();
30    }
31   
 
32  1 toggle @Test
33    public void defaultMatcher() {
34  1 control.setDefaultMatcher(MockControl.ARRAY_MATCHER);
35   
36  1 mock.methodA(new int[] { 1, 1 });
37  1 mock.methodB(new int[] { 2, 2 });
38   
39  1 control.replay();
40   
41  1 mock.methodA(new int[] { 1, 1 });
42  1 mock.methodB(new int[] { 2, 2 });
43   
44  1 control.verify();
45    }
46   
 
47  1 toggle @Test
48    public void failInReplayState() {
49  1 control.replay();
50  1 try {
51  1 control.setDefaultMatcher(MockControl.ARRAY_MATCHER);
52  0 fail();
53    } catch (IllegalStateException expected) {
54    }
55    }
56   
 
57  1 toggle @Test
58    public void failIfDefaultMatcherSetTwice() {
59  1 control.setDefaultMatcher(MockControl.ARRAY_MATCHER);
60  1 try {
61  1 control.setDefaultMatcher(MockControl.ARRAY_MATCHER);
62  0 fail();
63    } catch (IllegalStateException expected) {
64  1 assertEquals(
65    "default matcher can only be set once directly after creation of the MockControl",
66    expected.getMessage());
67    }
68    }
69   
 
70  1 toggle @Test
71    public void defaultMatcherSetTooLate() {
72  1 int[] integers = new int[] { 1, 1 };
73  1 int[] integers2 = new int[] { 2, 2 };
74  1 mock.methodA(integers);
75  1 control.setVoidCallable();
76  1 control.setDefaultMatcher(MockControl.ARRAY_MATCHER);
77  1 mock.methodA(integers2);
78  1 control.setVoidCallable();
79  1 control.replay();
80   
81  1 boolean failed = true;
82  1 try {
83  1 mock.methodA(new int[] { 1, 1 });
84  0 failed = false;
85    } catch (AssertionError expected) {
86    }
87  1 if (!failed) {
88  0 fail();
89    }
90  1 mock.methodA(integers);
91  1 mock.methodA(new int[] { 2, 2 });
92  1 control.verify();
93    }
94    }