org.easymock
Class MockControl

java.lang.Object
  extended byorg.easymock.MockControl

public class MockControl
extends java.lang.Object

A MockControl object controls the behavior of its associated mock object. For more information, see the EasyMock documentation.


Field Summary
static ArgumentsMatcher ALWAYS_MATCHER
          Matches always.
static ArgumentsMatcher ARRAY_MATCHER
          Matches if each expected argument is equal to the corresponding actual argument for non-array arguments; array arguments are compared with the appropriate java.util.Arrays.equals() -method.
static ArgumentsMatcher EQUALS_MATCHER
          Matches if each expected argument is equal to the corresponding actual argument.
protected static org.easymock.internal.IBehaviorFactory NICE_BEHAVIOR_FACTORY
          internal constant with protected visibility to allow access for extensions.
static org.easymock.internal.Range ONE
          Exactly one call.
static org.easymock.internal.Range ONE_OR_MORE
          One or more calls.
protected static org.easymock.internal.IBehaviorFactory ORDERED_BEHAVIOR_FACTORY
          internal constant with protected visibility to allow access for extensions.
protected static org.easymock.internal.IBehaviorFactory UNORDERED_BEHAVIOR_FACTORY
          internal constant with protected visibility to allow access for extensions.
static org.easymock.internal.Range ZERO_OR_MORE
          Zero or more calls.
 
Constructor Summary
protected MockControl(java.lang.Class toMock, org.easymock.internal.IProxyFactory proxyFactory, org.easymock.internal.IBehaviorFactory behaviorFactory)
          Creates a new mock control object using the provided proxy and behavior factory - this is an internal constructor with protected visibility to allow access for extensions.
 
Method Summary
static MockControl createControl(java.lang.Class toMock)
          Creates a mock control object for the specified interface.
static MockControl createNiceControl(java.lang.Class toMock)
          Creates a mock control object for the specified interface.
