1 5 package org.easymock.tests; 6 7 import junit.framework.TestCase; 8 9 import org.easymock.MockControl; 10 11 public class RecordStateMethodCallMissingTest extends TestCase { 12 MockControl<IMethods> control; 13 14 IMethods mock; 15 16 protected void setUp() { 17 control = MockControl.createControl(IMethods.class); 18 mock = control.getMock(); 19 } 20 21 public void testSetBooleanReturnValueWithoutMethodCall() { 22 try { 23 control.setReturnValue(false); 24 fail("IllegalStateException expected"); 25 } catch (IllegalStateException expected) { 26 assertEquals( 27 "method call on the mock needed before setting return value", 28 expected.getMessage()); 29 } 30 } 31 32 public void testSetLongReturnValueWithoutMethodCall() { 33 try { 34 control.setReturnValue(0); 35 fail("IllegalStateException expected"); 36 } catch (IllegalStateException expected) { 37 assertEquals( 38 "method call on the mock needed before setting return value", 39 expected.getMessage()); 40 } 41 } 42 43 public void testSetFloatReturnValueWithoutMethodCall() { 44 try { 45 control.setReturnValue((float) 0.0); 46 fail("IllegalStateException expected"); 47 } catch (IllegalStateException expected) { 48 assertEquals( 49 "method call on the mock needed before setting return value", 50 expected.getMessage()); 51 } 52 } 53 54 public void testSetDoubleReturnValueWithoutMethodCall() { 55 try { 56 control.setReturnValue(0.0); 57 fail("IllegalStateException expected"); 58 } catch (IllegalStateException expected) { 59 assertEquals( 60 "method call on the mock needed before setting return value", 61 expected.getMessage()); 62 } 63 } 64 65 public void testSetObjectReturnValueWithoutMethodCall() { 66 try { 67 control.setReturnValue(null); 68 fail("IllegalStateException expected"); 69 } catch (IllegalStateException expected) { 70 assertEquals( 71 "method call on the mock needed before setting return value", 72 expected.getMessage()); 73 } 74 } 75 76 public void testSetVoidCallableWithoutMethodCall() { 77 try { 78 control.setVoidCallable(); 79 fail("IllegalStateException expected"); 80 } catch (IllegalStateException expected) { 81 assertEquals( 82 "method call on the mock needed before setting void callable", 83 expected.getMessage()); 84 } 85 } 86 87 public void testSetThrowableWithoutMethodCall() { 88 try { 89 control.setThrowable(new RuntimeException ()); 90 fail("IllegalStateException expected"); 91 } catch (IllegalStateException expected) { 92 assertEquals( 93 "method call on the mock needed before setting Throwable", 94 expected.getMessage()); 95 } 96 } 97 98 public void testSetBooleanReturnValueCountWithoutMethodCall() { 99 try { 100 control.setReturnValue(false, 3); 101 fail("IllegalStateException expected"); 102 } catch (IllegalStateException expected) { 103 assertEquals( 104 "method call on the mock needed before setting return value", 105 expected.getMessage()); 106 } 107 } 108 109 public void testSetLongReturnValueCountWithoutMethodCall() { 110 try { 111 control.setReturnValue(0, 3); 112 fail("IllegalStateException expected"); 113 } catch (IllegalStateException expected) { 114 assertEquals( 115 "method call on the mock needed before setting return value", 116 expected.getMessage()); 117 } 118 } 119 120 public void testSetFloatReturnValueCountWithoutMethodCall() { 121 try { 122 control.setReturnValue((float) 0.0, 3); 123 fail("IllegalStateException expected"); 124 } catch (IllegalStateException expected) { 125 assertEquals( 126 "method call on the mock needed before setting return value", 127 expected.getMessage()); 128 } 129 } 130 131 public void testSetDoubleReturnValueCountWithoutMethodCall() { 132 try { 133 control.setReturnValue(0.0, 3); 134 fail("IllegalStateException expected"); 135 } catch (IllegalStateException expected) { 136 assertEquals( 137 "method call on the mock needed before setting return value", 138 expected.getMessage()); 139 } 140 } 141 142 public void testSetObjectReturnValueCountWithoutMethodCall() { 143 try { 144 control.setReturnValue(null, 3); 145 fail("IllegalStateException expected"); 146 } catch (IllegalStateException expected) { 147 assertEquals( 148 "method call on the mock needed before setting return value", 149 expected.getMessage()); 150 } 151 } 152 153 public void testSetVoidCallableCountWithoutMethodCall() { 154 try { 155 control.setVoidCallable(3); 156 fail("IllegalStateException expected"); 157 } catch (IllegalStateException expected) { 158 assertEquals( 159 "method call on the mock needed before setting void callable", 160 expected.getMessage()); 161 } 162 } 163 164 public void testSetThrowableCountWithoutMethodCall() { 165 try { 166 control.setThrowable(new RuntimeException (), 3); 167 fail("IllegalStateException expected"); 168 } catch (IllegalStateException expected) { 169 assertEquals( 170 "method call on the mock needed before setting Throwable", 171 expected.getMessage()); 172 } 173 } 174 175 public void testSetBooleanDefaultReturnValueWithoutMethodCall() { 176 try { 177 control.setDefaultReturnValue(false); 178 fail("IllegalStateException expected"); 179 } catch (IllegalStateException expected) { 180 assertEquals( 181 "method call on the mock needed before setting default return value", 182 expected.getMessage()); 183 } 184 } 185 186 public void testSetLongDefaultReturnValueWithoutMethodCall() { 187 try { 188 control.setDefaultReturnValue(0); 189 fail("IllegalStateException expected"); 190 } catch (IllegalStateException expected) { 191 assertEquals( 192 "method call on the mock needed before setting default return value", 193 expected.getMessage()); 194 } 195 } 196 197 public void testSetFloatDefaultReturnValueWithoutMethodCall() { 198 try { 199 control.setDefaultReturnValue((float) 0.0); 200 fail("IllegalStateException expected"); 201 } catch (IllegalStateException expected) { 202 assertEquals( 203 "method call on the mock needed before setting default return value", 204 expected.getMessage()); 205 } 206 } 207 208 public void testSetDoubleDefaultReturnValueWithoutMethodCall() { 209 try { 210 control.setDefaultReturnValue(0.0); 211 fail("IllegalStateException expected"); 212 } catch (IllegalStateException expected) { 213 assertEquals( 214 "method call on the mock needed before setting default return value", 215 expected.getMessage()); 216 } 217 } 218 219 public void testSetObjectDefaultReturnValueWithoutMethodCall() { 220 try { 221 control.setDefaultReturnValue(null); 222 fail("IllegalStateException expected"); 223 } catch (IllegalStateException expected) { 224 assertEquals( 225 "method call on the mock needed before setting default return value", 226 expected.getMessage()); 227 } 228 } 229 230 public void testSetDefaultVoidCallableWithoutMethodCall() { 231 try { 232 control.setDefaultVoidCallable(); 233 fail("IllegalStateException expected"); 234 } catch (IllegalStateException expected) { 235 assertEquals( 236 "method call on the mock needed before setting default void callable", 237 expected.getMessage()); 238 } 239 } 240 241 public void testSetDefaultThrowableWithoutMethodCall() { 242 try { 243 control.setDefaultThrowable(new RuntimeException ()); 244 fail("IllegalStateException expected"); 245 } catch (IllegalStateException expected) { 246 assertEquals( 247 "method call on the mock needed before setting default Throwable", 248 expected.getMessage()); 249 } 250 } 251 252 } 253
| Popular Tags
|