| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
package org.easymock.tests; |
| 6 |
|
|
| 7 |
|
import java.lang.reflect.InvocationHandler; |
| 8 |
|
import java.lang.reflect.Method; |
| 9 |
|
import java.lang.reflect.Proxy; |
| 10 |
|
|
| 11 |
|
import org.easymock.MockControl; |
| 12 |
|
import org.junit.Before; |
| 13 |
|
import org.junit.Test; |
| 14 |
|
|
| 15 |
|
@SuppressWarnings("deprecation") |
|
|
|
| 100% |
Uncovered Elements: 0 (82) |
Complexity: 12 |
Complexity Density: 0,17 |
|
| 16 |
|
public class UsageVarargTest { |
| 17 |
|
|
| 18 |
|
MockControl<IVarArgs> control; |
| 19 |
|
|
| 20 |
|
IVarArgs mock; |
| 21 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 22 |
10
|
@Before... |
| 23 |
|
public void setup() { |
| 24 |
10
|
control = MockControl.createStrictControl(IVarArgs.class); |
| 25 |
10
|
mock = control.getMock(); |
| 26 |
|
} |
| 27 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
| 28 |
1
|
@Test... |
| 29 |
|
public void varargObjectAccepted() { |
| 30 |
1
|
mock.withVarargsString(1, "1"); |
| 31 |
1
|
mock.withVarargsString(2, "1", "2"); |
| 32 |
1
|
mock.withVarargsString(2, "1", "2"); |
| 33 |
1
|
mock.withVarargsObject(3, "1"); |
| 34 |
1
|
mock.withVarargsObject(4, "1", "2"); |
| 35 |
|
|
| 36 |
1
|
control.replay(); |
| 37 |
1
|
mock.withVarargsString(1, "1"); |
| 38 |
1
|
mock.withVarargsString(2, "1", "2"); |
| 39 |
1
|
mock.withVarargsString(2, "1", "2"); |
| 40 |
1
|
mock.withVarargsObject(3, "1"); |
| 41 |
1
|
mock.withVarargsObject(4, "1", "2"); |
| 42 |
1
|
control.verify(); |
| 43 |
|
} |
| 44 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 45 |
1
|
@Test... |
| 46 |
|
public void varargBooleanAccepted() { |
| 47 |
1
|
mock.withVarargsBoolean(1, true); |
| 48 |
1
|
mock.withVarargsBoolean(2, true, false); |
| 49 |
|
|
| 50 |
1
|
control.replay(); |
| 51 |
1
|
mock.withVarargsBoolean(1, true); |
| 52 |
1
|
mock.withVarargsBoolean(2, true, false); |
| 53 |
1
|
control.verify(); |
| 54 |
|
} |
| 55 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 56 |
1
|
@Test... |
| 57 |
|
public void varargByteAccepted() { |
| 58 |
1
|
mock.withVarargsByte(1, (byte) 1); |
| 59 |
1
|
mock.withVarargsByte(2, (byte) 1, (byte) 2); |
| 60 |
|
|
| 61 |
1
|
control.replay(); |
| 62 |
1
|
mock.withVarargsByte(1, (byte) 1); |
| 63 |
1
|
mock.withVarargsByte(2, (byte) 1, (byte) 2); |
| 64 |
1
|
control.verify(); |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 67 |
1
|
@Test... |
| 68 |
|
public void varargCharAccepted() { |
| 69 |
1
|
mock.withVarargsChar(1, 'a'); |
| 70 |
1
|
mock.withVarargsChar(1, 'a', 'b'); |
| 71 |
|
|
| 72 |
1
|
control.replay(); |
| 73 |
1
|
mock.withVarargsChar(1, 'a'); |
| 74 |
1
|
mock.withVarargsChar(1, 'a', 'b'); |
| 75 |
1
|
control.verify(); |
| 76 |
|
} |
| 77 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 78 |
1
|
@Test... |
| 79 |
|
public void varargDoubleAccepted() { |
| 80 |
1
|
mock.withVarargsDouble(1, 1.0d); |
| 81 |
1
|
mock.withVarargsDouble(1, 1.0d, 2.0d); |
| 82 |
|
|
| 83 |
1
|
control.replay(); |
| 84 |
1
|
mock.withVarargsDouble(1, 1.0d); |
| 85 |
1
|
mock.withVarargsDouble(1, 1.0d, 2.0d); |
| 86 |
1
|
control.verify(); |
| 87 |
|
} |
| 88 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 89 |
1
|
@Test... |
| 90 |
|
public void varargFloatAccepted() { |
| 91 |
1
|
mock.withVarargsFloat(1, 1.0f); |
| 92 |
1
|
mock.withVarargsFloat(1, 1.0f, 2.0f); |
| 93 |
|
|
| 94 |
1
|
control.replay(); |
| 95 |
1
|
mock.withVarargsFloat(1, 1.0f); |
| 96 |
1
|
mock.withVarargsFloat(1, 1.0f, 2.0f); |
| 97 |
1
|
control.verify(); |
| 98 |
|
} |
| 99 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 100 |
1
|
@Test... |
| 101 |
|
public void varargIntAccepted() { |
| 102 |
1
|
mock.withVarargsInt(1, 1); |
| 103 |
1
|
mock.withVarargsInt(1, 1, 2); |
| 104 |
|
|
| 105 |
1
|
control.replay(); |
| 106 |
1
|
mock.withVarargsInt(1, 1); |
| 107 |
1
|
mock.withVarargsInt(1, 1, 2); |
| 108 |
1
|
control.verify(); |
| 109 |
|
} |
| 110 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 111 |
1
|
@Test... |
| 112 |
|
public void varargLongAccepted() { |
| 113 |
1
|
mock.withVarargsLong(1, (long) 1); |
| 114 |
1
|
mock.withVarargsLong(1, 1, 2); |
| 115 |
|
|
| 116 |
1
|
control.replay(); |
| 117 |
1
|
mock.withVarargsLong(1, (long) 1); |
| 118 |
1
|
mock.withVarargsLong(1, 1, 2); |
| 119 |
1
|
control.verify(); |
| 120 |
|
} |
| 121 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
| 122 |
1
|
@Test... |
| 123 |
|
public void varargShortAccepted() { |
| 124 |
1
|
mock.withVarargsShort(1, (short) 1); |
| 125 |
1
|
mock.withVarargsShort(1, (short) 1, (short) 2); |
| 126 |
|
|
| 127 |
1
|
control.replay(); |
| 128 |
1
|
mock.withVarargsShort(1, (short) 1); |
| 129 |
1
|
mock.withVarargsShort(1, (short) 1, (short) 2); |
| 130 |
1
|
control.verify(); |
| 131 |
|
} |
| 132 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
1
PASS
|
|
| 133 |
1
|
@Test... |
| 134 |
|
public void varargAcceptedIfArrayIsGiven() { |
| 135 |
1
|
IVarArgs object = (IVarArgs) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { IVarArgs.class }, new InvocationHandler() { |
| 136 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 137 |
6
|
public Object invoke(Object proxy, Method method, Object[] args)... |
| 138 |
|
throws Throwable { |
| 139 |
6
|
return null; |
| 140 |
|
} |
| 141 |
|
}); |
| 142 |
1
|
object.withVarargsObject(1); |
| 143 |
1
|
object.withVarargsObject(1, (Object) null); |
| 144 |
1
|
object.withVarargsObject(1, (Object[]) null); |
| 145 |
1
|
object.withVarargsObject(1, (Object[]) new Object[0] ); |
| 146 |
1
|
object.withVarargsObject(1, false); |
| 147 |
1
|
object.withVarargsObject(1, new boolean[] {true, false}); |
| 148 |
|
} |
| 149 |
|
} |