static MockControl createStrictControl(java.lang.Class toMock)
          Creates a mock control object for the specified interface.
 void expectAndDefaultReturn(boolean ignored, boolean value)
          Same as setDefaultReturnValue(boolean).
 void expectAndDefaultReturn(double ignored, double value)
          Same as setDefaultReturnValue(double).
 void expectAndDefaultReturn(float ignored, float value)
          Same as setDefaultReturnValue(float).
 void expectAndDefaultReturn(long ignored, long value)
          Same as setDefaultReturnValue(long).
 void expectAndDefaultReturn(java.lang.Object ignored, java.lang.Object value)
          Same as setDefaultReturnValue(Object).
 void expectAndDefaultThrow(boolean ignored, java.lang.Throwable throwable)
          Same as setDefaultThrowable(Throwable).
 void expectAndDefaultThrow(double ignored, java.lang.Throwable throwable)
          Same as setDefaultThrowable(Throwable).
 void expectAndDefaultThrow(float ignored, java.lang.Throwable throwable)
          Same as setDefaultThrowable(Throwable).
 void expectAndDefaultThrow(long ignored, java.lang.Throwable throwable)
          Same as setDefaultThrowable(Throwable).
 void expectAndDefaultThrow(java.lang.Object ignored, java.lang.Throwable throwable)
          Same as setDefaultThrowable(Throwable).
 void expectAndReturn(boolean ignored, boolean value)
          Same as setReturnValue(boolean).
 void expectAndReturn(boolean ignored, boolean value, int count)
          Same as setReturnValue(boolean, int).
 void expectAndReturn(boolean ignored, boolean value, int min, int max)
          Same as setReturnValue(boolean, int, int).
 void expectAndReturn(boolean ignored, boolean value, org.easymock.internal.Range range)
          Same as setReturnValue(boolean, Range).
 void expectAndReturn(double ignored, double value)
          Same as setReturnValue(double).
 void expectAndReturn(double ignored, double value, int count)
          Same as setReturnValue(double, int).
 void expectAndReturn(double ignored, double value, int min, int max)
          Same as setReturnValue(double, int, int).
 void expectAndReturn(double ignored, double value, org.easymock.internal.Range range)
          Same as setReturnValue(double, Range).
 void expectAndReturn(float ignored, float value)
          Same as setReturnValue(float).
 void expectAndReturn(float ignored, float value, int count)
          Same as setReturnValue(float, int).
 void expectAndReturn(float ignored, float value, int min, int max)
          Same as setReturnValue(float, int, int).
 void expectAndReturn(float ignored, float value, org.easymock.internal.Range range)
          Same as setReturnValue(float, Range).
 void expectAndReturn(long ignored, long value)
          Same as setReturnValue(long).
 void expectAndReturn(long ignored, long value, int count)
          Same as setReturnValue(long, int).
 void expectAndReturn(long ignored, long value, int min, int max)
          Same as setReturnValue(long, int, int).
 void expectAndReturn(long ignored, long value, org.easymock.internal.Range range)
          Same as setReturnValue(long, Range).
 void expectAndReturn(java.lang.Object ignored, java.lang.Object value)
          Same as setReturnValue(Object).
 void expectAndReturn(java.lang.Object ignored, java.lang.Object value, int count)
          Same as setReturnValue(Object, int).
 void expectAndReturn(java.lang.Object ignored, java.lang.Object value, int min, int max)
          Same as setReturnValue(Object, int, int).
 void expectAndReturn(java.lang.Object ignored, java.lang.Object value, org.easymock.internal.Range range)
          Same as setReturnValue(Object, Range).
 void expectAndThrow(boolean ignored, java.lang.Throwable throwable)
          Same as setThrowable(Throwable).
 void expectAndThrow(boolean ignored, java.lang.Throwable throwable, int count)
          Same as setThrowable(Throwable, int).
 void expectAndThrow(boolean ignored, java.lang.Throwable throwable, int min, int max)
          Same as setThrowable(Throwable, int, int).
 void expectAndThrow(boolean ignored, java.lang.Throwable throwable, org.easymock.internal.Range range)
          Same as setThrowable(Throwable, Range).
 void expectAndThrow(double ignored, java.lang.Throwable throwable)
          Same as setThrowable(Throwable).
 void expectAndThrow(double ignored, java.lang.Throwable throwable, int count)
          Same as setThrowable(Throwable, int).
 void expectAndThrow(double ignored, java.lang.Throwable throwable, int min, int max)
          Same as setThrowable(Throwable, int, int).
 void expectAndThrow(double ignored, java.lang.Throwable throwable, org.easymock.internal.Range range)
          Same as setThrowable(Throwable, Range).
 void expectAndThrow(float ignored, java.lang.Throwable throwable)
          Same as setThrowable(Throwable).
 void expectAndThrow(float ignored, java.lang.Throwable throwable, int count)
          Same as setThrowable(Throwable, int).
 void expectAndThrow(float ignored, java.lang.Throwable throwable, int min, int max)
          Same as setThrowable(Throwable, int, int).
 void expectAndThrow(float ignored, java.lang.Throwable throwable, org.easymock.internal.Range range)
          Same as setThrowable(Throwable, Range).
 void expectAndThrow(long ignored, java.lang.Throwable throwable)
          Same as setThrowable(Throwable).
 void expectAndThrow(long ignored, java.lang.Throwable throwable, int count)
          Same as setThrowable(Throwable, int).
 void expectAndThrow(long ignored, java.lang.Throwable throwable, int min, int max)
          Same as setThrowable(Throwable, int, int).
 void expectAndThrow(long ignored, java.lang.Throwable throwable, org.easymock.internal.Range range)
          Same as setThrowable(Throwable, Range).
 void expectAndThrow(java.lang.Object ignored, java.lang.Throwable throwable)
          Same as setThrowable(Throwable).
 void expectAndThrow(java.lang.Object ignored, java.lang.Throwable throwable, int count)
          Same as setThrowable(Throwable, int).
 void expectAndThrow(java.lang.Object ignored, java.lang.Throwable throwable, int min, int max)
          Same as setThrowable(Throwable, int, int).
 void expectAndThrow(java.lang.Object ignored, java.lang.Throwable throwable, org.easymock.internal.Range range)
          Same as setThrowable(Throwable, Range).
 java.lang.Object getMock()
          Returns the mock object.
 void replay()
          Switches the mock object from record state to replay state.
 void reset()
          Resets the mock control and the mock object to the state directly after creation.
 void setDefaultMatcher(ArgumentsMatcher matcher)
          Sets the default ArgumentsMatcher for all methods of the mock object.
 void setDefaultReturnValue(boolean value)
          Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.
 void setDefaultReturnValue(double value)
          Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.
 void setDefaultReturnValue(float value)
          Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.
 void setDefaultReturnValue(long value)
          Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.
 void setDefaultReturnValue(java.lang.Object value)
          Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.
 void setDefaultThrowable(java.lang.Throwable throwable)
          Records that the mock object will by default allow the last method specified by a method call, and will react by throwing the provided Throwable.
 void setDefaultVoidCallable()
          Records that the mock object will by default allow the last method specified by a method call.
 void setMatcher(ArgumentsMatcher matcher)
          Sets the ArgumentsMatcher for the last method called on the mock object.
 void setReturnValue(boolean value)
          Records that the mock object will expect the last method call once, and will react by returning the provided return value.
 void setReturnValue(boolean value, int times)
          Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.
 void setReturnValue(boolean value, int minCount, int maxCount)
          Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.
 void setReturnValue(boolean value, org.easymock.internal.Range range)
          Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value.
 void setReturnValue(double value)
          Records that the mock object will expect the last method call once, and will react by returning the provided return value.
 void setReturnValue(double value, int times)
          Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.
 void setReturnValue(double value, int minCount, int maxCount)
          Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.
 void setReturnValue(double value, org.easymock.internal.Range range)
          Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value.
 void setReturnValue(float value)
          Records that the mock object will expect the last method call once, and will react by returning the provided return value.
 void setReturnValue(float value, int times)
          Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.
 void setReturnValue(float value, int minCount, int maxCount)
          Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.
 void setReturnValue(float value, org.easymock.internal.Range range)
          Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value.
 void setReturnValue(long value)
          Records that the mock object will expect the last method call once, and will react by returning the provided return value.
 void setReturnValue(long value, int times)
          Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.
 void setReturnValue(long value, int minCount, int maxCount)
          Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.
 void setReturnValue(long value, org.easymock.internal.Range range)
          Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value.
 void setReturnValue(java.lang.Object value)
          Records that the mock object will expect the last method call once, and will react by returning the provided return value.
 void setReturnValue(java.lang.Object value, int times)
          Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.
 void setReturnValue(java.lang.Object value, int minCount, int maxCount)
          Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.
 void setReturnValue(java.lang.Object value, org.easymock.internal.Range range)
          Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value.
 void setThrowable(java.lang.Throwable throwable)
          Records that the mock object will expect the last method call once, and will react by throwing the provided Throwable.
 void setThrowable(java.lang.Throwable throwable, int times)
          Records that the mock object will expect the last method call a fixed number of times, and will react by throwing the provided Throwable.
 void setThrowable(java.lang.Throwable throwable, int minCount, int maxCount)
          Records that the mock object will expect the last method call between minCount and maxCount times, and will react by throwing the provided Throwable.
 void setThrowable(java.lang.Throwable throwable, org.easymock.internal.Range range)
          Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by throwing the provided Throwable.
 void setVoidCallable()
          Records that the mock object will expect the last method call once, and will react by returning silently.
 void setVoidCallable(int times)
          Records that the mock object will expect the last method call a fixed number of times, and will react by returning silently.
 void setVoidCallable(int minCount, int maxCount)
          Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning silently.
 void setVoidCallable(org.easymock.internal.Range range)
          Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning silently.
 void verify()
          Verifies that all expectations have been met.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NICE_BEHAVIOR_FACTORY

