KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > easymock > tests > UsageVarargTest


1 /*
2  * Copyright (c) 2001-2005 OFFIS. This program is made available under the terms of
3  * the MIT License.
4  */

5 package org.easymock.tests;
6
7 import junit.framework.TestCase;
8
9 import org.easymock.MockControl;
10
11 public class UsageVarargTest extends TestCase {
12
13     MockControl<IVarArgs> control;
14
15     IVarArgs mock;
16
17     protected void setUp() {
18         control = MockControl.createStrictControl(IVarArgs.class);
19         mock = control.getMock();
20     }
21
22     public void testVarargObjectAccepted() {
23         mock.withVarargsString(1, "1");
24         mock.withVarargsString(2, "1", "2");
25         mock.withVarargsObject(3, "1");
26         mock.withVarargsObject(4, "1", "2");
27
28         control.replay();
29         mock.withVarargsString(1, "1");
30         mock.withVarargsString(2, "1", "2");
31         mock.withVarargsObject(3, "1");
32         mock.withVarargsObject(4, "1", "2");
33         control.verify();
34     }
35
36     public void testVarargBooleanAccepted() {
37         mock.withVarargsBoolean(1, true);
38         mock.withVarargsBoolean(2, true, false);
39
40         control.replay();
41         mock.withVarargsBoolean(1, true);
42         mock.withVarargsBoolean(2, true, false);
43         control.verify();
44     }
45
46     public void testVarargByteAccepted() {
47         mock.withVarargsByte(1, (byte) 1);
48         mock.withVarargsByte(2, (byte) 1, (byte) 2);
49
50         control.replay();
51         mock.withVarargsByte(1, (byte) 1);
52         mock.withVarargsByte(2, (byte) 1, (byte) 2);
53         control.verify();
54     }
55
56     public void testVarargCharAccepted() {
57         mock.withVarargsChar(1, 'a');
58         mock.withVarargsChar(1, 'a', 'b');
59
60         control.replay();
61         mock.withVarargsChar(1, 'a');
62         mock.withVarargsChar(1, 'a', 'b');
63         control.verify();
64     }
65
66     public void testVarargDoubleAccepted() {
67         mock.withVarargsDouble(1, 1.0d);
68         mock.withVarargsDouble(1, 1.0d, 2.0d);
69
70         control.replay();
71         mock.withVarargsDouble(1, 1.0d);
72         mock.withVarargsDouble(1, 1.0d, 2.0d);
73         control.verify();
74     }
75
76     public void testVarargFloatAccepted() {
77         mock.withVarargsFloat(1, 1.0f);
78         mock.withVarargsFloat(1, 1.0f, 2.0f);
79
80         control.replay();
81         mock.withVarargsFloat(1, 1.0f);
82         mock.withVarargsFloat(1, 1.0f, 2.0f);
83         control.verify();
84     }
85
86     public void testVarargIntAccepted() {
87         mock.withVarargsInt(1, 1);
88         mock.withVarargsInt(1, 1, 2);
89
90         control.replay();
91         mock.withVarargsInt(1, 1);
92         mock.withVarargsInt(1, 1, 2);
93         control.verify();
94     }
95
96     public void testVarargLongAccepted() {
97         mock.withVarargsLong(1, (long) 1);
98         mock.withVarargsLong(1, (long) 1, (long) 2);
99
100         control.replay();
101         mock.withVarargsLong(1, (long) 1);
102         mock.withVarargsLong(1, (long) 1, (long) 2);
103         control.verify();
104     }
105
106     public void testVarargShortAccepted() {
107         mock.withVarargsShort(1, (short) 1);
108         mock.withVarargsShort(1, (short) 1, (short) 2);
109
110         control.replay();
111         mock.withVarargsShort(1, (short) 1);
112         mock.withVarargsShort(1, (short) 1, (short) 2);
113         control.verify();
114     }
115 }
Popular Tags