org.easymock

Class MockControl

public class MockControl extends Object

A MockControl object controls the behavior of its associated mock object. For more information, see the EasyMock documentation.
Field Summary
static ArgumentsMatcherALWAYS_MATCHER
Matches always.
static ArgumentsMatcherARRAY_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 ArgumentsMatcherEQUALS_MATCHER
Matches if each expected argument is equal to the corresponding actual argument.
protected static IBehaviorFactoryNICE_BEHAVIOR_FACTORY
internal constant with protected visibility to allow access for extensions.
static RangeONE
Exactly one call.
static RangeONE_OR_MORE
One or more calls.
protected static IBehaviorFactoryORDERED_BEHAVIOR_FACTORY
internal constant with protected visibility to allow access for extensions.
protected static IBehaviorFactoryUNORDERED_BEHAVIOR_FACTORY
internal constant with protected visibility to allow access for extensions.
static RangeZERO_OR_MORE
Zero or more calls.
Constructor Summary
protected MockControl(Class toMock, IProxyFactory proxyFactory, 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 MockControlcreateControl(Class toMock)
Creates a mock control object for the specified interface.
static MockControlcreateNiceControl(Class toMock)
Creates a mock control object for the specified interface.
static MockControlcreateStrictControl(Class toMock)
Creates a mock control object for the specified interface.
voidexpectAndDefaultReturn(boolean ignored, boolean value)
Same as MockControl.
voidexpectAndDefaultReturn(long ignored, long value)
Same as MockControl.
voidexpectAndDefaultReturn(float ignored, float value)
Same as MockControl.
voidexpectAndDefaultReturn(double ignored, double value)
Same as MockControl.
voidexpectAndDefaultReturn(Object ignored, Object value)
voidexpectAndDefaultThrow(boolean ignored, Throwable throwable)
voidexpectAndDefaultThrow(long ignored, Throwable throwable)
voidexpectAndDefaultThrow(float ignored, Throwable throwable)
voidexpectAndDefaultThrow(double ignored, Throwable throwable)
voidexpectAndDefaultThrow(Object ignored, Throwable throwable)
voidexpectAndReturn(boolean ignored, boolean value)
Same as MockControl.
voidexpectAndReturn(long ignored, long value)
Same as MockControl.
voidexpectAndReturn(float ignored, float value)
Same as MockControl.
voidexpectAndReturn(double ignored, double value)
Same as MockControl.
voidexpectAndReturn(Object ignored, Object value)
Same as setReturnValue.
voidexpectAndReturn(boolean ignored, boolean value, Range range)
Same as MockControl.
voidexpectAndReturn(long ignored, long value, Range range)
Same as MockControl.
voidexpectAndReturn(float ignored, float value, Range range)
Same as MockControl.
voidexpectAndReturn(double ignored, double value, Range range)
Same as MockControl.
voidexpectAndReturn(Object ignored, Object value, Range range)
Same as MockControl.
voidexpectAndReturn(boolean ignored, boolean value, int count)
Same as MockControl.
voidexpectAndReturn(long ignored, long value, int count)
Same as MockControl.
voidexpectAndReturn(float ignored, float value, int count)
Same as MockControl.
voidexpectAndReturn(double ignored, double value, int count)
Same as MockControl.
voidexpectAndReturn(Object ignored, Object value, int count)
Same as MockControl.
voidexpectAndReturn(boolean ignored, boolean value, int min, int max)
Same as MockControl.
voidexpectAndReturn(long ignored, long value, int min, int max)
Same as MockControl.
voidexpectAndReturn(float ignored, float value, int min, int max)
Same as MockControl.
voidexpectAndReturn(double ignored, double value, int min, int max)
Same as MockControl.
voidexpectAndReturn(Object ignored, Object value, int min, int max)
Same as MockControl.
voidexpectAndThrow(boolean ignored, Throwable throwable)
Same as setThrowable.
voidexpectAndThrow(long ignored, Throwable throwable)
Same as setThrowable.
voidexpectAndThrow(float ignored, Throwable throwable)
Same as setThrowable.
voidexpectAndThrow(double ignored, Throwable throwable)
Same as setThrowable.
voidexpectAndThrow(Object ignored, Throwable throwable)
Same as setThrowable.
voidexpectAndThrow(boolean ignored, Throwable throwable, Range range)
Same as MockControl.
voidexpectAndThrow(long ignored, Throwable throwable, Range range)
Same as MockControl.
voidexpectAndThrow(float ignored, Throwable throwable, Range range)
Same as MockControl.
voidexpectAndThrow(double ignored, Throwable throwable, Range range)
Same as MockControl.
voidexpectAndThrow(Object ignored, Throwable throwable, Range range)
Same as MockControl.
voidexpectAndThrow(boolean ignored, Throwable throwable, int count)
Same as MockControl.
voidexpectAndThrow(long ignored, Throwable throwable, int count)
Same as MockControl.
voidexpectAndThrow(float ignored, Throwable throwable, int count)
Same as MockControl.
voidexpectAndThrow(double ignored, Throwable throwable, int count)
Same as MockControl.
voidexpectAndThrow(Object ignored, Throwable throwable, int count)
Same as MockControl.
voidexpectAndThrow(boolean ignored, Throwable throwable, int min, int max)
Same as MockControl.
voidexpectAndThrow(long ignored, Throwable throwable, int min, int max)
Same as MockControl.
voidexpectAndThrow(float ignored, Throwable throwable, int min, int max)
Same as MockControl.
voidexpectAndThrow(double ignored, Throwable throwable, int min, int max)
Same as MockControl.
voidexpectAndThrow(Object ignored, Throwable throwable, int min, int max)
Same as MockControl.
ObjectgetMock()
Returns the mock object.
voidreplay()
Switches the mock object from record state to replay state.
voidreset()
Resets the mock control and the mock object to the state directly after creation.
voidsetDefaultMatcher(ArgumentsMatcher matcher)
Sets the default ArgumentsMatcher for all methods of the mock object.
voidsetDefaultReturnValue(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.
voidsetDefaultReturnValue(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.
voidsetDefaultReturnValue(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.
voidsetDefaultReturnValue(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.
voidsetDefaultReturnValue(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.
voidsetDefaultThrowable(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.
voidsetDefaultVoidCallable()
Records that the mock object will by default allow the last method specified by a method call.
voidsetMatcher(ArgumentsMatcher matcher)
Sets the ArgumentsMatcher for the last method called on the mock object.
voidsetReturnValue(boolean value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.
voidsetReturnValue(long value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.
voidsetReturnValue(float value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.
voidsetReturnValue(double value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.
voidsetReturnValue(Object value)
Records that the mock object will expect the last method call once, and will react by returning the provided return value.
voidsetReturnValue(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.
voidsetReturnValue(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.
voidsetReturnValue(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.
voidsetReturnValue(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.
voidsetReturnValue(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.
voidsetReturnValue(boolean value, 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.
voidsetReturnValue(double value, 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.
voidsetReturnValue(float value, 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.
voidsetReturnValue(long value, 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.
voidsetReturnValue(Object value, 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.
voidsetReturnValue(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.
voidsetReturnValue(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.
voidsetReturnValue(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.
voidsetReturnValue(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.
voidsetReturnValue(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.
voidsetThrowable(Throwable throwable)
Records that the mock object will expect the last method call once, and will react by throwing the provided Throwable.
voidsetThrowable(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.
voidsetThrowable(Throwable throwable, 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.
voidsetThrowable(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.
voidsetVoidCallable()
Records that the mock object will expect the last method call once, and will react by returning silently.
voidsetVoidCallable(int times)
Records that the mock object will expect the last method call a fixed number of times, and will react by returning silently.
voidsetVoidCallable(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.
voidsetVoidCallable(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.
voidverify()
Verifies that all expectations have been met.

Field Detail

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.

EQUALS_MATCHER

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

NICE_BEHAVIOR_FACTORY

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

ONE

public static final Range ONE
Exactly one call.

ONE_OR_MORE

public static final Range ONE_OR_MORE
One or more calls.

ORDERED_BEHAVIOR_FACTORY

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

UNORDERED_BEHAVIOR_FACTORY

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

ZERO_OR_MORE

public static final Range ZERO_OR_MORE
Zero or more calls.

Constructor Detail

MockControl

protected MockControl(Class toMock, IProxyFactory proxyFactory, 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(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.

createNiceControl

public static MockControl createNiceControl(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.

createStrictControl

public static MockControl createStrictControl(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.

expectAndDefaultReturn

public void expectAndDefaultReturn(boolean ignored, boolean value)
Same as MockControl. 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 MockControl. 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 MockControl. 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 MockControl. For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters: ignored an ignored value.

expectAndDefaultReturn

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

Parameters: ignored an ignored value.

expectAndDefaultThrow

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

Parameters: ignored an ignored value.

expectAndDefaultThrow

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

Parameters: ignored an ignored value.

expectAndDefaultThrow

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

Parameters: ignored an ignored value.

expectAndDefaultThrow

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

Parameters: ignored an ignored value.

expectAndDefaultThrow

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

Parameters: ignored an ignored value.

expectAndReturn

public void expectAndReturn(boolean ignored, boolean value)
Same as MockControl. 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 MockControl. 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 MockControl. 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 MockControl. For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters: ignored an ignored value.

expectAndReturn

public void expectAndReturn(Object ignored, Object value)
Same as setReturnValue. 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, Range range)
Same as MockControl. 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, Range range)
Same as MockControl. 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, Range range)
Same as MockControl. 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, Range range)
Same as MockControl. For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters: ignored an ignored value.

expectAndReturn

public void expectAndReturn(Object ignored, Object value, Range range)
Same as MockControl. 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 MockControl. 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 MockControl. 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 MockControl. 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 MockControl. For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters: ignored an ignored value.

expectAndReturn

public void expectAndReturn(Object ignored, Object value, int count)
Same as MockControl. 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 MockControl. 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 MockControl. 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 MockControl. 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 MockControl. For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Parameters: ignored an ignored value.

expectAndReturn

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

expectAndThrow

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

Parameters: ignored an ignored value.

getMock

public Object getMock()
Returns the mock object.

Returns: the mock object of this control

replay

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

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

reset

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

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: IllegalStateException if called in replay state, or if any behavior is already defined on the mock object.

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: 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: 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: 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: 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(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: 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. IllegalArgumentException if the provided return value is not compatible to the return value of the last method called on the mock object.

setDefaultThrowable

public void setDefaultThrowable(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: IllegalArgumentException if the last method called on the mock cannot throw the provided Throwable. NullPointerException if throwable is null. IllegalStateException if the mock object is in replay state, or if no method was called on the mock object before.

setDefaultVoidCallable

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

Throws: 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.

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: IllegalStateException if called in replay state, or if no method was called on the mock object before.

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: 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: 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: 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: 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(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: 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. IllegalArgumentException if the provided return value is not compatible to the return value of the last method called on the mock object.

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: 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: 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: 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: 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(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: 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. IllegalArgumentException if the provided return value is not compatible to the return value of the last method called on the mock object.

setReturnValue

public void setReturnValue(boolean value, 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: 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, 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: 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, 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: 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, 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: 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(Object value, 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: 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. IllegalArgumentException if the provided return value is not compatible to the return value of the last method called on the mock object.

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: 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: 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: 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: 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(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: 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. IllegalArgumentException if the provided return value is not compatible to the return value of the last method called on the mock object.

setThrowable

public void setThrowable(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: IllegalStateException if the mock object is in replay state or if no method was called on the mock object before. IllegalArgumentException if the last method called on the mock cannot throw the provided Throwable. NullPointerException if throwable is null.

setThrowable

public void setThrowable(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: IllegalStateException if the mock object is in replay state or if no method was called on the mock object before. IllegalArgumentException if the last method called on the mock cannot throw the provided Throwable. NullPointerException if throwable is null.

setThrowable

public void setThrowable(Throwable throwable, 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: IllegalStateException if the mock object is in replay state or if no method was called on the mock object before. IllegalArgumentException if the last method called on the mock cannot throw the provided Throwable. NullPointerException if throwable is null.

setThrowable

public void setThrowable(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: IllegalStateException if the mock object is in replay state or if no method was called on the mock object before. IllegalArgumentException if the last method called on the mock cannot throw the provided Throwable. NullPointerException if throwable is null.

setVoidCallable

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

Throws: 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.

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: 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.

setVoidCallable

public void setVoidCallable(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: 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.

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: 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.

verify

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

Throws: IllegalStateException if the mock object is in record state. AssertionFailedError if any expectation has not been met.

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