Top Description Methods
org.easymock

public Interface IMocksControl

Known Direct Implementers
org.easymock.internal.MocksControl
Imports
java.lang.reflect.Method

Controls all the mock objects created by it. For details, see the EasyMock documentation.
Author
OFFIS, Tammo Freese

Method Summary

Modifier and TypeMethod and Description
public void
checkIsUsedInOneThread(boolean
If it should be used in one thread only or not
shouldBeUsedInOneThread
)

Check that the mock is called from only one thread

public void
checkOrder(boolean
true switches order checking on, false switches it off.
state
)

Switches order checking on and off.

public <
the interface or class that the mock object should implement/extend.
T
,
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
R
>
R

Returns:

the mock object.
createMock
(Class<T>
the interface or class that the mock object should implement/extend.
toMock
)

Same as mock(Class) but using the old naming.

public <
the interface or class that the mock object should implement/extend.
T
,
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
R
>
R

Returns:

the mock object.
createMock
(String
the name of the mock object.
name
,
Class<T>
the interface or class that the mock object should implement/extend.
toMock
)

Same as mock(String, Class) but using the old naming.

public <
the class that the mock object should extend.
T
,
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
R
>
R

Returns:

the mock object.
createMock
(String
the name of the mock object.
name
,
Class<T>
the class that the mock object should extend.
toMock
,
ConstructorArgs
constructor and parameters used to instantiate the mock. If null, no constructor will be called
constructorArgs
,
Method...
methods that will be mocked, other methods will behave normally. If empty, all methods will be mocked
mockedMethods
)

Same as mock(String, Class, ConstructorArgs, Method...) but using the old naming

public void
makeThreadSafe(boolean
If the mock should be thread safe or not
threadSafe
)

Makes the mock thread safe.

public default <
the interface or class that the mock object should implement/extend.
T
,
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
R
>
R

Returns:

the mock object.
mock
(Class<T>
the interface or class that the mock object should implement/extend.
toMock
)

Creates a mock object that implements the given interface.

public default <
the interface or class that the mock object should implement/extend.
T
,
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
R
>
R

Returns:

the mock object.
mock
(String
the name of the mock object.
name
,
Class<T>
the interface or class that the mock object should implement/extend.
toMock
)

Creates a mock object that implements the given interface.

public default <
the class that the mock object should extend.
T
,
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
R
>
R

Returns:

the mock object.
mock
(String
the name of the mock object.
name
,
Class<T>
the class that the mock object should extend.
toMock
,
ConstructorArgs
constructor and parameters used to instantiate the mock. If null, no constructor will be called
constructorArgs
,
Method...
methods that will be mocked, other methods will behave normally. If empty, all methods will be mocked
mockedMethods
)

Creates a mock object that implements the given class.

public void
replay()

Switches the control from record mode to replay mode.

public void
reset()

Removes all expectations for the mock objects of this control.

public void
resetToDefault()

Removes all expectations for the mock objects of this control and turn them to default mocks.

public void
resetToNice()

Removes all expectations for the mock objects of this control and turn them to nice mocks.

public void
resetToStrict()

Removes all expectations for the mock objects of this control and turn them to strict mocks.

public void
verify()

Verifies that all expectations were met and that no unexpected call was performed.

public void
verifyRecording()

Verifies that all expectations were met.

public void
verifyUnexpectedCalls()

Verifies that no unexpected call was performed.

Method Detail

checkIsUsedInOneThreadback to summary
public void checkIsUsedInOneThread(boolean shouldBeUsedInOneThread)

Check that the mock is called from only one thread

Parameters
shouldBeUsedInOneThread:boolean

If it should be used in one thread only or not

checkOrderback to summary
public void checkOrder(boolean state)

Switches order checking on and off.

Parameters
state:boolean

true switches order checking on, false switches it off.

createMockback to summary
public <T, R> R createMock(Class<T> toMock)

Same as mock(Class) but using the old naming.

