Source Code Cross Referenced for MockControl.java in  » Testing » mocquer » org » jingle » mocquer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » mocquer » org.jingle.mocquer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jingle.mocquer;
002:
003:        import java.util.Arrays;
004:
005:        import org.jingle.mocquer.internal.MockDelegationInvocationHandler;
006:        import org.jingle.mocquer.internal.NiceBehaviorSet;
007:        import org.jingle.mocquer.internal.NormalBehaviorSet;
008:        import org.jingle.mocquer.internal.StrictBehaviorSet;
009:        import org.jingle.util.dydelegation.DelegationGenerator;
010:        import org.jingle.util.dydelegation.Delegation;
011:
012:        /**
013:         * The controller of the mock object
014:         *
015:         * @author JianLu
016:         * @version 1.0 2004-10-26
017:         * @since 1.0
018:         */
019:        public class MockControl {
020:
021:            /*
022:             * Predefined argument matcher -- Always matches
023:             */
024:            public static final ArgumentsMatcher ALWAYS_MATCHER = new ArgumentsMatcher() {
025:                public boolean matches(java.lang.Object[] expected,
026:                        java.lang.Object[] actual) {
027:                    return true;
028:                }
029:            };
030:
031:            /*
032:             * Predefined argument matcher -- Applies eqauls() to each argument 
033:             */
034:            public static final ArgumentsMatcher EQUALS_MATCHER = new ArgumentsMatcher() {
035:                public boolean matches(java.lang.Object[] expected,
036:                        java.lang.Object[] actual) {
037:                    if (expected == null)
038:                        return true;
039:                    if (expected.length == actual.length) {
040:                        for (int i = 1; i <= expected.length; i++) {
041:                            if (expected[i - 1] instanceof  Delegation)
042:                                return expected[i - 1] == actual[i - 1];
043:                            if (!((expected[i - 1] == null) ? (actual[i - 1] == null)
044:                                    : expected[i - 1].equals(actual[i - 1])))
045:                                return false;
046:                        }
047:                        return true;
048:                    }
049:                    return false;
050:                }
051:            };
052:
053:            /*
054:             * Predefined argument matcher -- Applies Array.eqauls() to each array type argument 
055:             */
056:            public static final ArgumentsMatcher ARRAY_MATCHER = new ArgumentsMatcher() {
057:                public boolean matches(java.lang.Object[] expected,
058:                        java.lang.Object[] actual) {
059:                    if (expected == null)
060:                        return true;
061:                    if (expected.length == actual.length) {
062:                        for (int i = 1; i <= expected.length; i++) {
063:                            if (!((expected[i - 1] == null) ? (actual[i - 1] == null)
064:                                    : equals(expected[i - 1], actual[i - 1])))
065:                                return false;
066:                        }
067:                        return true;
068:                    }
069:                    return false;
070:                }
071:
072:                protected boolean equals(Object expected, Object actual) {
073:                    if (actual == null)
074:                        return false;
075:                    if (!expected.getClass().equals(actual.getClass()))
076:                        return false;
077:                    if (expected instanceof  Delegation)
078:                        return expected == actual;
079:                    if (!expected.getClass().isArray())
080:                        return expected.equals(actual);
081:                    if (expected instanceof  boolean[]) {
082:                        return Arrays.equals((boolean[]) expected,
083:                                (boolean[]) actual);
084:                    } else if (expected instanceof  byte[]) {
085:                        return Arrays
086:                                .equals((byte[]) expected, (byte[]) actual);
087:                    } else if (expected instanceof  char[]) {
088:                        return Arrays
089:                                .equals((char[]) expected, (char[]) actual);
090:                    } else if (expected instanceof  double[]) {
091:                        return Arrays.equals((double[]) expected,
092:                                (double[]) actual);
093:                    } else if (expected instanceof  float[]) {
094:                        return Arrays.equals((float[]) expected,
095:                                (float[]) actual);
096:                    } else if (expected instanceof  int[]) {
097:                        return Arrays.equals((int[]) expected, (int[]) actual);
098:                    } else if (expected instanceof  long[]) {
099:                        return Arrays
100:                                .equals((long[]) expected, (long[]) actual);
101:                    } else if (expected instanceof  short[]) {
102:                        return Arrays.equals((short[]) expected,
103:                                (short[]) actual);
104:                    } else if (expected instanceof  Object[]) {
105:                        return Arrays.equals((Object[]) expected,
106:                                (Object[]) actual);
107:                    } else {
108:                        return false;
109:                    }
110:                }
111:            };
112:
113:            /**
114:             * The mock object
115:             */
116:            Object mockObject = null;
117:
118:            /**
119:             * Protected constructor
120:             * @param mockObject The mock object
121:             */
122:            protected MockControl(Object mockObject) {
123:                this .mockObject = mockObject;
124:            }
125:
126:            /**
127:             * Create a normal mock control. This method only works for class with default constructor.
128:             * <p>It is same as <pre><code>createControl(clazz, new Class[0], new Object[0])</code></pre></p>
129:             * @param clazz The class to be mocked
130:             * @return MockControl object
131:             */
132:            public static MockControl createControl(Class clazz) {
133:                Object mockObject = DelegationGenerator.newDelegationInstance(
134:                        null, new Class[] { clazz }, (String) null,
135:                        new MockDelegationInvocationHandler(
136:                                new NormalBehaviorSet()));
137:                return new MockControl(mockObject);
138:            }
139:
140:            /**
141:             * Create a normal mock control
142:             * @param argTypes The constructor signature of the given class
143:             * @param args The constructor parameters of the given class
144:             * @param clazz The class to be mocked
145:             * @return MockControl object
146:             */
147:            public static MockControl createControl(Class clazz,
148:                    Class[] argTypes, Object[] args) {
149:                Object mockObject = DelegationGenerator.newDelegationInstance(
150:                        null, new Class[] { clazz }, (String) null, argTypes,
151:                        args, new MockDelegationInvocationHandler(
152:                                new NormalBehaviorSet()));
153:                return new MockControl(mockObject);
154:            }
155:
156:            /**
157:             * Create a nice mock control. This method only works for class with default constructor.
158:             * <p>It is same as <pre><code>createNiceControl(clazz, new Class[0], new Object[0])</code></pre></p>
159:             * @param clazz The class to be mocked
160:             * @return MockControl object
161:             */
162:            public static MockControl createNiceControl(Class clazz) {
163:                Object mockObject = DelegationGenerator.newDelegationInstance(
164:                        null, new Class[] { clazz }, (String) null,
165:                        new MockDelegationInvocationHandler(
166:                                new NiceBehaviorSet()));
167:                return new MockControl(mockObject);
168:            }
169:
170:            /**
171:             * Create a nice mock control.
172:             * @param clazz The class to be mocked
173:             * @param argTypes The constructor signature of the given class
174:             * @param args The constructor parameters of the given class
175:             * @return MockControl object
176:             */
177:            public static MockControl createNiceControl(Class clazz,
178:                    Class[] argTypes, Object[] args) {
179:                Object mockObject = DelegationGenerator.newDelegationInstance(
180:                        null, new Class[] { clazz }, (String) null, argTypes,
181:                        args, new MockDelegationInvocationHandler(
182:                                new NiceBehaviorSet()));
183:                return new MockControl(mockObject);
184:            }
185:
186:            /**
187:             * Create a strict mock control. This method only works for class with default constructor.
188:             * <p>It is same as <pre><code>createStrictControl(clazz, new Class[0], new Object[0])</code></pre></p>
189:             * @param clazz The class to be mocked
190:             * @return MockControl object
191:             */
192:            public static MockControl createStrictControl(Class clazz) {
193:                Object mockObject = DelegationGenerator.newDelegationInstance(
194:                        null, new Class[] { clazz }, (String) null,
195:                        new MockDelegationInvocationHandler(
196:                                new StrictBehaviorSet()));
197:                return new MockControl(mockObject);
198:            }
199:
200:            /**
201:             * Create a strict mock control
202:             * @param clazz The class to be mocked
203:             * @param argTypes The constructor signature of the given class
204:             * @param args The constructor parameters of the given class
205:             * @return MockControl object
206:             */
207:            public static MockControl createStrictControl(Class clazz,
208:                    Class[] argTypes, Object[] args) {
209:                Object mockObject = DelegationGenerator.newDelegationInstance(
210:                        null, new Class[] { clazz }, (String) null, argTypes,
211:                        args, new MockDelegationInvocationHandler(
212:                                new StrictBehaviorSet()));
213:                return new MockControl(mockObject);
214:            }
215:
216:            /**
217:             * Get the mock object
218:             * @return The mock object
219:             */
220:            public Object getMock() {
221:                return mockObject;
222:            }
223:
224:            /**
225:             * Replay the mock control
226:             * <p>All the behaviors defined are still valid<p>
227:             */
228:            public void replay() {
229:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
230:                        .getInvocationHandler(mockObject);
231:                handler.replay();
232:            }
233:
234:            /**
235:             * Reset the mock control
236:             * <p>All the behaviors defined will be erased<p>
237:             */
238:            public void reset() {
239:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
240:                        .getInvocationHandler(mockObject);
241:                handler.reset();
242:            }
243:
244:            /**
245:             * verify the mock control
246:             * <p>All the behaviors defined will be verified<p>
247:             */
248:            public void verify() {
249:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
250:                        .getInvocationHandler(mockObject);
251:                handler.verify();
252:            }
253:
254:            /**
255:             * Set the return value for last method call on the mock object
256:             * @param value The return value
257:             */
258:            public void setReturnValue(int value) {
259:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
260:                        .getInvocationHandler(mockObject);
261:                handler.setReturnValue(new Integer(value), Range.ONE_OR_MORE);
262:            }
263:
264:            /**
265:             * Set the return value for last method call on the mock object
266:             * @param value The return value
267:             */
268:            public void setReturnValue(boolean value) {
269:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
270:                        .getInvocationHandler(mockObject);
271:                handler.setReturnValue(new Boolean(value), Range.ONE_OR_MORE);
272:            }
273:
274:            /**
275:             * Set the return value for last method call on the mock object
276:             * @param value The return value
277:             */
278:            public void setReturnValue(char value) {
279:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
280:                        .getInvocationHandler(mockObject);
281:                handler.setReturnValue(new Character(value), Range.ONE_OR_MORE);
282:            }
283:
284:            /**
285:             * Set the return value for last method call on the mock object
286:             * @param value The return value
287:             */
288:            public void setReturnValue(short value) {
289:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
290:                        .getInvocationHandler(mockObject);
291:                handler.setReturnValue(new Short(value), Range.ONE_OR_MORE);
292:            }
293:
294:            /**
295:             * Set the return value for last method call on the mock object
296:             * @param value The return value
297:             */
298:            public void setReturnValue(byte value) {
299:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
300:                        .getInvocationHandler(mockObject);
301:                handler.setReturnValue(new Byte(value), Range.ONE_OR_MORE);
302:            }
303:
304:            /**
305:             * Set the return value for last method call on the mock object
306:             * @param value The return value
307:             */
308:            public void setReturnValue(long value) {
309:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
310:                        .getInvocationHandler(mockObject);
311:                handler.setReturnValue(new Long(value), Range.ONE_OR_MORE);
312:            }
313:
314:            /**
315:             * Set the return value for last method call on the mock object
316:             * @param value The return value
317:             */
318:            public void setReturnValue(float value) {
319:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
320:                        .getInvocationHandler(mockObject);
321:                handler.setReturnValue(new Float(value), Range.ONE_OR_MORE);
322:            }
323:
324:            /**
325:             * Set the return value for last method call on the mock object
326:             * @param value The return value
327:             */
328:            public void setReturnValue(double value) {
329:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
330:                        .getInvocationHandler(mockObject);
331:                handler.setReturnValue(new Double(value), Range.ONE_OR_MORE);
332:            }
333:
334:            /**
335:             * Set the return value for last method call on the mock object
336:             * @param value The return value
337:             */
338:            public void setReturnValue(Object value) {
339:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
340:                        .getInvocationHandler(mockObject);
341:                handler.setReturnValue(value, Range.ONE_OR_MORE);
342:            }
343:
344:            /**
345:             * Set default return value for last method call on the mock object
346:             * @param value The default return value
347:             */
348:            public void setDefaultReturnValue(int value) {
349:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
350:                        .getInvocationHandler(mockObject);
351:                handler.setDefaultReturnValue(new Integer(value));
352:            }
353:
354:            /**
355:             * Set default return value for last method call on the mock object
356:             * @param value The default return value
357:             */
358:            public void setDefaultReturnValue(boolean value) {
359:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
360:                        .getInvocationHandler(mockObject);
361:                handler.setDefaultReturnValue(new Boolean(value));
362:            }
363:
364:            /**
365:             * Set default return value for last method call on the mock object
366:             * @param value The default return value
367:             */
368:            public void setDefaultReturnValue(char value) {
369:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
370:                        .getInvocationHandler(mockObject);
371:                handler.setDefaultReturnValue(new Character(value));
372:            }
373:
374:            /**
375:             * Set default return value for last method call on the mock object
376:             * @param value The default return value
377:             */
378:            public void setDefaultReturnValue(short value) {
379:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
380:                        .getInvocationHandler(mockObject);
381:                handler.setDefaultReturnValue(new Short(value));
382:            }
383:
384:            /**
385:             * Set default return value for last method call on the mock object
386:             * @param value The default return value
387:             */
388:            public void setDefaultReturnValue(byte value) {
389:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
390:                        .getInvocationHandler(mockObject);
391:                handler.setDefaultReturnValue(new Byte(value));
392:            }
393:
394:            /**
395:             * Set default return value for last method call on the mock object
396:             * @param value The default return value
397:             */
398:            public void setDefaultReturnValue(float value) {
399:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
400:                        .getInvocationHandler(mockObject);
401:                handler.setDefaultReturnValue(new Float(value));
402:            }
403:
404:            /**
405:             * Set default return value for last method call on the mock object
406:             * @param value The default return value
407:             */
408:            public void setDefaultReturnValue(double value) {
409:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
410:                        .getInvocationHandler(mockObject);
411:                handler.setDefaultReturnValue(new Double(value));
412:            }
413:
414:            /**
415:             * Set default return value for last method call on the mock object
416:             * @param value The default return value
417:             */
418:            public void setDefaultReturnValue(long value) {
419:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
420:                        .getInvocationHandler(mockObject);
421:                handler.setDefaultReturnValue(new Long(value));
422:            }
423:
424:            /**
425:             * Set default return value for last method call on the mock object
426:             * @param value The default return value
427:             */
428:            public void setDefaultReturnValue(Object value) {
429:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
430:                        .getInvocationHandler(mockObject);
431:                handler.setDefaultReturnValue(value);
432:            }
433:
434:            /**
435:             * Set throwable object for last method call on the mock object
436:             * @param throwable The throwable object
437:             */
438:            public void setThrowable(Throwable throwable) {
439:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
440:                        .getInvocationHandler(mockObject);
441:                handler.setThrowable(throwable, Range.ONE_OR_MORE);
442:            }
443:
444:            /**
445:             * Set default throwable object for last method call on the mock object
446:             * @param throwable The throwable object
447:             */
448:            public void setDefaultThrowable(Throwable throwable) {
449:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
450:                        .getInvocationHandler(mockObject);
451:                handler.setDefaultThrowable(throwable);
452:            }
453:
454:            /**
455:             * Indicate that method call on the mock object has no return value
456:             */
457:            public void setVoidCallable() {
458:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
459:                        .getInvocationHandler(mockObject);
460:                handler.setVoidCallable(Range.ONE_OR_MORE);
461:            }
462:
463:            /**
464:             * Indicate that method call on the mock object defaultly has no return value
465:             */
466:            public void setDefaultVoidCallable() {
467:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
468:                        .getInvocationHandler(mockObject);
469:                handler.setDefaultVoidCallable();
470:            }
471:
472:            /**
473:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
474:             * @param value The return value
475:             * @param times The times limitation of the call occurrence
476:             */
477:            public void setReturnValue(int value, int times) {
478:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
479:                        .getInvocationHandler(mockObject);
480:                handler.setReturnValue(new Integer(value), new Range(times));
481:            }
482:
483:            /**
484:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
485:             * @param value The return value
486:             * @param times The times limitation of the call occurrence
487:             */
488:            public void setReturnValue(boolean value, int times) {
489:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
490:                        .getInvocationHandler(mockObject);
491:                handler.setReturnValue(new Boolean(value), new Range(times));
492:            }
493:
494:            /**
495:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
496:             * @param value The return value
497:             * @param times The times limitation of the call occurrence
498:             */
499:            public void setReturnValue(char value, int times) {
500:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
501:                        .getInvocationHandler(mockObject);
502:                handler.setReturnValue(new Character(value), new Range(times));
503:            }
504:
505:            /**
506:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
507:             * @param value The return value
508:             * @param times The times limitation of the call occurrence
509:             */
510:            public void setReturnValue(short value, int times) {
511:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
512:                        .getInvocationHandler(mockObject);
513:                handler.setReturnValue(new Short(value), new Range(times));
514:            }
515:
516:            /**
517:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
518:             * @param value The return value
519:             * @param times The times limitation of the call occurrence
520:             */
521:            public void setReturnValue(byte value, int times) {
522:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
523:                        .getInvocationHandler(mockObject);
524:                handler.setReturnValue(new Byte(value), new Range(times));
525:            }
526:
527:            /**
528:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
529:             * @param value The return value
530:             * @param times The times limitation of the call occurrence
531:             */
532:            public void setReturnValue(long value, int times) {
533:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
534:                        .getInvocationHandler(mockObject);
535:                handler.setReturnValue(new Long(value), new Range(times));
536:            }
537:
538:            /**
539:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
540:             * @param value The return value
541:             * @param times The times limitation of the call occurrence
542:             */
543:            public void setReturnValue(float value, int times) {
544:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
545:                        .getInvocationHandler(mockObject);
546:                handler.setReturnValue(new Float(value), new Range(times));
547:            }
548:
549:            /**
550:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
551:             * @param value The return value
552:             * @param times The times limitation of the call occurrence
553:             */
554:            public void setReturnValue(double value, int times) {
555:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
556:                        .getInvocationHandler(mockObject);
557:                handler.setReturnValue(new Double(value), new Range(times));
558:            }
559:
560:            /**
561:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
562:             * @param value The return value
563:             * @param times The times limitation of the call occurrence
564:             */
565:            public void setReturnValue(Object value, int times) {
566:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
567:                        .getInvocationHandler(mockObject);
568:                handler.setReturnValue(value, new Range(times));
569:            }
570:
571:            /**
572:             * Set throwable object for last method call on the mock object with a times limitation of the call occurrence
573:             * @param throwable The throwable object
574:             * @param times The times limitation of the call occurrence
575:             */
576:            public void setThrowable(Throwable throwable, int times) {
577:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
578:                        .getInvocationHandler(mockObject);
579:                handler.setThrowable(throwable, new Range(times));
580:            }
581:
582:            /**
583:             * Indicate that method call on the mock object has no return value with a times limitation of the call occurrence
584:             * @param times The times limitation of the call occurrence
585:             */
586:            public void setVoidCallable(int times) {
587:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
588:                        .getInvocationHandler(mockObject);
589:                handler.setVoidCallable(new Range(times));
590:            }
591:
592:            /**
593:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
594:             * @param value The return value
595:             * @param min The minimum times limitation of the call occurrence
596:             * @param max The maxmum times limitation of the call occurrence
597:             */
598:            public void setReturnValue(int value, int min, int max) {
599:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
600:                        .getInvocationHandler(mockObject);
601:                handler.setReturnValue(new Integer(value), new Range(min, max));
602:            }
603:
604:            /**
605:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
606:             * @param value The return value
607:             * @param min The minimum times limitation of the call occurrence
608:             * @param max The maxmum times limitation of the call occurrence
609:             */
610:            public void setReturnValue(boolean value, int min, int max) {
611:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
612:                        .getInvocationHandler(mockObject);
613:                handler.setReturnValue(new Boolean(value), new Range(min, max));
614:            }
615:
616:            /**
617:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
618:             * @param value The return value
619:             * @param min The minimum times limitation of the call occurrence
620:             * @param max The maxmum times limitation of the call occurrence
621:             */
622:            public void setReturnValue(char value, int min, int max) {
623:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
624:                        .getInvocationHandler(mockObject);
625:                handler.setReturnValue(new Character(value),
626:                        new Range(min, max));
627:            }
628:
629:            /**
630:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
631:             * @param value The return value
632:             * @param min The minimum times limitation of the call occurrence
633:             * @param max The maxmum times limitation of the call occurrence
634:             */
635:            public void setReturnValue(short value, int min, int max) {
636:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
637:                        .getInvocationHandler(mockObject);
638:                handler.setReturnValue(new Short(value), new Range(min, max));
639:            }
640:
641:            /**
642:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
643:             * @param value The return value
644:             * @param min The minimum times limitation of the call occurrence
645:             * @param max The maxmum times limitation of the call occurrence
646:             */
647:            public void setReturnValue(byte value, int min, int max) {
648:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
649:                        .getInvocationHandler(mockObject);
650:                handler.setReturnValue(new Byte(value), new Range(min, max));
651:            }
652:
653:            /**
654:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
655:             * @param value The return value
656:             * @param min The minimum times limitation of the call occurrence
657:             * @param max The maxmum times limitation of the call occurrence
658:             */
659:            public void setReturnValue(long value, int min, int max) {
660:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
661:                        .getInvocationHandler(mockObject);
662:                handler.setReturnValue(new Long(value), new Range(min, max));
663:            }
664:
665:            /**
666:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
667:             * @param value The return value
668:             * @param min The minimum times limitation of the call occurrence
669:             * @param max The maxmum times limitation of the call occurrence
670:             */
671:            public void setReturnValue(float value, int min, int max) {
672:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
673:                        .getInvocationHandler(mockObject);
674:                handler.setReturnValue(new Float(value), new Range(min, max));
675:            }
676:
677:            /**
678:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
679:             * @param value The return value
680:             * @param min The minimum times limitation of the call occurrence
681:             * @param max The maxmum times limitation of the call occurrence
682:             */
683:            public void setReturnValue(double value, int min, int max) {
684:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
685:                        .getInvocationHandler(mockObject);
686:                handler.setReturnValue(new Double(value), new Range(min, max));
687:            }
688:
689:            /**
690:             * Set return value for last method call on the mock object with a times limitation of the call occurrence
691:             * @param value The return value
692:             * @param min The minimum times limitation of the call occurrence
693:             * @param max The maxmum times limitation of the call occurrence
694:             */
695:            public void setReturnValue(Object value, int min, int max) {
696:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
697:                        .getInvocationHandler(mockObject);
698:                handler.setReturnValue(value, new Range(min, max));
699:            }
700:
701:            /**
702:             * Set throwable object for last method call on the mock object with a times limitation of the call occurrence
703:             * @param throwable The throwable object
704:             * @param min The minimum times limitation of the call occurrence
705:             * @param max The maxmum times limitation of the call occurrence
706:             */
707:            public void setThrowable(Throwable throwable, int min, int max) {
708:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
709:                        .getInvocationHandler(mockObject);
710:                handler.setThrowable(throwable, new Range(min, max));
711:            }
712:
713:            /**
714:             * Indicate that last method call on the mock object has no return value with a times limitation of the call occurrence
715:             * @param min The minimum times limitation of the call occurrence
716:             * @param max The maxmum times limitation of the call occurrence
717:             */
718:            public void setVoidCallable(int min, int max) {
719:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
720:                        .getInvocationHandler(mockObject);
721:                handler.setVoidCallable(new Range(min, max));
722:            }
723:
724:            /**
725:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
726:             * @param value The return value
727:             * @param range The range limitation of the call occurrence
728:             */
729:            public void setReturnValue(int value, Range range) {
730:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
731:                        .getInvocationHandler(mockObject);
732:                handler.setReturnValue(new Integer(value), range);
733:            }
734:
735:            /**
736:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
737:             * @param value The return value
738:             * @param range The range limitation of the call occurrence
739:             */
740:            public void setReturnValue(boolean value, Range range) {
741:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
742:                        .getInvocationHandler(mockObject);
743:                handler.setReturnValue(new Boolean(value), range);
744:            }
745:
746:            /**
747:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
748:             * @param value The return value
749:             * @param range The range limitation of the call occurrence
750:             */
751:            public void setReturnValue(char value, Range range) {
752:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
753:                        .getInvocationHandler(mockObject);
754:                handler.setReturnValue(new Character(value), range);
755:            }
756:
757:            /**
758:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
759:             * @param value The return value
760:             * @param range The range limitation of the call occurrence
761:             */
762:            public void setReturnValue(short value, Range range) {
763:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
764:                        .getInvocationHandler(mockObject);
765:                handler.setReturnValue(new Short(value), range);
766:            }
767:
768:            /**
769:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
770:             * @param value The return value
771:             * @param range The range limitation of the call occurrence
772:             */
773:            public void setReturnValue(byte value, Range range) {
774:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
775:                        .getInvocationHandler(mockObject);
776:                handler.setReturnValue(new Byte(value), range);
777:            }
778:
779:            /**
780:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
781:             * @param value The return value
782:             * @param range The range limitation of the call occurrence
783:             */
784:            public void setReturnValue(long value, Range range) {
785:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
786:                        .getInvocationHandler(mockObject);
787:                handler.setReturnValue(new Long(value), range);
788:            }
789:
790:            /**
791:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
792:             * @param value The return value
793:             * @param range The range limitation of the call occurrence
794:             */
795:            public void setReturnValue(float value, Range range) {
796:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
797:                        .getInvocationHandler(mockObject);
798:                handler.setReturnValue(new Float(value), range);
799:            }
800:
801:            /**
802:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
803:             * @param value The return value
804:             * @param range The range limitation of the call occurrence
805:             */
806:            public void setReturnValue(double value, Range range) {
807:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
808:                        .getInvocationHandler(mockObject);
809:                handler.setReturnValue(new Double(value), range);
810:            }
811:
812:            /**
813:             * Set return value for last method call on the mock object with a range limitation of the call occurrence
814:             * @param value The return value
815:             * @param range The range limitation of the call occurrence
816:             */
817:            public void setReturnValue(Object value, Range range) {
818:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
819:                        .getInvocationHandler(mockObject);
820:                handler.setReturnValue(value, range);
821:            }
822:
823:            /**
824:             * Set throwable object for last method call on the mock object with a range limitation of the call occurrence
825:             * @param throwable The throwable object
826:             * @param range The range limitation of the call occurrence
827:             */
828:            public void setThrowable(Throwable throwable, Range range) {
829:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
830:                        .getInvocationHandler(mockObject);
831:                handler.setThrowable(throwable, range);
832:            }
833:
834:            /**
835:             * Indacate that last method call on the mock object has no return value with a range limitation of the call occurrence
836:             * @param range The range limitation of the call occurrence
837:             */
838:            public void setVoidCallable(Range range) {
839:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
840:                        .getInvocationHandler(mockObject);
841:                handler.setVoidCallable(range);
842:            }
843:
844:            /**
845:             * Set default argument matcher
846:             * @param matcher The default argument matcher object
847:             */
848:            public void setDefaultMatcher(ArgumentsMatcher matcher) {
849:                if (matcher == null)
850:                    throw new AssertionFailedError("Invalid matcher [null]");
851:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
852:                        .getInvocationHandler(mockObject);
853:                handler.setDefaultMatcher(matcher);
854:            }
855:
856:            /**
857:             * Set argument matcher for last method call on the mock object
858:             * @param matcher The argument matcher object
859:             */
860:            public void setMatcher(ArgumentsMatcher matcher) {
861:                if (matcher == null)
862:                    throw new AssertionFailedError("Invalid matcher [null]");
863:                MockDelegationInvocationHandler handler = (MockDelegationInvocationHandler) DelegationGenerator
864:                        .getInvocationHandler(mockObject);
865:                handler.setMatcher(matcher);
866:            }
867:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.