Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
31   98   6   6,2
0   58   0,19   5
5     1,2  
1    
 
  UsageRangeTest       Line # 30 31 0% 6 1 97,2% 0.9722222
 
  (8)
 
1    /**
2    * Copyright 2001-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16   
17    package org.easymock.tests;
18   
19    import static org.easymock.EasyMock.*;
20    import static org.junit.Assert.*;
21   
22    import java.util.Iterator;
23   
24    import org.junit.Before;
25    import org.junit.Test;
26   
27    /**
28    * @author OFFIS, Tammo Freese
29    */
 
30    public class UsageRangeTest {
31   
32    private Iterator<String> mock;
33   
 
34  8 toggle @SuppressWarnings("unchecked")
35    @Before
36    public void setup() {
37  8 mock = createStrictMock(Iterator.class);
38    }
39   
 
40  2 toggle @Test
41    public void zeroOrMoreNoCalls() {
42  2 expect(mock.hasNext()).andReturn(false).anyTimes();
43  2 replay(mock);
44  2 verify(mock);
45    }
46   
 
47  2 toggle @Test
48    public void zeroOrMoreOneCall() {
49  2 expect(mock.hasNext()).andReturn(false).anyTimes();
50  2 replay(mock);
51  2 assertFalse(mock.hasNext());
52  2 verify(mock);
53    }
54   
 
55  2 toggle @Test
56    public void zeroOrMoreThreeCalls() {
57  2 expect(mock.hasNext()).andReturn(false).anyTimes();
58  2 replay(mock);
59  2 assertFalse(mock.hasNext());
60  2 assertFalse(mock.hasNext());
61  2 assertFalse(mock.hasNext());
62  2 verify(mock);
63    }
64   
 
65  2 toggle @Test
66    public void combination() {
67  2 expect(mock.hasNext()).andReturn(true).atLeastOnce();
68  2 expect(mock.next()).andReturn("1");
69   
70  2 expect(mock.hasNext()).andReturn(true).atLeastOnce();
71  2 expect(mock.next()).andReturn("2");
72   
73  2 expect(mock.hasNext()).andReturn(false).atLeastOnce();
74   
75  2 replay(mock);
76   
77  2 assertTrue(mock.hasNext());
78  2 assertTrue(mock.hasNext());
79  2 assertTrue(mock.hasNext());
80   
81  2 assertEquals("1", mock.next());
82   
83  2 try {
84  2 mock.next();
85  0 fail();
86    } catch (final AssertionError expected) {
87    }
88   
89  2 assertTrue(mock.hasNext());
90   
91  2 assertEquals("2", mock.next());
92   
93  2 assertFalse(mock.hasNext());
94   
95  2 verify(mock);
96   
97    }
98    }