Parameters
<T>
the interface or class that the mock object should implement/extend.
<R>
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
toMock:Class<T>

the interface or class that the mock object should implement/extend.

Returns:R

the mock object.

createMockback to summary
public <T, R> R createMock(String name, Class<T> toMock)

Same as mock(String, Class) but using the old naming.

Parameters
<T>
the interface or class that the mock object should implement/extend.
<R>
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
name:String

the name of the mock object.

toMock:Class<T>

the interface or class that the mock object should implement/extend.

Returns:R

the mock object.

Exceptions
IllegalArgumentException:
if the name is not a valid Java identifier.
createMockback to summary
public <T, R> R createMock(String name, Class<T> toMock, ConstructorArgs constructorArgs, Method... mockedMethods)

Same as mock(String, Class, ConstructorArgs, Method...) but using the old naming

Parameters
<T>
the class that the mock object should extend.
<R>
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
name:String

the name of the mock object.

toMock:Class<T>

the class that the mock object should extend.

constructorArgs:ConstructorArgs

constructor and parameters used to instantiate the mock. If null, no constructor will be called

mockedMethods:Method[]

methods that will be mocked, other methods will behave normally. If empty, all methods will be mocked

Returns:R

the mock object.

makeThreadSafeback to summary
public void makeThreadSafe(boolean threadSafe)

Makes the mock thread safe.

Parameters
threadSafe:boolean

If the mock should be thread safe or not

mockback to summary
public default <T, R> R mock(Class<T> toMock)

Creates a mock object that implements the given interface.

Parameters
<T>
the interface or class that the mock object should implement/extend.
<R>
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
toMock:Class<T>

the interface or class that the mock object should implement/extend.

Returns:R

the mock object.

Since
4.0
mockback to summary
public default <T, R> R mock(String name, Class<T> toMock)

Creates a mock object that implements the given interface.

Parameters
<T>
the interface or class that the mock object should implement/extend.
<R>
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
name:String

the name of the mock object.

toMock:Class<T>

the interface or class that the mock object should implement/extend.

Returns:R

the mock object.

Exceptions
IllegalArgumentException:
if the name is not a valid Java identifier.
Since
4.0
mockback to summary
public default <T, R> R mock(String name, Class<T> toMock, ConstructorArgs constructorArgs, Method... mockedMethods)

Creates a mock object that implements the given class. Using this method directly in a test class is not recommended. Only frameworks extending EasyMock should use it. Final users should use the more convenient EasyMock#partialMockBuilder(Class) method instead

Parameters
<T>
the class that the mock object should extend.
<R>
the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the caller, we return a different type
name:String

the name of the mock object.

toMock:Class<T>

the class that the mock object should extend.

constructorArgs:ConstructorArgs

constructor and parameters used to instantiate the mock. If null, no constructor will be called

mockedMethods:Method[]

methods that will be mocked, other methods will behave normally. If empty, all methods will be mocked

Returns:R

the mock object.

Since
4.0
replayback to summary
public void replay()

Switches the control from record mode to replay mode.

resetback to summary
public void reset()

Removes all expectations for the mock objects of this control.

resetToDefaultback to summary
public void resetToDefault()

Removes all expectations for the mock objects of this control and turn them to default mocks.

resetToNiceback to summary
public void resetToNice()

Removes all expectations for the mock objects of this control and turn them to nice mocks.

resetToStrictback to summary
public void resetToStrict()

Removes all expectations for the mock objects of this control and turn them to strict mocks.

verifyback to summary
public void verify()

Verifies that all expectations were met and that no unexpected call was performed. It has the same effect as calling verifyRecording() followed by verifyUnexpectedCalls().

verifyRecordingback to summary
public void verifyRecording()

Verifies that all expectations were met.

Since
3.5
verifyUnexpectedCallsback to summary
public void verifyUnexpectedCalls()

Verifies that no unexpected call was performed.

Since
3.5