Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
14   92   11   1,27
0   55   0,79   5,5
11     1  
2    
 
  ConstructorArgsTest       Line # 27 14 0% 10 0 100% 1.0
  ConstructorArgsTest.A       Line # 31 0 0% 1 0 100% 1.0
 
  (18)
 
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.tests2;
18   
19    import static org.junit.Assert.*;
20   
21    import org.easymock.ConstructorArgs;
22    import org.junit.Test;
23   
24    /**
25    * @author Henri Tremblay
26    */
 
27    public class ConstructorArgsTest {
28   
29    public final Class<?> TYPE = null;
30   
 
31    public static class A {
32   
33    private static final Class<?> TYPE = null;
34   
 
35  2 toggle public A(final String s, final int i) {
36    }
37    }
38   
 
39  2 toggle @Test
40    public void testConstructorArgs() {
41  2 final ConstructorArgs args = new ConstructorArgs(A.class.getConstructors()[0], "a", 4);
42  2 checkArgs(args);
43    }
44   
 
45  2 toggle private void checkArgs(final ConstructorArgs args) {
46  2 assertEquals(2, args.getInitArgs().length);
47  2 assertEquals("a", args.getInitArgs()[0]);
48  2 assertEquals(4, args.getInitArgs()[1]);
49   
50  2 assertEquals(A.class.getConstructors()[0], args.getConstructor());
51    }
52   
 
53  2 toggle @Test(expected = IllegalArgumentException.class)
54    public void testConstructorArgs_WrongArgument() {
55  2 new ConstructorArgs(A.class.getConstructors()[0], "a", "b");
56    }
57   
 
58  2 toggle @Test(expected = IllegalArgumentException.class)
59    public void testConstructorArgs_NullPrimitive() {
60  2 new ConstructorArgs(A.class.getConstructors()[0], "a", null);
61    }
62   
 
63  2 toggle @Test(expected = IllegalArgumentException.class)
64    public void testConstructorArgs_PrimitiveForObject() {
65  2 new ConstructorArgs(A.class.getConstructors()[0], 1, 2);
66    }
67   
 
68  2 toggle @Test
69    public void testConstructorArgs_NullObject() {
70  2 new ConstructorArgs(A.class.getConstructors()[0], null, 2);
71    }
72   
 
73  2 toggle @Test(expected = IllegalArgumentException.class)
74    public void testConstructorArgs_WrongPrimitive() {
75  2 new ConstructorArgs(A.class.getConstructors()[0], "a", 2.0f);
76    }
77   
 
78  2 toggle @Test(expected = IllegalArgumentException.class)
79    public void testConstructorArgs_WrongNumberOfArgs() {
80  2 new ConstructorArgs(A.class.getConstructors()[0], "a");
81    }
82   
 
83  2 toggle @Test(expected = IllegalArgumentException.class)
84    public void testConstructorArgs_TypeExistsButPrivate() {
85  2 new ConstructorArgs(A.class.getConstructors()[0], "a", new A(null, 1));
86    }
87   
 
88  2 toggle @Test(expected = IllegalArgumentException.class)
89    public void testConstructorArgs_TypeExistsButNotStatic() {
90  2 new ConstructorArgs(A.class.getConstructors()[0], "a", new ConstructorArgsTest());
91    }
92    }