protected static final org.easymock.internal.IBehaviorFactory NICE_BEHAVIOR_FACTORY
internal constant with protected visibility to allow access for extensions.


ORDERED_BEHAVIOR_FACTORY

protected static final org.easymock.internal.IBehaviorFactory ORDERED_BEHAVIOR_FACTORY
internal constant with protected visibility to allow access for extensions.


UNORDERED_BEHAVIOR_FACTORY

protected static final org.easymock.internal.IBehaviorFactory UNORDERED_BEHAVIOR_FACTORY
internal constant with protected visibility to allow access for extensions.


ONE

public static final org.easymock.internal.Range ONE
Exactly one call.


ONE_OR_MORE

public static final org.easymock.internal.Range ONE_OR_MORE
One or more calls.


ZERO_OR_MORE

public static final org.easymock.internal.Range ZERO_OR_MORE
Zero or more calls.


EQUALS_MATCHER

public static final ArgumentsMatcher EQUALS_MATCHER
Matches if each expected argument is equal to the corresponding actual argument.


ALWAYS_MATCHER

public static final ArgumentsMatcher ALWAYS_MATCHER
Matches always.


ARRAY_MATCHER

public static final ArgumentsMatcher ARRAY_MATCHER
Matches if each expected argument is equal to the corresponding actual argument for non-array arguments; array arguments are compared with the appropriate java.util.Arrays.equals() -method.

