Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
12   56   8   4
10   42   0,67   3
3     2,67  
1    
 
 
  LegacyMatcherProvider       Line # 15 12 8 100% 1.0
 
  (13)
 
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.internal;
6   
7    import java.lang.reflect.Method;
8    import java.util.HashMap;
9    import java.util.Map;
10   
11    import org.easymock.ArgumentsMatcher;
12    import org.easymock.MockControl;
13   
14    @SuppressWarnings("deprecation")
 
15    public class LegacyMatcherProvider {
16   
17    private ArgumentsMatcher defaultMatcher;
18   
19    private boolean defaultMatcherSet;
20   
21    private Map<Method, ArgumentsMatcher> matchers = new HashMap<Method, ArgumentsMatcher>();
22   
 
23  14 toggle public ArgumentsMatcher getMatcher(Method method) {
24  14 if (!matchers.containsKey(method)) {
25  5 if (!defaultMatcherSet) {
26  1 setDefaultMatcher(MockControl.EQUALS_MATCHER);
27    }
28  5 matchers.put(method, defaultMatcher);
29    }
30  14 return matchers.get(method);
31    }
32   
33   
 
34  7 toggle public void setDefaultMatcher(ArgumentsMatcher matcher) {
35  7 if (defaultMatcherSet) {
36  1 throw new RuntimeExceptionWrapper(
37    new IllegalStateException(
38    "default matcher can only be set once directly after creation of the MockControl"));
39    }
40  6 defaultMatcher = matcher;
41  6 defaultMatcherSet = true;
42    }
43   
 
44  13 toggle public void setMatcher(Method method, ArgumentsMatcher matcher) {
45  13 if (matchers.containsKey(method) && matchers.get(method) != matcher) {
46  2 throw new RuntimeExceptionWrapper(new IllegalStateException(
47    "for method "
48    + method.getName()
49    + "("
50  2 + (method.getParameterTypes().length == 0 ? ""
51    : "...")
52    + "), a matcher has already been set"));
53    }
54  11 matchers.put(method, matcher);
55    }
56    }