Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
16   78   4   4
0   42   0,25   4
4     1  
1    
 
  CapturesMatcherTest       Line # 33 16 0% 4 0 100% 1.0
 
  (2)
 
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.junit.Assert.*;
20   
21    import org.easymock.Capture;
22    import org.easymock.CaptureType;
23    import org.easymock.internal.Invocation;
24    import org.easymock.internal.LastControl;
25    import org.easymock.internal.matchers.Captures;
26    import org.junit.After;
27    import org.junit.Before;
28    import org.junit.Test;
29   
30    /**
31    * @author Henri Tremblay
32    */
 
33    public class CapturesMatcherTest {
34   
35    private final Capture<String> capture = new Capture<String>(CaptureType.ALL);
36   
37    private final Captures<String> matcher = new Captures<String>(capture);
38   
39    private StringBuffer buffer;
40   
 
41  2 toggle @Before
42    public void setUp() throws Exception {
43  2 LastControl.pushCurrentInvocation(new Invocation(this, getClass().getMethod("test"), new Object[0]));
44  2 buffer = new StringBuffer();
45    }
46   
 
47  2 toggle @After
48    public void tearDown() {
49  2 LastControl.popCurrentInvocation();
50    }
51   
 
52  2 toggle @Test
53    public void test() throws Exception {
54   
55  2 matcher.appendTo(buffer);
56  2 assertEquals("capture(Nothing captured yet)", buffer.toString());
57   
58  2 assertTrue(matcher.matches(null));
59   
60  2 matcher.validateCapture();
61   
62  2 clearBuffer();
63  2 matcher.appendTo(buffer);
64  2 assertEquals("capture(null)", buffer.toString());
65   
66  2 assertTrue(matcher.matches("s"));
67   
68  2 matcher.validateCapture();
69   
70  2 clearBuffer();
71  2 matcher.appendTo(buffer);
72  2 assertEquals("capture([null, s])", buffer.toString());
73    }
74   
 
75  4 toggle private void clearBuffer() {
76  4 buffer.delete(0, buffer.length());
77    }
78    }