Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
../../../img/srcFileCovDistChart10.png 0% of files have more coverage
23   82   6   7,67
6   46   0,26   3
3     2  
1    
 
  MethodSerializationWrapper       Line # 27 23 0% 6 0 100% 1.0
 
  (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.internal;
18   
19    import java.io.Serializable;
20    import java.lang.reflect.Method;
21    import java.util.HashMap;
22    import java.util.Map;
23   
24    /**
25    * @author Henri Tremblay
26    */
 
27    public class MethodSerializationWrapper implements Serializable {
28   
29    private static final long serialVersionUID = 1775475200823842126L;
30   
31    private static final Map<String, Class<?>> primitiveTypes = new HashMap<String, Class<?>>(10);
32   
 
33  2 toggle static {
34  2 primitiveTypes.put(Boolean.TYPE.getName(), Boolean.TYPE);
35  2 primitiveTypes.put(Byte.TYPE.getName(), Byte.TYPE);
36  2 primitiveTypes.put(Short.TYPE.getName(), Short.TYPE);
37  2 primitiveTypes.put(Character.TYPE.getName(), Character.TYPE);
38  2 primitiveTypes.put(Integer.TYPE.getName(), Integer.TYPE);
39  2 primitiveTypes.put(Long.TYPE.getName(), Long.TYPE);
40  2 primitiveTypes.put(Float.TYPE.getName(), Float.TYPE);
41  2 primitiveTypes.put(Double.TYPE.getName(), Double.TYPE);
42    }
43   
44    private final String className;
45   
46    private final String methodName;
47   
48    private final String[] parameterTypeNames;
49   
 
50  100 toggle public MethodSerializationWrapper(final Method m) {
51  100 className = m.getDeclaringClass().getName();
52  100 methodName = m.getName();
53   
54  100 final Class<?>[] parameterTypes = m.getParameterTypes();
55   
56  100 parameterTypeNames = new String[parameterTypes.length];
57   
58  154 for (int i = 0; i < parameterTypes.length; i++) {
59  54 parameterTypeNames[i] = parameterTypes[i].getName();
60    }
61    }
62   
 
63  100 toggle public Method getMethod() throws ClassNotFoundException, NoSuchMethodException {
64  100 final Class<?> clazz = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
65   
66  100 final Class<?>[] parameterTypes = new Class[parameterTypeNames.length];
67   
68  154 for (int i = 0; i < parameterTypeNames.length; i++) {
69  54 final Class<?> primitiveType = primitiveTypes.get(parameterTypeNames[i]);
70  54 if (primitiveType != null) {
71  22 parameterTypes[i] = primitiveType;
72    } else {
73  32 parameterTypes[i] = Class.forName(parameterTypeNames[i], true, Thread.currentThread()
74    .getContextClassLoader());
75    }
76    }
77   
78  100 final Method m = clazz.getMethod(methodName, parameterTypes);
79   
80  100 return m;
81    }
82    }