Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
../../img/srcFileCovDistChart10.png 0% of files have more coverage
264   2 154   147   1,82
4   597   0,56   145
145     1,01  
1    
0,2% of code in this file is excluded from these metrics.
 
  EasyMock       Line # 32 264 0,2% 147 0 100% 1.0
 
  (776)
 
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;
18   
19    import java.lang.reflect.Method;
20    import java.util.Comparator;
21   
22    import org.easymock.internal.*;
23    import org.easymock.internal.matchers.*;
24   
25    /**
26    * Main EasyMock class. Contains methods to create, replay and verify mocks and
27    * a list of standard matchers.
28    *
29    * @author OFFIS, Tammo Freese
30    * @author Henri Tremblay
31    */
 
32    public class EasyMock {
33   
34    /**
35    * Since EasyMock 2.4, by default, a mock wasn't allowed to be called in
36    * multiple threads unless it was made thread-safe (See
37    * {@link #makeThreadSafe(Object, boolean)} method). Since EasyMock 2.5,
38    * this isn't the default anymore. For backward compatibility, this property
39    * can bring EasyMock 2.4 behavior back.
40    */
41    public static final String ENABLE_THREAD_SAFETY_CHECK_BY_DEFAULT = "easymock.enableThreadSafetyCheckByDefault";
42   
43    /**
44    * Since EasyMock 2.5, by default a mock is thread-safe. For backward
45    * compatibility, this property can change the default. A given mock still
46    * can be made thread-safe by calling
47    * {@link #makeThreadSafe(Object, boolean)}.
48    */
49    public static final String NOT_THREAD_SAFE_BY_DEFAULT = "easymock.notThreadSafeByDefault";
50   
51    /**
52    * Since EasyMock 3.0, EasyMock can perform class mocking directly without
53    * using the class extension. If you want to disable any class mocking, turn
54    * this to true.
55    */
56    public static final String DISABLE_CLASS_MOCKING = "easymock.disableClassMocking";
57   
58    /**
59    * Creates a mock object that implements the given interface, order checking
60    * is enabled by default.
61    *
62    * @param <T>
63    * the interface that the mock object should implement.
64    * @param toMock
65    * the class of the interface that the mock object should
66    * implement.
67    * @return the mock object.
68    */
 
69  96 toggle public static <T> T createStrictMock(final Class<T> toMock) {
70  96 return createStrictControl().createMock(toMock);
71    }
72   
73    /**
74    * Creates a mock object that implements the given interface, order checking
75    * is enabled by default.
76    *
77    * @param name
78    * the name of the mock object.
79    * @param toMock
80    * the class of the interface that the mock object should
81    * implement.
82    * @param <T>
83    * the interface that the mock object should implement.
84    * @return the mock object.
85    * @throws IllegalArgumentException
86    * if the name is not a valid Java identifier.
87    */
 
88  6 toggle public static <T> T createStrictMock(final String name, final Class<T> toMock) {
89  6 return createStrictControl().createMock(name, toMock);
90    }
91   
92    /**
93    * Creates a mock object that implements the given interface, order checking
94    * is disabled by default.
95    *
96    * @param <T>
97    * the interface that the mock object should implement.
98    * @param toMock
99    * the class of the interface that the mock object should
100    * implement.
101    * @return the mock object.
102    */
 
103  564 toggle public static <T> T createMock(final Class<T> toMock) {
104  564 return createControl().createMock(toMock);
105    }
106   
107    /**
108    * Creates a mock object that implements the given interface, order checking
109    * is disabled by default.
110    *
111    * @param name
112    * the name of the mock object.
113    * @param toMock
114    * the class of the interface that the mock object should
115    * implement.
116    *
117    * @param <T>
118    * the interface that the mock object should implement.
119    * @return the mock object.
120    * @throws IllegalArgumentException
121    * if the name is not a valid Java identifier.
122    */
 
123  8 toggle public static <T> T createMock(final String name, final Class<T> toMock) {
124  8 return createControl().createMock(name, toMock);
125    }
126   
127    /**
128    * Creates a mock object that implements the given interface, order checking
129    * is disabled by default, and the mock object will return <code>0</code>,
130    * <code>null</code> or <code>false</code> for unexpected invocations.
131    *
132    * @param <T>
133    * the interface that the mock object should implement.
134    * @param toMock
135    * the class of the interface that the mock object should
136    * implement.
137    * @return the mock object.
138    */
 
139  46 toggle public static <T> T createNiceMock(final Class<T> toMock) {
140  46 return createNiceControl().createMock(toMock);
141    }
142   
143    /**
144    * Creates a mock object that implements the given interface, order checking
145    * is disabled by default, and the mock object will return <code>0</code>,
146    * <code>null</code> or <code>false</code> for unexpected invocations.
147    *
148    * @param name
149    * the name of the mock object.
150    * @param toMock
151    * the class of the interface that the mock object should
152    * implement.
153    *
154    * @param <T>
155    * the interface that the mock object should implement.
156    * @return the mock object.
157    * @throws IllegalArgumentException
158    * if the name is not a valid Java identifier.
159    */
 
160  6 toggle public static <T> T createNiceMock(final String name, final Class<T> toMock) {
161  6 return createNiceControl().createMock(name, toMock);
162    }
163   
164    /**
165    * Creates a mock object that extends the given class, order checking is
166    * enabled by default.
167    *
168    * @param <T>
169    * the class that the mock object should extend.
170    * @param toMock
171    * the class that the mock object should extend.
172    * @param mockedMethods
173    * methods that will be mocked, other methods will behave
174    * normally
175    * @return the mock object.
176    *
177    * @deprecated Use {@link #createMockBuilder(Class)} instead
178    */
 
179  4 toggle @Deprecated
180    public static <T> T createStrictMock(final Class<T> toMock, final Method... mockedMethods) {
181  4 return createStrictControl().createMock(toMock, mockedMethods);
182    }
183   
184    /**
185    * Creates a mock object that extends the given class, order checking is
186    * enabled by default.
187    *
188    * @param <T>
189    * the class that the mock object should extend.
190    * @param name
191    * the name of the mock object.
192    * @param toMock
193    * the class that the mock object should extend.
194    * @param mockedMethods
195    * methods that will be mocked, other methods will behave
196    * normally
197    * @return the mock object.
198    *
199    * @deprecated Use {@link #createMockBuilder(Class)} instead
200    */
 
201  2 toggle @Deprecated
202    public static <T> T createStrictMock(final String name, final Class<T> toMock,
203    final Method... mockedMethods) {
204  2 return createStrictControl().createMock(name, toMock, mockedMethods);
205    }
206   
207    /**
208    * Creates a mock object that extends the given class, order checking is
209    * enabled by default.
210    *
211    * @param <T>
212    * the class that the mock object should extend.
213    * @param toMock
214    * the class that the mock object should extend.
215    * @param constructorArgs
216    * constructor and parameters used to instantiate the mock.
217    * @param mockedMethods
218    * methods that will be mocked, other methods will behave
219    * normally
220    * @return the mock object.
221    *
222    * @deprecated Use {@link #createMockBuilder(Class)} instead
223    */
 
224  2 toggle @Deprecated
225    public static <T> T createStrictMock(final Class<T> toMock, final ConstructorArgs constructorArgs,
226    final Method... mockedMethods) {
227  2 return createStrictControl().createMock(toMock, constructorArgs, mockedMethods);
228    }
229   
230    /**
231    * Creates a mock object that extends the given class, order checking is
232    * enabled by default.
233    *
234    * @param <T>
235    * the class that the mock object should extend.
236    * @param name
237    * the name of the mock object.
238    * @param toMock
239    * the class that the mock object should extend.
240    * @param constructorArgs
241    * constructor and parameters used to instantiate the mock.
242    * @param mockedMethods
243    * methods that will be mocked, other methods will behave
244    * normally
245    * @return the mock object.
246    *
247    * @deprecated Use {@link #createMockBuilder(Class)} instead
248    */
 
249  2 toggle @Deprecated
250    public static <T> T createStrictMock(final String name, final Class<T> toMock,
251    final ConstructorArgs constructorArgs, final Method... mockedMethods) {
252  2 return createStrictControl().createMock(name, toMock, constructorArgs, mockedMethods);
253    }
254   
255    /**
256    * Creates a mock object that extends the given class, order checking is
257    * disabled by default.
258    *
259    * @param <T>
260    * the class that the mock object should extend.
261    * @param toMock
262    * the class that the mock object should extend.
263    * @param mockedMethods
264    * methods that will be mocked, other methods will behave
265    * normally
266    * @return the mock object.
267    *
268    * @deprecated Use {@link #createMockBuilder(Class)} instead
269    */
 
270  4 toggle @Deprecated
271    public static <T> T createMock(final Class<T> toMock, final Method... mockedMethods) {
272  4 return createControl().createMock(toMock, mockedMethods);
273    }
274   
275    /**
276    * Creates a mock object that extends the given class, order checking is
277    * disabled by default.
278    *
279    * @param <T>
280    * the class that the mock object should extend.
281    * @param name
282    * the name of the mock object.
283    * @param toMock
284    * the class that the mock object should extend.
285    * @param mockedMethods
286    * methods that will be mocked, other methods will behave
287    * normally
288    * @return the mock object.
289    *
290    * @deprecated Use {@link #createMockBuilder(Class)} instead
291    */
 
292  2 toggle @Deprecated
293    public static <T> T createMock(final String name, final Class<T> toMock, final Method... mockedMethods) {
294  2 return createControl().createMock(name, toMock, mockedMethods);
295    }
296   
297    /**
298    * Creates a mock object that extends the given class, order checking is
299    * disabled by default.
300    *
301    * @param <T>
302    * the class that the mock object should extend.
303    * @param toMock
304    * the class that the mock object should extend.
305    * @param constructorArgs
306    * constructor and parameters used to instantiate the mock.
307    * @param mockedMethods
308    * methods that will be mocked, other methods will behave
309    * normally
310    * @return the mock object.
311    *
312    * @deprecated Use {@link #createMockBuilder(Class)} instead
313    */
 
314  2 toggle @Deprecated
315    public static <T> T createMock(final Class<T> toMock, final ConstructorArgs constructorArgs,
316    final Method... mockedMethods) {
317  2 return createControl().createMock(toMock, constructorArgs, mockedMethods);
318    }
319   
320    /**
321    * Creates a mock object that extends the given class, order checking is
322    * disabled by default.
323    *
324    * @param <T>
325    * the class that the mock object should extend.
326    * @param name
327    * the name of the mock object.
328    * @param toMock
329    * the class that the mock object should extend.
330    * @param constructorArgs
331    * constructor and parameters used to instantiate the mock.
332    * @param mockedMethods
333    * methods that will be mocked, other methods will behave
334    * normally
335    * @return the mock object.
336    *
337    * @deprecated Use {@link #createMockBuilder(Class)} instead
338    */
 
339  2 toggle @Deprecated
340    public static <T> T createMock(final String name, final Class<T> toMock,
341    final ConstructorArgs constructorArgs, final Method... mockedMethods) {
342  2 return createControl().createMock(name, toMock, constructorArgs, mockedMethods);
343    }
344   
345    /**
346    * Creates a mock object that extends the given class, order checking is
347    * disabled by default, and the mock object will return <code>0</code>,
348    * <code>null</code> or <code>false</code> for unexpected invocations.
349    *
350    * @param <T>
351    * the class that the mock object should extend.
352    * @param toMock
353    * the class that the mock object should extend.
354    * @param mockedMethods
355    * methods that will be mocked, other methods will behave
356    * normally
357    * @return the mock object.
358    *
359    * @deprecated Use {@link #createMockBuilder(Class)} instead
360    */
 
361  4 toggle @Deprecated
362    public static <T> T createNiceMock(final Class<T> toMock, final Method... mockedMethods) {
363  4 return createNiceControl().createMock(toMock, mockedMethods);
364    }
365   
366    /**
367    * Creates a mock object that extends the given class, order checking is
368    * disabled by default, and the mock object will return <code>0</code>,
369    * <code>null</code> or <code>false</code> for unexpected invocations.
370    *
371    * @param <T>
372    * the class that the mock object should extend.
373    * @param name
374    * the name of the mock object.
375    * @param toMock
376    * the class that the mock object should extend.
377    * @param mockedMethods
378    * methods that will be mocked, other methods will behave
379    * normally
380    * @return the mock object.
381    *
382    * @deprecated Use {@link #createMockBuilder(Class)} instead
383    */
 
384  2 toggle @Deprecated
385    public static <T> T createNiceMock(final String name, final Class<T> toMock,
386    final Method... mockedMethods) {
387  2 return createNiceControl().createMock(name, toMock, mockedMethods);
388    }
389   
390    /**
391    * Creates a mock object that extends the given class, order checking is
392    * disabled by default, and the mock object will return <code>0</code>,
393    * <code>null</code> or <code>false</code> for unexpected invocations.
394    *
395    * @param <T>
396    * the class that the mock object should extend.
397    * @param toMock
398    * the class that the mock object should extend.
399    * @param constructorArgs
400    * constructor and parameters used to instantiate the mock.
401    * @param mockedMethods
402    * methods that will be mocked, other methods will behave
403    * normally
404    * @return the mock object.
405    *
406    * @deprecated Use {@link #createMockBuilder(Class)} instead
407    */
 
408  2 toggle @Deprecated
409    public static <T> T createNiceMock(final Class<T> toMock, final ConstructorArgs constructorArgs,
410    final Method... mockedMethods) {
411  2 return createNiceControl().createMock(toMock, constructorArgs, mockedMethods);
412    }
413   
414    /**
415    * Creates a mock object that extends the given class, order checking is
416    * disabled by default, and the mock object will return <code>0</code>,
417    * <code>null</code> or <code>false</code> for unexpected invocations.
418    *
419    * @param <T>
420    * the class that the mock object should extend.
421    * @param name
422    * the name of the mock object.
423    * @param toMock
424    * the class that the mock object should extend.
425    * @param constructorArgs
426    * constructor and parameters used to instantiate the mock.
427    * @param mockedMethods
428    * methods that will be mocked, other methods will behave
429    * normally
430    * @return the mock object.
431    *
432    * @deprecated Use {@link #createMockBuilder(Class)} instead
433    */
 
434  2 toggle @Deprecated
435    public static <T> T createNiceMock(final String name, final Class<T> toMock,
436    final ConstructorArgs constructorArgs, final Method... mockedMethods) {
437  2 return createNiceControl().createMock(name, toMock, constructorArgs, mockedMethods);
438    }
439   
440    /**
441    * Create a mock builder allowing to create a partial mock for the given
442    * class or interface.
443    *
444    * @param <T>
445    * the interface that the mock object should implement.
446    * @param toMock
447    * the class of the interface that the mock object should
448    * implement.
449    * @return a mock builder to create a partial mock
450    */
 
451  26 toggle public static <T> IMockBuilder<T> createMockBuilder(final Class<T> toMock) {
452  26 return new MockBuilder<T>(toMock);
453    }
454   
455    /**
456    * Creates a control, order checking is enabled by default.
457    *
458    * @return the control.
459    */
 
460  150 toggle public static IMocksControl createStrictControl() {
461  150 return new MocksControl(MocksControl.MockType.STRICT);
462    }
463   
464    /**
465    * Creates a control, order checking is disabled by default.
466    *
467    * @return the control.
468    */
 
469  768 toggle public static IMocksControl createControl() {
470  768 return new MocksControl(MocksControl.MockType.DEFAULT);
471    }
472   
473    /**
474    * Creates a control, order checking is disabled by default, and the mock
475    * objects created by this control will return <code>0</code>,
476    * <code>null</code> or <code>false</code> for unexpected invocations.
477    *
478    * @return the control.
479    */
 
480  102 toggle public static IMocksControl createNiceControl() {
481  102 return new MocksControl(MocksControl.MockType.NICE);
482    }
483   
484    /**
485    * Returns the expectation setter for the last expected invocation in the
486    * current thread.
487    *
488    * @param <T>
489    * type returned by the expected method
490    * @param value
491    * the parameter is used to transport the type to the
492    * ExpectationSetter. It allows writing the expected call as
493    * argument, i.e.
494    * <code>expect(mock.getName()).andReturn("John Doe")<code>.
495    *
496    * @return the expectation setter.
497    */
 
498  980 toggle public static <T> IExpectationSetters<T> expect(final T value) {
499  980 return EasyMock.getControlForLastCall();
500    }
501   
502    /**
503    * Returns the expectation setter for the last expected invocation in the
504    * current thread. This method is used for expected invocations on void
505    * methods.
506    *
507    * @param <T>
508    * type returned by the expected method
509    * @return the expectation setter.
510    */
 
511  88 toggle public static <T> IExpectationSetters<T> expectLastCall() {
512  88 return getControlForLastCall();
513    }
514   
 
515  1068 toggle @SuppressWarnings("unchecked")
516    private static <T> IExpectationSetters<T> getControlForLastCall() {
517  1068 final MocksControl lastControl = LastControl.lastControl();
518  1068 if (lastControl == null) {
519  8 LastControl.pullMatchers(); // cleanup matchers to prevent impacting
520    // other tests
521  8 throw new IllegalStateException("no last call on a mock available");
522    }
523  1060 return (IExpectationSetters<T>) lastControl;
524    }
525   
526    /**
527    * Expects any boolean argument. For details, see the EasyMock
528    * documentation.
529    *
530    * @return <code>false</code>.
531    */
 
532  4 toggle public static boolean anyBoolean() {
533  4 reportMatcher(Any.ANY);
534  4 return false;
535    }
536   
537    /**
538    * Expects any byte argument. For details, see the EasyMock documentation.
539    *
540    * @return <code>0</code>.
541    */
 
542  4 toggle public static byte anyByte() {
543  4 reportMatcher(Any.ANY);
544  4 return 0;
545    }
546   
547    /**
548    * Expects any char argument. For details, see the EasyMock documentation.
549    *
550    * @return <code>0</code>.
551    */
 
552  4 toggle public static char anyChar() {
553  4 reportMatcher(Any.ANY);
554  4 return 0;
555    }
556   
557    /**
558    * Expects any int argument. For details, see the EasyMock documentation.
559    *
560    * @return <code>0</code>.
561    */
 
562  48 toggle public static int anyInt() {
563  48 reportMatcher(Any.ANY);
564  48 return 0;
565    }
566   
567    /**
568    * Expects any long argument. For details, see the EasyMock documentation.
569    *
570    * @return <code>0</code>.
571    */
 
572  4 toggle public static long anyLong() {
573  4 reportMatcher(Any.ANY);
574  4 return 0;
575    }
576   
577    /**
578    * Expects any float argument. For details, see the EasyMock documentation.
579    *
580    * @return <code>0</code>.
581    */
 
582  4 toggle public static float anyFloat() {
583  4 reportMatcher(Any.ANY);
584  4 return 0;
585    }
586   
587    /**
588    * Expects any double argument. For details, see the EasyMock documentation.
589    *
590    * @return <code>0</code>.
591    */
 
592  4 toggle public static double anyDouble() {
593  4 reportMatcher(Any.ANY);
594  4 return 0;
595    }
596   
597    /**
598    * Expects any short argument. For details, see the EasyMock documentation.
599    *
600    * @return <code>0</code>.
601    */
 
602  4 toggle public static short anyShort() {
603  4 reportMatcher(Any.ANY);
604  4 return 0;
605    }
606   
607    /**
608    * Expects any Object argument. For details, see the EasyMock documentation.
609    * This matcher (and {@link #anyObject(Class)}) can be used in these three
610    * ways:
611    * <ul>
612    * <li><code>(T)EasyMock.anyObject() // explicit cast</code></li>
613    * <li>
614    * <code>EasyMock.&lt;T&gt; anyObject() // fixing the returned generic</code>
615    * </li>
616    * <li>
617    * <code>EasyMock.anyObject(T.class) // pass the returned type in parameter</code>
618    * </li>
619    * </ul>
620    *
621    * @param <T>
622    * type of the method argument to match
623    * @return <code>null</code>.
624    */
 
625  16 toggle public static <T> T anyObject() {
626  16 reportMatcher(Any.ANY);
627  16 return null;
628    }
629   
630    /**
631    * Expects any Object argument. For details, see the EasyMock documentation.
632    * To work well with generics, this matcher can be used in three different
633    * ways. See {@link #anyObject()}.
634    *
635    * @param <T>
636    * type of the method argument to match
637    * @param clazz
638    * the class of the argument to match
639    * @return <code>null</code>.
640    */
 
641  2 toggle public static <T> T anyObject(final Class<T> clazz) {
642  2 reportMatcher(Any.ANY);
643  2 return null;
644    }
645   
646    /**
647    * Expects a comparable argument greater than or equal the given value. For
648    * details, see the EasyMock documentation.
649    *
650    * @param <T>
651    * type of the method argument to match
652    * @param value
653    * the given value.
654    * @return <code>null</code>.
655    */
 
656  2 toggle public static <T extends Comparable<T>> T geq(final Comparable<T> value) {
657  2 reportMatcher(new GreaterOrEqual<T>(value));
658  2 return null;
659    }
660   
661    /**
662    * Expects a byte argument greater than or equal to the given value. For
663    * details, see the EasyMock documentation.
664    *
665    * @param value
666    * the given value.
667    * @return <code>0</code>.
668    */
 
669  2 toggle public static byte geq(final byte value) {
670  2 reportMatcher(new GreaterOrEqual<Byte>(value));
671  2 return 0;
672    }
673   
674    /**
675    * Expects a double argument greater than or equal to the given value. For
676    * details, see the EasyMock documentation.
677    *
678    * @param value
679    * the given value.
680    * @return <code>0</code>.
681    */
 
682  2 toggle public static double geq(final double value) {
683  2 reportMatcher(new GreaterOrEqual<Double>(value));
684  2 return 0;
685    }
686   
687    /**
688    * Expects a float argument greater than or equal to the given value. For
689    * details, see the EasyMock documentation.
690    *
691    * @param value
692    * the given value.
693    * @return <code>0</code>.
694    */
 
695  2 toggle public static float geq(final float value) {
696  2 reportMatcher(new GreaterOrEqual<Float>(value));
697  2 return 0;
698    }
699   
700    /**
701    * Expects an int argument greater than or equal to the given value. For
702    * details, see the EasyMock documentation.
703    *
704    * @param value
705    * the given value.
706    * @return <code>0</code>.
707    */
 
708  8 toggle public static int geq(final int value) {
709  8 reportMatcher(new GreaterOrEqual<Integer>(value));
710  8 return 0;
711    }
712   
713    /**
714    * Expects a long argument greater than or equal to the given value. For
715    * details, see the EasyMock documentation.
716    *
717    * @param value
718    * the given value.
719    * @return <code>0</code>.
720    */
 
721  2 toggle public static long geq(final long value) {
722  2 reportMatcher(new GreaterOrEqual<Long>(value));
723  2 return 0;
724    }
725   
726    /**
727    * Expects a short argument greater than or equal to the given value. For
728    * details, see the EasyMock documentation.
729    *
730    * @param value
731    * the given value.
732    * @return <code>0</code>.
733    */
 
734  2 toggle public static short geq(final short value) {
735  2 reportMatcher(new GreaterOrEqual<Short>(value));
736  2 return 0;
737    }
738   
739    /**
740    * Expects a comparable argument less than or equal the given value. For
741    * details, see the EasyMock documentation.
742    *
743    * @param <T>
744    * type of the method argument to match
745    * @param value
746    * the given value.
747    * @return <code>null</code>.
748    */
 
749  2 toggle public static <T extends Comparable<T>> T leq(final Comparable<T> value) {
750  2 reportMatcher(new LessOrEqual<T>(value));
751  2 return null;
752    }
753   
754    /**
755    * Expects a byte argument less than or equal to the given value. For
756    * details, see the EasyMock documentation.
757    *
758    * @param value
759    * the given value.
760    * @return <code>0</code>.
761    */
 
762  2 toggle public static byte leq(final byte value) {
763  2 reportMatcher(new LessOrEqual<Byte>(value));
764  2 return 0;
765    }
766   
767    /**
768    * Expects a double argument less than or equal to the given value. For
769    * details, see the EasyMock documentation.
770    *
771    * @param value
772    * the given value.
773    * @return <code>0</code>.
774    */
 
775  2 toggle public static double leq(final double value) {
776  2 reportMatcher(new LessOrEqual<Double>(value));
777  2 return 0;
778    }
779   
780    /**
781    * Expects a float argument less than or equal to the given value. For
782    * details, see the EasyMock documentation.
783    *
784    * @param value
785    * the given value.
786    * @return <code>0</code>.
787    */
 
788  2 toggle public static float leq(final float value) {
789  2 reportMatcher(new LessOrEqual<Float>(value));
790  2 return 0;
791    }
792   
793    /**
794    * Expects an int argument less than or equal to the given value. For
795    * details, see the EasyMock documentation.
796    *
797    * @param value
798    * the given value.
799    * @return <code>0</code>.
800    */
 
801  8 toggle public static int leq(final int value) {
802  8 reportMatcher(new LessOrEqual<Integer>(value));
803  8 return 0;
804    }
805   
806    /**
807    * Expects a long argument less than or equal to the given value. For
808    * details, see the EasyMock documentation.
809    *
810    * @param value
811    * the given value.
812    * @return <code>0</code>.
813    */
 
814  2 toggle public static long leq(final long value) {
815  2 reportMatcher(new LessOrEqual<Long>(value));
816  2 return 0;
817    }
818   
819    /**
820    * Expects a short argument less than or equal to the given value. For
821    * details, see the EasyMock documentation.
822    *
823    * @param value
824    * the given value.
825    * @return <code>0</code>.
826    */
 
827  2 toggle public static short leq(final short value) {
828  2 reportMatcher(new LessOrEqual<Short>(value));
829  2 return 0;
830    }
831   
832    /**
833    * Expects a comparable argument greater than the given value. For details,
834    * see the EasyMock documentation.
835    *
836    * @param <T>
837    * type of the method argument to match
838    * @param value
839    * the given value.
840    * @return <code>null</code>.
841    */
 
842  2 toggle public static <T extends Comparable<T>> T gt(final Comparable<T> value) {
843  2 reportMatcher(new GreaterThan<T>(value));
844  2 return null;
845    }
846   
847    /**
848    * Expects a byte argument greater than the given value. For details, see
849    * the EasyMock documentation.
850    *
851    * @param value
852    * the given value.
853    * @return <code>0</code>.
854    */
 
855  2 toggle public static byte gt(final byte value) {
856  2 reportMatcher(new GreaterThan<Byte>(value));
857  2 return 0;
858    }
859   
860    /**
861    * Expects a double argument greater than the given value. For details, see
862    * the EasyMock documentation.
863    *
864    * @param value
865    * the given value.
866    * @return <code>0</code>.
867    */
 
868  2 toggle public static double gt(final double value) {
869  2 reportMatcher(new GreaterThan<Double>(value));
870  2 return 0;
871    }
872   
873    /**
874    * Expects a float argument greater than the given value. For details, see
875    * the EasyMock documentation.
876    *
877    * @param value
878    * the given value.
879    * @return <code>0</code>.
880    */
 
881  2 toggle public static float gt(final float value) {
882  2 reportMatcher(new GreaterThan<Float>(value));
883  2 return 0;
884    }
885   
886    /**
887    * Expects an int argument greater than the given value. For details, see
888    * the EasyMock documentation.
889    *
890    * @param value
891    * the given value.
892    * @return <code>0</code>.
893    */
 
894  6 toggle public static int gt(final int value) {
895  6 reportMatcher(new GreaterThan<Integer>(value));
896  6 return 0;
897    }
898   
899    /**
900    * Expects a long argument greater than the given value. For details, see
901    * the EasyMock documentation.
902    *
903    * @param value
904    * the given value.
905    * @return <code>0</code>.
906    */
 
907  2 toggle public static long gt(final long value) {
908  2 reportMatcher(new GreaterThan<Long>(value));
909  2 return 0;
910    }
911   
912    /**
913    * Expects a short argument greater than the given value. For details, see
914    * the EasyMock documentation.
915    *
916    * @param value
917    * the given value.
918    * @return <code>0</code>.
919    */
 
920  2 toggle public static short gt(final short value) {
921  2 reportMatcher(new GreaterThan<Short>(value));
922  2 return 0;
923    }
924   
925    /**
926    * Expects a comparable argument less than the given value. For details, see
927    * the EasyMock documentation.
928    *
929    * @param <T>
930    * type of the method argument to match
931    * @param value
932    * the given value.
933    * @return <code>null</code>.
934    */
 
935  2 toggle public static <T extends Comparable<T>> T lt(final Comparable<T> value) {
936  2 reportMatcher(new LessThan<T>(value));
937  2 return null;
938    }
939   
940    /**
941    * Expects a byte argument less than the given value. For details, see the
942    * EasyMock documentation.
943    *
944    * @param value
945    * the given value.
946    * @return <code>0</code>.
947    */
 
948  2 toggle public static byte lt(final byte value) {
949  2 reportMatcher(new LessThan<Byte>(value));
950  2 return 0;
951    }
952   
953    /**
954    * Expects a double argument less than the given value. For details, see the
955    * EasyMock documentation.
956    *
957    * @param value
958    * the given value.
959    * @return <code>0</code>.
960    */
 
961  2 toggle public static double lt(final double value) {
962  2 reportMatcher(new LessThan<Double>(value));
963  2 return 0;
964    }
965   
966    /**
967    * Expects a float argument less than the given value. For details, see the
968    * EasyMock documentation.
969    *
970    * @param value
971    * the given value.
972    * @return <code>0</code>.
973    */
 
974  2 toggle public static float lt(final float value) {
975  2 reportMatcher(new LessThan<Float>(value));
976  2 return 0;
977    }
978   
979    /**
980    * Expects an int argument less than the given value. For details, see the
981    * EasyMock documentation.
982    *
983    * @param value
984    * the given value.
985    * @return <code>0</code>.
986    */
 
987  8 toggle public static int lt(final int value) {
988  8 reportMatcher(new LessThan<Integer>(value));
989  8 return 0;
990    }
991   
992    /**
993    * Expects a long argument less than the given value. For details, see the
994    * EasyMock documentation.
995    *
996    * @param value
997    * the given value.
998    * @return <code>0</code>.
999    */
 
1000  2 toggle public static long lt(final long value) {
1001  2 reportMatcher(new LessThan<Long>(value));
1002  2 return 0;
1003    }
1004   
1005    /**
1006    * Expects a short argument less than the given value. For details, see the
1007    * EasyMock documentation.
1008    *
1009    * @param value
1010    * the given value.
1011    * @return <code>0</code>.
1012    */
 
1013  2 toggle public static short lt(final short value) {
1014  2 reportMatcher(new LessThan<Short>(value));
1015  2 return 0;
1016    }
1017   
1018    /**
1019    * Expects an object implementing the given class. For details, see the
1020    * EasyMock documentation.
1021    *
1022    * @param <T>
1023    * the accepted type.
1024    * @param clazz
1025    * the class of the accepted type.
1026    * @return <code>null</code>.
1027    */
 
1028  14 toggle public static <T> T isA(final Class<T> clazz) {
1029  14 reportMatcher(new InstanceOf(clazz));
1030  14 return null;
1031    }
1032   
1033    /**
1034    * Expects a string that contains the given substring. For details, see the
1035    * EasyMock documentation.
1036    *
1037    * @param substring
1038    * the substring.
1039    * @return <code>null</code>.
1040    */
 
1041  12 toggle public static String contains(final String substring) {
1042  12 reportMatcher(new Contains(substring));
1043  12 return null;
1044    }
1045   
1046    /**
1047    * Expects a boolean that matches both given expectations.
1048    *
1049    * @param first
1050    * placeholder for the first expectation.
1051    * @param second
1052    * placeholder for the second expectation.
1053    * @return <code>false</code>.
1054    */
 
1055  2 toggle public static boolean and(final boolean first, final boolean second) {
1056  2 LastControl.reportAnd(2);
1057  2 return false;
1058    }
1059   
1060    /**
1061    * Expects a byte that matches both given expectations.
1062    *
1063    * @param first
1064    * placeholder for the first expectation.
1065    * @param second
1066    * placeholder for the second expectation.
1067    * @return <code>0</code>.
1068    */
 
1069  2 toggle public static byte and(final byte first, final byte second) {
1070  2 LastControl.reportAnd(2);
1071  2 return 0;
1072    }
1073   
1074    /**
1075    * Expects a char that matches both given expectations.
1076    *
1077    * @param first
1078    * placeholder for the first expectation.
1079    * @param second
1080    * placeholder for the second expectation.
1081    * @return <code>0</code>.
1082    */
 
1083  2 toggle public static char and(final char first, final char second) {
1084  2 LastControl.reportAnd(2);
1085  2 return 0;
1086    }
1087   
1088    /**
1089    * Expects a double that matches both given expectations.
1090    *
1091    * @param first
1092    * placeholder for the first expectation.
1093    * @param second
1094    * placeholder for the second expectation.
1095    * @return <code>0</code>.
1096    */
 
1097  2 toggle public static double and(final double first, final double second) {
1098  2 LastControl.reportAnd(2);
1099  2 return 0;
1100    }
1101   
1102    /**
1103    * Expects a float that matches both given expectations.
1104    *
1105    * @param first
1106    * placeholder for the first expectation.
1107    * @param second
1108    * placeholder for the second expectation.
1109    * @return <code>0</code>.
1110    */
 
1111  2 toggle public static float and(final float first, final float second) {
1112  2 LastControl.reportAnd(2);
1113  2 return 0;
1114    }
1115   
1116    /**
1117    * Expects an int that matches both given expectations.
1118    *
1119    * @param first
1120    * placeholder for the first expectation.
1121    * @param second
1122    * placeholder for the second expectation.
1123    * @return <code>0</code>.
1124    */
 
1125  4 toggle public static int and(final int first, final int second) {
1126  4 LastControl.reportAnd(2);
1127  4 return 0;
1128    }
1129   
1130    /**
1131    * Expects a long that matches both given expectations.
1132    *
1133    * @param first
1134    * placeholder for the first expectation.
1135    * @param second
1136    * placeholder for the second expectation.
1137    * @return <code>0</code>.
1138    */
 
1139  2 toggle public static long and(final long first, final long second) {
1140  2 LastControl.reportAnd(2);
1141  2 return 0;
1142    }
1143   
1144    /**
1145    * Expects a short that matches both given expectations.
1146    *
1147    * @param first
1148    * placeholder for the first expectation.
1149    * @param second
1150    * placeholder for the second expectation.
1151    * @return <code>0</code>.
1152    */
 
1153  2 toggle public static short and(final short first, final short second) {
1154  2 LastControl.reportAnd(2);
1155  2 return 0;
1156    }
1157   
1158    /**
1159    * Expects an Object that matches both given expectations.
1160    *
1161    * @param <T>
1162    * the type of the object, it is passed through to prevent casts.
1163    * @param first
1164    * placeholder for the first expectation.
1165    * @param second
1166    * placeholder for the second expectation.
1167    * @return <code>null</code>.
1168    */
 
1169  16 toggle public static <T> T and(final T first, final T second) {
1170  16 LastControl.reportAnd(2);
1171  16 return null;
1172    }
1173   
1174    /**
1175    * Expects a boolean that matches one of the given expectations.
1176    *
1177    * @param first
1178    * placeholder for the first expectation.
1179    * @param second
1180    * placeholder for the second expectation.
1181    * @return <code>false</code>.
1182    */
 
1183  2 toggle public static boolean or(final boolean first, final boolean second) {
1184  2 LastControl.reportOr(2);
1185  2 return false;
1186    }
1187   
1188    /**
1189    * Expects a byte that matches one of the given expectations.
1190    *
1191    * @param first
1192    * placeholder for the first expectation.
1193    * @param second
1194    * placeholder for the second expectation.
1195    * @return <code>0</code>.
1196    */
 
1197  2 toggle public static byte or(final byte first, final byte second) {
1198  2 LastControl.reportOr(2);
1199  2 return 0;
1200    }
1201   
1202    /**
1203    * Expects a char that matches one of the given expectations.
1204    *
1205    * @param first
1206    * placeholder for the first expectation.
1207    * @param second
1208    * placeholder for the second expectation.
1209    * @return <code>0</code>.
1210    */
 
1211  2 toggle public static char or(final char first, final char second) {
1212  2 LastControl.reportOr(2);
1213  2 return 0;
1214    }
1215   
1216    /**
1217    * Expects a double that matches one of the given expectations.
1218    *
1219    * @param first
1220    * placeholder for the first expectation.
1221    * @param second
1222    * placeholder for the second expectation.
1223    * @return <code>0</code>.
1224    */
 
1225  2 toggle public static double or(final double first, final double second) {
1226  2 LastControl.reportOr(2);
1227  2 return 0;
1228    }
1229   
1230    /**
1231    * Expects a float that matches one of the given expectations.
1232    *
1233    * @param first
1234    * placeholder for the first expectation.
1235    * @param second
1236    * placeholder for the second expectation.
1237    * @return <code>0</code>.
1238    */
 
1239  2 toggle public static float or(final float first, final float second) {
1240  2 LastControl.reportOr(2);
1241  2 return 0;
1242    }
1243   
1244    /**
1245    * Expects an int that matches one of the given expectations.
1246    *
1247    * @param first
1248    * placeholder for the first expectation.
1249    * @param second
1250    * placeholder for the second expectation.
1251    * @return <code>0</code>.
1252    */
 
1253  4 toggle public static int or(final int first, final int second) {
1254  4 LastControl.reportOr(2);
1255  4 return first;
1256    }
1257   
1258    /**
1259    * Expects a long that matches one of the given expectations.
1260    *
1261    * @param first
1262    * placeholder for the first expectation.
1263    * @param second
1264    * placeholder for the second expectation.
1265    * @return <code>0</code>.
1266    */
 
1267  2 toggle public static long or(final long first, final long second) {
1268  2 LastControl.reportOr(2);
1269  2 return 0;
1270    }
1271   
1272    /**
1273    * Expects a short that matches one of the given expectations.
1274    *
1275    * @param first
1276    * placeholder for the first expectation.
1277    * @param second
1278    * placeholder for the second expectation.
1279    * @return <code>0</code>.
1280    */
 
1281  2 toggle public static short or(final short first, final short second) {
1282  2 LastControl.reportOr(2);
1283  2 return 0;
1284    }
1285   
1286    /**
1287    * Expects an Object that matches one of the given expectations.
1288    *
1289    * @param <T>
1290    * the type of the object, it is passed through to prevent casts.
1291    * @param first
1292    * placeholder for the first expectation.
1293    * @param second
1294    * placeholder for the second expectation.
1295    * @return <code>null</code>.
1296    */
 
1297  6 toggle public static <T> T or(final T first, final T second) {
1298  6 LastControl.reportOr(2);
1299  4 return null;
1300    }
1301   
1302    /**
1303    * Expects a boolean that does not match the given expectation.
1304    *
1305    * @param first
1306    * placeholder for the expectation.
1307    * @return <code>false</code>.
1308    */
 
1309  2 toggle public static boolean not(final boolean first) {
1310  2 LastControl.reportNot();
1311  2 return false;
1312    }
1313   
1314    /**
1315    * Expects a byte that does not match the given expectation.
1316    *
1317    * @param first
1318    * placeholder for the expectation.
1319    * @return <code>0</code>.
1320    */
 
1321  2 toggle public static byte not(final byte first) {
1322  2 LastControl.reportNot();
1323  2 return 0;
1324    }
1325   
1326    /**
1327    * Expects a char that does not match the given expectation.
1328    *
1329    * @param first
1330    * placeholder for the expectation.
1331    * @return <code>0</code>.
1332    */
 
1333  2 toggle public static char not(final char first) {
1334  2 LastControl.reportNot();
1335  2 return 0;
1336    }
1337   
1338    /**
1339    * Expects a double that does not match the given expectation.
1340    *
1341    * @param first
1342    * placeholder for the expectation.
1343    * @return <code>0</code>.
1344    */
 
1345  2 toggle public static double not(final double first) {
1346  2 LastControl.reportNot();
1347  2 return 0;
1348    }
1349   
1350    /**
1351    * Expects a float that does not match the given expectation.
1352    *
1353    * @param first
1354    * placeholder for the expectation.
1355    * @return <code>0</code>.
1356    */
 
1357  2 toggle public static float not(final float first) {
1358  2 LastControl.reportNot();
1359  2 return first;
1360    }
1361   
1362    /**
1363    * Expects an int that does not match the given expectation.
1364    *
1365    * @param first
1366    * placeholder for the expectation.
1367    * @return <code>0</code>.
1368    */
 
1369  2 toggle public static int not(final int first) {
1370  2 LastControl.reportNot();
1371  2 return 0;
1372    }
1373   
1374    /**
1375    * Expects a long that does not match the given expectation.
1376    *
1377    * @param first
1378    * placeholder for the expectation.
1379    * @return <code>0</code>.
1380    */
 
1381  2 toggle public static long not(final long first) {
1382  2 LastControl.reportNot();
1383  2 return 0;
1384    }
1385   
1386    /**
1387    * Expects a short that does not match the given expectation.
1388    *
1389    * @param first
1390    * placeholder for the expectation.
1391    * @return <code>0</code>.
1392    */
 
1393  2 toggle public static short not(final short first) {
1394  2 LastControl.reportNot();
1395  2 return 0;
1396    }
1397   
1398    /**
1399    * Expects an Object that does not match the given expectation.
1400    *
1401    * @param <T>
1402    * the type of the object, it is passed through to prevent casts.
1403    * @param first
1404    * placeholder for the expectation.
1405    * @return <code>null</code>.
1406    */
 
1407  12 toggle public static <T> T not(final T first) {
1408  12 LastControl.reportNot();
1409  10 return null;
1410    }
1411   
1412    /**
1413    * Expects a boolean that is equal to the given value.
1414    *
1415    * @param value
1416    * the given value.
1417    * @return <code>0</code>.
1418    */
 
1419  10 toggle public static boolean eq(final boolean value) {
1420  10 reportMatcher(new Equals(value));
1421  10 return false;
1422    }
1423   
1424    /**
1425    * Expects a byte that is equal to the given value.
1426    *
1427    * @param value
1428    * the given value.
1429    * @return <code>0</code>.
1430    */
 
1431  10 toggle public static byte eq(final byte value) {
1432  10 reportMatcher(new Equals(value));
1433  10 return 0;
1434    }
1435   
1436    /**
1437    * Expects a char that is equal to the given value.
1438    *
1439    * @param value
1440    * the given value.
1441    * @return <code>0</code>.
1442    */
 
1443  10 toggle public static char eq(final char value) {
1444  10 reportMatcher(new Equals(value));
1445  10 return 0;
1446    }
1447   
1448    /**
1449    * Expects a double that is equal to the given value.
1450    *
1451    * @param value
1452    * the given value.
1453    * @return <code>0</code>.
1454    */
 
1455  10 toggle public static double eq(final double value) {
1456  10 reportMatcher(new Equals(value));
1457  10 return 0;
1458    }
1459   
1460    /**
1461    * Expects a float that is equal to the given value.
1462    *
1463    * @param value
1464    * the given value.
1465    * @return <code>0</code>.
1466    */
 
1467  10 toggle public static float eq(final float value) {
1468  10 reportMatcher(new Equals(value));
1469  10 return 0;
1470    }
1471   
1472    /**
1473    * Expects an int that is equal to the given value.
1474    *
1475    * @param value
1476    * the given value.
1477    * @return <code>0</code>.
1478    */
 
1479  40 toggle public static int eq(final int value) {
1480  40 reportMatcher(new Equals(value));
1481  40 return 0;
1482    }
1483   
1484    /**
1485    * Expects a long that is equal to the given value.
1486    *
1487    * @param value
1488    * the given value.
1489    * @return <code>0</code>.
1490    */
 
1491  10 toggle public static long eq(final long value) {
1492  10 reportMatcher(new Equals(value));
1493  10 return 0;
1494    }
1495   
1496    /**
1497    * Expects a short that is equal to the given value.
1498    *
1499    * @param value
1500    * the given value.
1501    * @return <code>0</code>.
1502    */
 
1503  10 toggle public static short eq(final short value) {
1504  10 reportMatcher(new Equals(value));
1505  10 return 0;
1506    }
1507   
1508    /**
1509    * Expects an Object that is equal to the given value.
1510    *
1511    * @param <T>
1512    * type of the method argument to match
1513    * @param value
1514    * the given value.
1515    * @return <code>null</code>.
1516    */
 
1517  34 toggle public static <T> T eq(final T value) {
1518  34 reportMatcher(new Equals(value));
1519  34 return null;
1520    }
1521   
1522    /**
1523    * Expects a boolean array that is equal to the given array, i.e. it has to
1524    * have the same length, and each element has to be equal.
1525    *
1526    * @param value
1527    * the given arry.
1528    * @return <code>null</code>.
1529    */
 
1530  2 toggle public static boolean[] aryEq(final boolean[] value) {
1531  2 reportMatcher(new ArrayEquals(value));
1532  2 return null;
1533    }
1534   
1535    /**
1536    * Expects a byte array that is equal to the given array, i.e. it has to
1537    * have the same length, and each element has to be equal.
1538    *
1539    * @param value
1540    * the given arry.
1541    * @return <code>null</code>.
1542    */
 
1543  2 toggle public static byte[] aryEq(final byte[] value) {
1544  2 reportMatcher(new ArrayEquals(value));
1545  2 return null;
1546    }
1547   
1548    /**
1549    * Expects a char array that is equal to the given array, i.e. it has to
1550    * have the same length, and each element has to be equal.
1551    *
1552    * @param value
1553    * the given arry.
1554    * @return <code>null</code>.
1555    */
 
1556  2 toggle public static char[] aryEq(final char[] value) {
1557  2 reportMatcher(new ArrayEquals(value));
1558  2 return null;
1559    }
1560   
1561    /**
1562    * Expects a double array that is equal to the given array, i.e. it has to
1563    * have the same length, and each element has to be equal.
1564    *
1565    * @param value
1566    * the given arry.
1567    * @return <code>null</code>.
1568    */
 
1569  2 toggle public static double[] aryEq(final double[] value) {
1570  2 reportMatcher(new ArrayEquals(value));
1571  2 return null;
1572    }
1573   
1574    /**
1575    * Expects a float array that is equal to the given array, i.e. it has to
1576    * have the same length, and each element has to be equal.
1577    *
1578    * @param value
1579    * the given arry.
1580    * @return <code>null</code>.
1581    */
 
1582  2 toggle public static float[] aryEq(final float[] value) {
1583  2 reportMatcher(new ArrayEquals(value));
1584  2 return null;
1585    }
1586   
1587    /**
1588    * Expects an int array that is equal to the given array, i.e. it has to
1589    * have the same length, and each element has to be equal.
1590    *
1591    * @param value
1592    * the given arry.
1593    * @return <code>null</code>.
1594    */
 
1595  2 toggle public static int[] aryEq(final int[] value) {
1596  2 reportMatcher(new ArrayEquals(value));
1597  2 return null;
1598    }
1599   
1600    /**
1601    * Expects a long array that is equal to the given array, i.e. it has to
1602    * have the same length, and each element has to be equal.
1603    *
1604    * @param value
1605    * the given arry.
1606    * @return <code>null</code>.
1607    */
 
1608  2 toggle public static long[] aryEq(final long[] value) {
1609  2 reportMatcher(new ArrayEquals(value));
1610  2 return null;
1611    }
1612   
1613    /**
1614    * Expects a short array that is equal to the given array, i.e. it has to
1615    * have the same length, and each element has to be equal.
1616    *
1617    * @param value
1618    * the given arry.
1619    * @return <code>null</code>.
1620    */
 
1621  2 toggle public static short[] aryEq(final short[] value) {
1622  2 reportMatcher(new ArrayEquals(value));
1623  2 return null;
1624    }
1625   
1626    /**
1627    * Expects an Object array that is equal to the given array, i.e. it has to
1628    * have the same type, length, and each element has to be equal.
1629    *
1630    * @param <T>
1631    * the type of the array, it is passed through to prevent casts.
1632    * @param value
1633    * the given arry.
1634    * @return <code>null</code>.
1635    */
 
1636  10 toggle public static <T> T[] aryEq(final T[] value) {
1637  10 reportMatcher(new ArrayEquals(value));
1638  10 return null;
1639    }
1640   
1641    /**
1642    * Expects null. To work well with generics, this matcher (and
1643    * {@link #isNull(Class)}) can be used in these three ways:
1644    * <ul>
1645    * <li><code>(T)EasyMock.isNull() // explicit cast</code></li>
1646    * <li>
1647    * <code>EasyMock.&lt;T&gt; isNull() // fixing the returned generic</code></li>
1648    * <li>
1649    * <code>EasyMock.isNull(T.class) // pass the returned type in parameter</code>
1650    * </li>
1651    * </ul>
1652    *
1653    * @param <T>
1654    * type of the method argument to match
1655    * @return <code>null</code>.
1656    */
 
1657  10 toggle public static <T> T isNull() {
1658  10 reportMatcher(Null.NULL);
1659  10 return null;
1660    }
1661   
1662    /**
1663    * Expects null. To work well with generics, this matcher can be used in
1664    * three different ways. See {@link #isNull()}.
1665    *
1666    * @param <T>
1667    * type of the method argument to match
1668    * @param clazz
1669    * the class of the argument to match
1670    * @return <code>null</code>.
1671    *
1672    * @see #isNull()
1673    */
 
1674  2 toggle public static <T> T isNull(final Class<T> clazz) {
1675  2 reportMatcher(Null.NULL);
1676  2 return null;
1677    }
1678   
1679    /**
1680    * Expects not null. To work well with generics, this matcher (and
1681    * {@link #notNull(Class)}) can be used in these three ways:
1682    * <ul>
1683    * <li><code>(T)EasyMock.notNull() // explicit cast</code></li>
1684    * <li>
1685    * <code>EasyMock.&lt;T&gt; notNull() // fixing the returned generic</code></li>
1686    * <li>
1687    * <code>EasyMock.notNull(T.class) // pass the returned type in parameter</code>
1688    * </li>
1689    * </ul>
1690    *
1691    * @param <T>
1692    * type of the method argument to match
1693    * @return <code>null</code>.
1694    */
 
1695  10 toggle public static <T> T notNull() {
1696  10 reportMatcher(NotNull.NOT_NULL);
1697  10 return null;
1698    }
1699   
1700    /**
1701    * Expects not null. To work well with generics, this matcher can be used in
1702    * three different ways. See {@link #notNull()}.
1703    *
1704    * @param <T>
1705    * type of the method argument to match
1706    * @param clazz
1707    * the class of the argument to match
1708    * @return <code>null</code>.
1709    *
1710    * @see #notNull()
1711    */
 
1712  2 toggle public static <T> T notNull(final Class<T> clazz) {
1713  2 reportMatcher(NotNull.NOT_NULL);
1714  2 return null;
1715    }
1716   
1717    /**
1718    * Expects a string that contains a substring that matches the given regular
1719    * expression. For details, see the EasyMock documentation.
1720    *
1721    * @param regex
1722    * the regular expression.
1723    * @return <code>null</code>.
1724    */
 
1725  4 toggle public static String find(final String regex) {
1726  4 reportMatcher(new Find(regex));
1727  4 return null;
1728    }
1729   
1730    /**
1731    * Expects a string that matches the given regular expression. For details,
1732    * see the EasyMock documentation.
1733    *
1734    * @param regex
1735    * the regular expression.
1736    * @return <code>null</code>.
1737    */
 
1738  4 toggle public static String matches(final String regex) {
1739  4 reportMatcher(new Matches(regex));
1740  4 return null;
1741    }
1742   
1743    /**
1744    * Expects a string that starts with the given prefix. For details, see the
1745    * EasyMock documentation.
1746    *
1747    * @param prefix
1748    * the prefix.
1749    * @return <code>null</code>.
1750    */
 
1751  4 toggle public static String startsWith(final String prefix) {
1752  4 reportMatcher(new StartsWith(prefix));
1753  4 return null;
1754    }
1755   
1756    /**
1757    * Expects a string that ends with the given suffix. For details, see the
1758    * EasyMock documentation.
1759    *
1760    * @param suffix
1761    * the suffix.
1762    * @return <code>null</code>.
1763    */
 
1764  4 toggle public static String endsWith(final String suffix) {
1765  4 reportMatcher(new EndsWith(suffix));
1766  4 return null;
1767    }
1768   
1769    /**
1770    * Expects a double that has an absolute difference to the given value that
1771    * is less than the given delta. For details, see the EasyMock
1772    * documentation.
1773    *
1774    * @param value
1775    * the given value.
1776    * @param delta
1777    * the given delta.
1778    * @return <code>0</code>.
1779    */
 
1780  4 toggle public static double eq(final double value, final double delta) {
1781  4 reportMatcher(new EqualsWithDelta(value, delta));
1782  4 return 0;
1783    }
1784   
1785    /**
1786    * Expects a float that has an absolute difference to the given value that
1787    * is less than the given delta. For details, see the EasyMock
1788    * documentation.
1789    *
1790    * @param value
1791    * the given value.
1792    * @param delta
1793    * the given delta.
1794    * @return <code>0</code>.
1795    */
 
1796  6 toggle public static float eq(final float value, final float delta) {
1797  6 reportMatcher(new EqualsWithDelta(value, delta));
1798  6 return 0;
1799    }
1800   
1801    /**
1802    * Expects an Object that is the same as the given value. For details, see
1803    * the EasyMock documentation.
1804    *
1805    * @param <T>
1806    * the type of the object, it is passed through to prevent casts.
1807    * @param value
1808    * the given value.
1809    * @return <code>null</code>.
1810    */
 
1811  4 toggle public static <T> T same(final T value) {
1812  4 reportMatcher(new Same(value));
1813  4 return null;
1814    }
1815   
1816    /**
1817    * Expects a comparable argument equals to the given value according to
1818    * their compareTo method. For details, see the EasMock documentation.
1819    *
1820    * @param <T>
1821    * type of the method argument to match
1822    * @param value
1823    * the given value.
1824    * @return <code>null</code>.
1825    */
 
1826  4 toggle public static <T extends Comparable<T>> T cmpEq(final Comparable<T> value) {
1827  4 reportMatcher(new CompareEqual<T>(value));
1828  4 return null;
1829    }
1830   
1831    /**
1832    * Expects an argument that will be compared using the provided comparator.
1833    * The following comparison will take place:
1834    * <p>
1835    * <code>comparator.compare(actual, expected) operator 0</code>
1836    * </p>
1837    * For details, see the EasyMock documentation.
1838    *
1839    * @param <T>
1840    * type of the method argument to match
1841    * @param value
1842    * the given value.
1843    * @param comparator
1844    * Comparator used to compare the actual with expected value.
1845    * @param operator
1846    * The comparison operator.
1847    * @return <code>null</code>
1848    */
 
1849  14 toggle public static <T> T cmp(final T value, final Comparator<? super T> comparator,
1850    final LogicalOperator operator) {
1851  14 reportMatcher(new Compare<T>(value, comparator, operator));
1852  14 return null;
1853    }
1854   
1855    /**
1856    * Expects a byte that is equal to the given value.
1857    *
1858    * @param value
1859    * the given value.
1860    * @return <code>0</code>.
1861    */
1862   
1863    /**
1864    * Expect any object but captures it for later use.
1865    *
1866    * @param <T>
1867    * Type of the captured object
1868    * @param captured
1869    * Where the parameter is captured
1870    * @return <code>null</code>
1871    */
 
1872  34 toggle public static <T> T capture(final Capture<T> captured) {
1873  34 reportMatcher(new Captures<T>(captured));
1874  34 return null;
1875    }
1876   
1877    /**
1878    * Expect any boolean but captures it for later use.
1879    *
1880    * @param captured
1881    * Where the parameter is captured
1882    * @return <code>false</code>
1883    */
 
1884  2 toggle public static boolean capture(final Capture<Boolean> captured) {
1885  2 reportMatcher(new Captures<Boolean>(captured));
1886  2 return false;
1887    }
1888   
1889    /**
1890    * Expect any int but captures it for later use.
1891    *
1892    * @param captured
1893    * Where the parameter is captured
1894    * @return <code>0</code>
1895    */
 
1896  46 toggle public static int capture(final Capture<Integer> captured) {
1897  46 reportMatcher(new Captures<Integer>(captured));
1898  46 return 0;
1899    }
1900   
1901    /**
1902    * Expect any long but captures it for later use.
1903    *
1904    * @param captured
1905    * Where the parameter is captured
1906    * @return <code>0</code>
1907    */
 
1908  2 toggle public static long capture(final Capture<Long> captured) {
1909  2 reportMatcher(new Captures<Long>(captured));
1910  2 return 0;
1911    }
1912   
1913    /**
1914    * Expect any float but captures it for later use.
1915    *
1916    * @param captured
1917    * Where the parameter is captured
1918    * @return <code>0</code>
1919    */
 
1920  2 toggle public static float capture(final Capture<Float> captured) {
1921  2 reportMatcher(new Captures<Float>(captured));
1922  2 return 0;
1923    }
1924   
1925    /**
1926    * Expect any double but captures it for later use.
1927    *
1928    * @param captured
1929    * Where the parameter is captured
1930    * @return <code>0</code>
1931    */
 
1932  2 toggle public static double capture(final Capture<Double> captured) {
1933  2 reportMatcher(new Captures<Double>(captured));
1934  2 return 0;
1935    }
1936   
1937    /**
1938    * Expect any byte but captures it for later use.
1939    *
1940    * @param captured
1941    * Where the parameter is captured
1942    * @return <code>0</code>
1943    */
 
1944  2 toggle public static byte capture(final Capture<Byte> captured) {
1945  2 reportMatcher(new Captures<Byte>(captured));
1946  2 return 0;
1947    }
1948   
1949    /**
1950    * Expect any char but captures it for later use.
1951    *
1952    * @param captured
1953    * Where the parameter is captured
1954    * @return <code>0</code>
1955    */
 
1956  2 toggle public static char capture(final Capture<Character> captured) {
1957  2 reportMatcher(new Captures<Character>(captured));
1958  2 return 0;
1959    }
1960   
1961    /**
1962    * Switches the given mock objects (more exactly: the controls of the mock
1963    * objects) to replay mode. For details, see the EasyMock documentation.
1964    *
1965    * @param mocks
1966    * the mock objects.
1967    */
 
1968  668 toggle public static void replay(final Object... mocks) {
1969  668 for (final Object mock : mocks) {
1970  676 getControl(mock).replay();
1971    }
1972    }
1973   
1974    /**
1975    * Resets the given mock objects (more exactly: the controls of the mock
1976    * objects). For details, see the EasyMock documentation.
1977    *
1978    * @param mocks
1979    * the mock objects.
1980    */
 
1981  58 toggle public static void reset(final Object... mocks) {
1982  58 for (final Object mock : mocks) {
1983  60 getControl(mock).reset();
1984    }
1985    }
1986   
1987    /**
1988    * Resets the given mock objects (more exactly: the controls of the mock
1989    * objects) and turn them to a mock with nice behavior. For details, see the
1990    * EasyMock documentation.
1991    *
1992    * @param mocks
1993    * the mock objects
1994    */
 
1995  4 toggle public static void resetToNice(final Object... mocks) {
1996  4 for (final Object mock : mocks) {
1997  4 getControl(mock).resetToNice();
1998    }
1999    }
2000   
2001    /**
2002    * Resets the given mock objects (more exactly: the controls of the mock
2003    * objects) and turn them to a mock with default behavior. For details, see
2004    * the EasyMock documentation.
2005    *
2006    * @param mocks
2007    * the mock objects
2008    */
 
2009  4 toggle public static void resetToDefault(final Object... mocks) {
2010  4 for (final Object mock : mocks) {
2011  4 getControl(mock).resetToDefault();
2012    }
2013    }
2014   
2015    /**
2016    * Resets the given mock objects (more exactly: the controls of the mock
2017    * objects) and turn them to a mock with strict behavior. For details, see
2018    * the EasyMock documentation.
2019    *
2020    * @param mocks
2021    * the mock objects
2022    */
 
2023  4 toggle public static void resetToStrict(final Object... mocks) {
2024  4 for (final Object mock : mocks) {
2025  4 getControl(mock).resetToStrict();
2026    }
2027    }
2028   
2029    /**
2030    * Verifies the given mock objects (more exactly: the controls of the mock
2031    * objects).
2032    *
2033    * @param mocks
2034    * the mock objects.
2035    */
 
2036  482 toggle public static void verify(final Object... mocks) {
2037  482 for (final Object mock : mocks) {
2038  490 getControl(mock).verify();
2039    }
2040    }
2041   
2042    /**
2043    * Switches order checking of the given mock object (more exactly: the
2044    * control of the mock object) the on and off. For details, see the EasyMock
2045    * documentation.
2046    *
2047    * @param mock
2048    * the mock object.
2049    * @param state
2050    * <code>true</code> switches order checking on,
2051    * <code>false</code> switches it off.
2052    */
 
2053  8 toggle public static void checkOrder(final Object mock, final boolean state) {
2054  8 getControl(mock).checkOrder(state);
2055    }
2056   
2057    /**
2058    * Reports an argument matcher. This method is needed to define own argument
2059    * matchers. For details, see the EasyMock documentation.
2060    *
2061    * @param matcher
2062    */
 
2063  532 toggle public static void reportMatcher(final IArgumentMatcher matcher) {
2064  532 LastControl.reportMatcher(matcher);
2065    }
2066   
 
2067  1254 toggle private static MocksControl getControl(final Object mock) {
2068  1254 return ClassExtensionHelper.getControl(mock);
2069    }
2070   
2071    /**
2072    * Returns the arguments of the current mock method call, if inside an
2073    * <code>IAnswer</code> callback - be careful here, reordering parameters of
2074    * method changes the semantics of your tests.
2075    *
2076    * @return the arguments of the current mock method call.
2077    * @throws IllegalStateException
2078    * if called outside of <code>IAnswer</code> callbacks.
2079    */
 
2080  26 toggle public static Object[] getCurrentArguments() {
2081  26 final Invocation result = LastControl.getCurrentInvocation();
2082  26 if (result == null) {
2083  2 throw new IllegalStateException(
2084    "current arguments are only available when executing callback methods");
2085    }
2086  24 return result.getArguments();
2087    }
2088   
2089    /**
2090    * By default, a mock is thread safe (unless
2091    * {@link #NOT_THREAD_SAFE_BY_DEFAULT} is set). This method can change this
2092    * behavior. Two reasons are known for someone to do that: Performance or
2093    * dead-locking issues.
2094    *
2095    * @param mock
2096    * the mock to make thread safe
2097    * @param threadSafe
2098    * If the mock should be thread safe or not
2099    */
 
2100  4 toggle public static void makeThreadSafe(final Object mock, final boolean threadSafe) {
2101  4 getControl(mock).makeThreadSafe(threadSafe);
2102    }
2103   
2104    /**
2105    * Tell that the mock should be used in only one thread. An exception will
2106    * be thrown if that's not the case. This can be useful when mocking an
2107    * object that isn't thread safe to make sure it is used correctly in a
2108    * multithreaded environment. By default, no check is done unless
2109    * {@link #ENABLE_THREAD_SAFETY_CHECK_BY_DEFAULT} was set to true.
2110    *
2111    * @param mock
2112    * the mock
2113    * @param shouldBeUsedInOneThread
2114    * If the mock should be used in only one thread
2115    */
 
2116  4 toggle public static void checkIsUsedInOneThread(final Object mock, final boolean shouldBeUsedInOneThread) {
2117  4 getControl(mock).checkIsUsedInOneThread(shouldBeUsedInOneThread);
2118    }
2119   
2120    /**
2121    * Get the current value for an EasyMock property
2122    *
2123    * @param key
2124    * key for the property
2125    * @return the property value
2126    */
 
2127  22 toggle public static String getEasyMockProperty(final String key) {
2128  22 return EasyMockProperties.getInstance().getProperty(key);
2129    }
2130   
2131    /**
2132    * Set a property to modify the default EasyMock behavior. These properties
2133    * can also be set as System properties or in easymock.properties. This
2134    * method can then be called to overload them. For details and a list of
2135    * available properties see the EasyMock documentation.
2136    * <p>
2137    * <b>Note:</b> This method is static. Setting a property will change the
2138    * entire EasyMock behavior.
2139    *
2140    * @param key
2141    * property key
2142    * @param value
2143    * property value. A null value will remove the property
2144    * @return the previous property value
2145    */
 
2146  12 toggle public static String setEasyMockProperty(final String key, final String value) {
2147  12 return EasyMockProperties.getInstance().setProperty(key, value);
2148    }
2149   
2150    // ///CLOVER:OFF
 
2151    toggle protected EasyMock() { // Need to be protected since the Class extension extends it
2152    }
2153    // ///CLOVER:ON
2154    }