Constructor Detail

MockControl

protected MockControl(java.lang.Class toMock,
                      org.easymock.internal.IProxyFactory proxyFactory,
                      org.easymock.internal.IBehaviorFactory behaviorFactory)
Creates a new mock control object using the provided proxy and behavior factory - this is an internal constructor with protected visibility to allow access for extensions.

Parameters:
toMock - the class of the interface to mock.
proxyFactory - the proxy factory.
behaviorFactory - the behavior factory.
Method Detail

createControl

public static MockControl createControl(java.lang.Class toMock)
Creates a mock control object for the specified interface. The MockControl and its associated mock object will not check the order of expected method calls. An unexpected method call on the mock object will lead to an AssertionFailedError.

Parameters:
toMock - the class of the interface to mock.
Returns:
the mock control.

createStrictControl

public static MockControl createStrictControl(java.lang.Class toMock)
Creates a mock control object for the specified interface. The MockControl and its associated mock object will check the order of expected method calls. An unexpected method call on the mock object will lead to an AssertionFailedError.

Parameters:
toMock - the class of the interface to mock.
Returns:
the mock control.

createNiceControl

public static MockControl createNiceControl(java.lang.Class toMock)
Creates a mock control object for the specified interface. The MockControl and its associated mock object will not check the order of expected method calls. An unexpected method call on the mock object will return an empty value (0, null, false).

Parameters:
toMock - the class of the interface to mock.
Returns:
the mock control.

getMock

public java.lang.Object getMock()
Returns the mock object.

Returns:
the mock object of this control

reset

public final void reset()
Resets the mock control and the mock object to the state directly after creation.


replay

public void replay()
Switches the mock object from record state to replay state. For more information, see the EasyMock documentation.

Throws:
java.lang.IllegalStateException - if the mock object already is in replay state.

verify

public void verify()
Verifies that all expectations have been met. For more information, see the EasyMock documentation.

Throws:
java.lang.IllegalStateException - if the mock object is in record state.
junit.framework.AssertionFailedError - if any expectation has not been met.

setVoidCallable

public void setVoidCallable()
Records that the mock object will expect the last method call once, and will react by returning silently.

Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setThrowable

public void setThrowable(java.lang.Throwable throwable)
Records that the mock object will expect the last method call once, and will react by throwing the provided Throwable.

Parameters:
throwable - the Throwable to throw.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state or if no method was called on the mock object before.
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.

setReturnValue

