org.easymock

Class EasyMockSupport

public class EasyMockSupport extends Object

Helper class to be used to keep tracks of mocks easily. See EasyMock documentation and SupportTest sample
Field Summary
protected List<IMocksControl>controls
List of all controls created
Method Summary
IMocksControlcreateControl()
Creates a control, order checking is disabled by default.
<T> TcreateMock(Class<T> toMock)
Creates a mock object that implements the given interface, order checking is disabled by default.
<T> TcreateMock(String name, Class<T> toMock)
Creates a mock object that implements the given interface, order checking is disabled by default.
IMocksControlcreateNiceControl()
Creates a control, order checking is disabled by default, and the mock objects created by this control will return 0, null or false for unexpected invocations.
<T> TcreateNiceMock(Class<T> toMock)
Creates a mock object that implements the given interface, order checking is disabled by default, and the mock object will return 0, null or false for unexpected invocations.
<T> TcreateNiceMock(String name, Class<T> toMock)
Creates a mock object that implements the given interface, order checking is disabled by default, and the mock object will return 0, null or false for unexpected invocations.
IMocksControlcreateStrictControl()
Creates a control, order checking is enabled by default.
<T> TcreateStrictMock(Class<T> toMock)
Creates a mock object that implements the given interface, order checking is enabled by default.
<T> TcreateStrictMock(String name, Class<T> toMock)
Creates a mock object that implements the given interface, order checking is enabled by default.
voidreplayAll()
Switches all registered mock objects (more exactly: the controls of the mock objects) to replay mode.
voidresetAll()
Resets all registered mock objects (more exactly: the controls of the mock objects).
voidresetAllToDefault()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with default behavior.
voidresetAllToNice()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with nice behavior.
voidresetAllToStrict()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with strict behavior.
voidverifyAll()
Verifies all registered mock objects (more exactly: the controls of the mock objects).

Field Detail

controls

protected final List<IMocksControl> controls
List of all controls created

Method Detail

createControl

public IMocksControl createControl()
Creates a control, order checking is disabled by default.

Returns: the control.

createMock

public <T> T createMock(Class<T> toMock)
Creates a mock object that implements the given interface, order checking is disabled by default.

Parameters: the interface that the mock object should implement. toMock the class of the interface that the mock object should implement.

Returns: the mock object.

createMock

public <T> T createMock(String name, Class<T> toMock)
Creates a mock object that implements the given interface, order checking is disabled by default.

Parameters: name the name of the mock object. toMock the class of the interface that the mock object should implement. the interface that the mock object should implement.

Returns: the mock object.

Throws: IllegalArgumentException if the name is not a valid Java identifier.

createNiceControl

public IMocksControl createNiceControl()
Creates a control, order checking is disabled by default, and the mock objects created by this control will return 0, null or false for unexpected invocations.

Returns: the control.

createNiceMock

public <T> T createNiceMock(Class<T> toMock)
Creates a mock object that implements the given interface, order checking is disabled by default, and the mock object will return 0, null or false for unexpected invocations.

Parameters: the interface that the mock object should implement. toMock the class of the interface that the mock object should implement.

Returns: the mock object.

createNiceMock

public <T> T createNiceMock(String name, Class<T> toMock)
Creates a mock object that implements the given interface, order checking is disabled by default, and the mock object will return 0, null or false for unexpected invocations.

Parameters: name the name of the mock object. toMock the class of the interface that the mock object should implement. the interface that the mock object should implement.

Returns: the mock object.

Throws: IllegalArgumentException if the name is not a valid Java identifier.

createStrictControl

public IMocksControl createStrictControl()
Creates a control, order checking is enabled by default.

Returns: the control.

createStrictMock

public <T> T createStrictMock(Class<T> toMock)
Creates a mock object that implements the given interface, order checking is enabled by default.

Parameters: the interface that the mock object should implement. toMock the class of the interface that the mock object should implement.

Returns: the mock object.

createStrictMock

public <T> T createStrictMock(String name, Class<T> toMock)
Creates a mock object that implements the given interface, order checking is enabled by default.

Parameters: name the name of the mock object. toMock the class of the interface that the mock object should implement. the interface that the mock object should implement.

Returns: the mock object.

Throws: IllegalArgumentException if the name is not a valid Java identifier.

replayAll

public void replayAll()
Switches all registered mock objects (more exactly: the controls of the mock objects) to replay mode. For details, see the EasyMock documentation.

resetAll

public void resetAll()
Resets all registered mock objects (more exactly: the controls of the mock objects). For details, see the EasyMock documentation.

resetAllToDefault

public void resetAllToDefault()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with default behavior. For details, see the EasyMock documentation.

resetAllToNice

public void resetAllToNice()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with nice behavior. For details, see the EasyMock documentation.

resetAllToStrict

public void resetAllToStrict()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with strict behavior. For details, see the EasyMock documentation.

verifyAll

public void verifyAll()
Verifies all registered mock objects (more exactly: the controls of the mock objects).
Copyright © 2001-2009 OFFIS, Tammo Freese, Henri Tremblay. This documentation is provided under the terms of the MIT licence.]]>