public void setReturnValue(boolean value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setReturnValue

public void setReturnValue(long value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return byte, short, char, int, or long.

setReturnValue

public void setReturnValue(float value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return float.

setReturnValue

public void setReturnValue(double value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return double.

setReturnValue

public void setReturnValue(java.lang.Object value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return an object.
java.lang.IllegalArgumentException - if the provided return value is not compatible to the return value of the last method called on the mock object.

setVoidCallable

public void setVoidCallable(int times)
Records that the mock object will expect the last method call a fixed number of times, and will react by returning silently.

Parameters:
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setThrowable

public void setThrowable(java.lang.Throwable throwable,
                         int times)
Records that the mock object will expect the last method call a fixed number of times, and will react by throwing the provided Throwable.

Parameters:
throwable - the Throwable to throw.
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state or if no method was called on the mock object before.
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.

setReturnValue

public void setReturnValue(boolean value,
                           int times)
Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.

Parameters:
value - the return value.
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setReturnValue

public void setReturnValue(double value,
                           int times)
Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.

Parameters:
value - the return value.
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return double.

setReturnValue

public void setReturnValue(float value,
                           int times)
Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.

Parameters:
value - the return value.
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return float.

setReturnValue

public void setReturnValue(long value,
                           int times)
Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.

Parameters:
value - the return value.
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return byte, short, char, int, or long.

setReturnValue

public void setReturnValue(java.lang.Object value,
                           int times)
Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.

Parameters:
value - the return value.
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return an object.
java.lang.IllegalArgumentException - if the provided return value is not compatible to the return value of the last method called on the mock object.

setVoidCallable

public void setVoidCallable(org.easymock.internal.Range range)
Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning silently. Available range arguments are:

Parameters:
range - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setThrowable

public void setThrowable(java.lang.Throwable throwable,
                         org.easymock.internal.Range range)
Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by throwing the provided Throwable. Available range arguments are:

Parameters:
throwable - the Throwable to throw.
range - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state or if no method was called on the mock object before.
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.

setReturnValue

public void setReturnValue(boolean value,
                           org.easymock.internal.Range range)
Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value. Available range arguments are:

Parameters:
value - the return value.
range - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setReturnValue

public void setReturnValue(double value,
                           org.easymock.internal.Range range)
Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value. Available range arguments are:

Parameters:
value - the return value.
range - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return double.

setReturnValue

public void setReturnValue(float value,
                           org.easymock.internal.Range range)
Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value. Available range arguments are:

Parameters:
value - the return value.
range - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return float.

setReturnValue

public void setReturnValue(long value,
                           org.easymock.internal.Range range)
Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value. Available range arguments are:

Parameters:
value - the return value.
range - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return byte, short, char, int, or long.

setReturnValue

public void setReturnValue(java.lang.Object value,
                           org.easymock.internal.Range range)
Records that the mock object will expect the last method call the number of times specified by the range argument, and will react by returning the provided return value. Available range arguments are:

Parameters:
value - the return value.
range - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return an object.
java.lang.IllegalArgumentException - if the provided return value is not compatible to the return value of the last method called on the mock object.

setDefaultVoidCallable

public void setDefaultVoidCallable()
Records that the mock object will by default allow the last method specified by a method call.

Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setDefaultThrowable

public void setDefaultThrowable(java.lang.Throwable throwable)
Records that the mock object will by default allow the last method specified by a method call, and will react by throwing the provided Throwable.

Parameters:
throwable - throwable the throwable to be thrown
Throws:
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.
java.lang.IllegalStateException - if the mock object is in replay state, or if no method was called on the mock object before.

setDefaultReturnValue

public void setDefaultReturnValue(boolean value)
Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setDefaultReturnValue

public void setDefaultReturnValue(long value)
Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return byte, short, char, int, or long.

setDefaultReturnValue

public void setDefaultReturnValue(float value)
Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return float.

setDefaultReturnValue

public void setDefaultReturnValue(double value)
Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return double.

setDefaultReturnValue

public void setDefaultReturnValue(java.lang.Object value)
Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return an object.
java.lang.IllegalArgumentException - if the provided return value is not compatible to the return value of the last method called on the mock object.

setMatcher

public void setMatcher(ArgumentsMatcher matcher)
Sets the ArgumentsMatcher for the last method called on the mock object. The matcher must be set before any behavior for the method is defined.

Throws:
java.lang.IllegalStateException - if called in replay state, or if no method was called on the mock object before.

setVoidCallable

public void setVoidCallable(int minCount,
                            int maxCount)
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning silently.

Parameters:
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setThrowable

public void setThrowable(java.lang.Throwable throwable,
                         int minCount,
                         int maxCount)
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by throwing the provided Throwable.

Parameters:
throwable - the Throwable to throw.
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state or if no method was called on the mock object before.
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.

setReturnValue

public void setReturnValue(boolean value,
                           int minCount,
                           int maxCount)
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.

Parameters:
value - the return value.
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setReturnValue

public void setReturnValue(long value,
                           int minCount,
                           int maxCount)
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.

Parameters:
value - the return value.
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return byte, short, char, int, or long.

setReturnValue

public void setReturnValue(float value,
                           int minCount,
                           int maxCount)
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.

Parameters:
value - the return value.
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return float.

setReturnValue

public void setReturnValue(double value,
                           int minCount,
                           int maxCount)
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.

Parameters:
value - the return value.
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return double.

setReturnValue

public void setReturnValue(java.lang.Object value,
                           int minCount,
                           int maxCount)
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.

Parameters:
value - the return value.
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return an object.
java.lang.IllegalArgumentException - if the provided return value is not compatible to the return value of the last method called on the mock object.

setDefaultMatcher

public void setDefaultMatcher(ArgumentsMatcher matcher)
Sets the default ArgumentsMatcher for all methods of the mock object. The matcher must be set before any behavior is defined on the mock object.

Throws:
java.lang.IllegalStateException - if called in replay state, or if any behavior is already defined on the mock object.

expectAndReturn

public void expectAndReturn(boolean ignored,
                            boolean value)
Same as setReturnValue(boolean). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(long ignored,
                            long value)
Same as setReturnValue(long). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(float ignored,
                            float value)
Same as setReturnValue(float). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(double ignored,
                            double value)
Same as setReturnValue(double). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(java.lang.Object ignored,
                            java.lang.Object value)
Same as setReturnValue(Object). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(boolean ignored,
                            boolean value,
                            org.easymock.internal.Range range)
Same as setReturnValue(boolean, Range). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(long ignored,
                            long value,
                            org.easymock.internal.Range range)
Same as setReturnValue(long, Range). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(float ignored,
                            float value,
                            org.easymock.internal.Range range)
Same as setReturnValue(float, Range). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(double ignored,
                            double value,
                            org.easymock.internal.Range range)
Same as setReturnValue(double, Range). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(java.lang.Object ignored,
                            java.lang.Object value,
                            org.easymock.internal.Range range)
Same as setReturnValue(Object, Range). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(boolean ignored,
                            boolean value,
                            int count)
Same as setReturnValue(boolean, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(long ignored,
                            long value,
                            int count)
Same as setReturnValue(long, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(float ignored,
                            float value,
                            int count)
Same as setReturnValue(float, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(double ignored,
                            double value,
                            int count)
Same as setReturnValue(double, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(java.lang.Object ignored,
                            java.lang.Object value,
                            int count)
Same as setReturnValue(Object, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(boolean ignored,
                            boolean value,
                            int min,
                            int max)
Same as setReturnValue(boolean, int, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(long ignored,
                            long value,
                            int min,
                            int max)
Same as setReturnValue(long, int, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(float ignored,
                            float value,
                            int min,
                            int max)
Same as setReturnValue(float, int, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(double ignored,
                            double value,
                            int min,
                            int max)
Same as setReturnValue(double, int, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndReturn

public void expectAndReturn(java.lang.Object ignored,
                            java.lang.Object value,
                            int min,
                            int max)
Same as setReturnValue(Object, int, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(boolean ignored,
                           java.lang.Throwable throwable)
Same as setThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(long ignored,
                           java.lang.Throwable throwable)
Same as setThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(float ignored,
                           java.lang.Throwable throwable)
Same as setThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(double ignored,
                           java.lang.Throwable throwable)
Same as setThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(java.lang.Object ignored,
                           java.lang.Throwable throwable)
Same as setThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(boolean ignored,
                           java.lang.Throwable throwable,
                           org.easymock.internal.Range range)
Same as setThrowable(Throwable, Range). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(long ignored,
                           java.lang.Throwable throwable,
                           org.easymock.internal.Range range)
Same as setThrowable(Throwable, Range). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(float ignored,
                           java.lang.Throwable throwable,
                           org.easymock.internal.Range range)
Same as setThrowable(Throwable, Range). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(double ignored,
                           java.lang.Throwable throwable,
                           org.easymock.internal.Range range)
Same as setThrowable(Throwable, Range). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(java.lang.Object ignored,
                           java.lang.Throwable throwable,
                           org.easymock.internal.Range range)
Same as setThrowable(Throwable, Range). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(boolean ignored,
                           java.lang.Throwable throwable,
                           int count)
Same as setThrowable(Throwable, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(long ignored,
                           java.lang.Throwable throwable,
                           int count)
Same as setThrowable(Throwable, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(float ignored,
                           java.lang.Throwable throwable,
                           int count)
Same as setThrowable(Throwable, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(double ignored,
                           java.lang.Throwable throwable,
                           int count)
Same as setThrowable(Throwable, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(java.lang.Object ignored,
                           java.lang.Throwable throwable,
                           int count)
Same as setThrowable(Throwable, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(boolean ignored,
                           java.lang.Throwable throwable,
                           int min,
                           int max)
Same as setThrowable(Throwable, int, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(long ignored,
                           java.lang.Throwable throwable,
                           int min,
                           int max)
Same as setThrowable(Throwable, int, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(float ignored,
                           java.lang.Throwable throwable,
                           int min,
                           int max)
Same as setThrowable(Throwable, int, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(double ignored,
                           java.lang.Throwable throwable,
                           int min,
                           int max)
Same as setThrowable(Throwable, int, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndThrow

public void expectAndThrow(java.lang.Object ignored,
                           java.lang.Throwable throwable,
                           int min,
                           int max)
Same as setThrowable(Throwable, int, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultReturn

public void expectAndDefaultReturn(boolean ignored,
                                   boolean value)
Same as setDefaultReturnValue(boolean). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultReturn

public void expectAndDefaultReturn(long ignored,
                                   long value)
Same as setDefaultReturnValue(long). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultReturn

public void expectAndDefaultReturn(float ignored,
                                   float value)
Same as setDefaultReturnValue(float). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultReturn

public void expectAndDefaultReturn(double ignored,
                                   double value)
Same as setDefaultReturnValue(double). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultReturn

public void expectAndDefaultReturn(java.lang.Object ignored,
                                   java.lang.Object value)
Same as setDefaultReturnValue(Object). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultThrow

public void expectAndDefaultThrow(boolean ignored,
                                  java.lang.Throwable throwable)
Same as setDefaultThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultThrow

public void expectAndDefaultThrow(long ignored,
                                  java.lang.Throwable throwable)
Same as setDefaultThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultThrow

public void expectAndDefaultThrow(float ignored,
                                  java.lang.Throwable throwable)
Same as setDefaultThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultThrow

public void expectAndDefaultThrow(double ignored,
                                  java.lang.Throwable throwable)
Same as setDefaultThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.

expectAndDefaultThrow

public void expectAndDefaultThrow(java.lang.Object ignored,
                                  java.lang.Throwable throwable)
Same as setDefaultThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.


Copyright © 2001-2005 OFFIS. This documentation is provided under the terms of the MIT licence.