org.easymock.classextension
Class MockClassControl

java.lang.Object
  extended byorg.easymock.MockControl
      extended byorg.easymock.classextension.MockClassControl

public class MockClassControl
extends org.easymock.MockControl

Instances of MockControl control the behavior of their associated mock objects. For more information, see the EasyMock documentation.


Field Summary
 
Fields inherited from class org.easymock.MockControl
ALWAYS_MATCHER, ARRAY_MATCHER, EQUALS_MATCHER, NICE_BEHAVIOR_FACTORY, ONE, ONE_OR_MORE, ORDERED_BEHAVIOR_FACTORY, UNORDERED_BEHAVIOR_FACTORY, ZERO_OR_MORE
 
Method Summary
static org.easymock.MockControl createControl(java.lang.Class classToMock)
          Does the same thing as above, but tries to use the best constructor.
static MockClassControl createControl(java.lang.Class classToMock, java.lang.Class[] constructorTypes, java.lang.Object[] constructorArgs)
          Creates a mock control object for the specified class and construct an instance using the constructor that matches constructorTypes with parameters constructorArgs.
static MockClassControl createControl(java.lang.Class classToMock, java.lang.Class[] constructorTypes, java.lang.Object[] constructorArgs, java.lang.reflect.Method[] mockedMethods)
          Do the same as above but allows to pass a list of methods to mock.
static org.easymock.MockControl createNiceControl(java.lang.Class classToMock)
          Does the same thing as above, but tries to use the first constructor found.
static MockClassControl createNiceControl(java.lang.Class classToMock, java.lang.Class[] constructorTypes, java.lang.Object[] constructorArgs)
          Creates a mock control object for the specified class and construct an instance using the constructor that matches constructorTypes with parameters constructorArgs.
static MockClassControl createNiceControl(java.lang.Class classToMock, java.lang.Class[] constructorTypes, java.lang.Object[] constructorArgs, java.lang.reflect.Method[] mockedMethods)
          Do the same as above but allows to pass a list of methods to mock.
static org.easymock.MockControl createStrictControl(java.lang.Class classToMock)
          Does the same thing as above, but tries to use the first constructor found.
static MockClassControl createStrictControl(java.lang.Class classToMock, java.lang.Class[] constructorTypes, java.lang.Object[] constructorArgs)
          Creates a mock control object for the specified class and construct an instance using the constructor that matches constructorTypes with parameters constructorArgs.
static MockClassControl createStrictControl(java.lang.Class classToMock, java.lang.Class[] constructorTypes, java.lang.Object[] constructorArgs, java.lang.reflect.Method[] mockedMethods)
          Do the same as above but allows to pass a list of methods to mock.
 
Methods inherited from class org.easymock.MockControl
expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndReturn, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, expectAndThrow, getMock, replay, reset, setDefaultMatcher, setDefaultReturnValue, setDefaultReturnValue, setDefaultReturnValue, setDefaultReturnValue, setDefaultReturnValue, setDefaultThrowable, setDefaultVoidCallable, setMatcher, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setReturnValue, setThrowable, setThrowable, setThrowable, setThrowable, setVoidCallable, setVoidCallable, setVoidCallable, setVoidCallable, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createControl

public static MockClassControl createControl(java.lang.Class classToMock,
                                             java.lang.Class[] constructorTypes,
                                             java.lang.Object[] constructorArgs)
Creates a mock control object for the specified class and construct an instance using the constructor that matches constructorTypes with parameters constructorArgs. 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:
classToMock - the class to mock.
constructorTypes - Class types of arguments in constructor to use to instantiate object
constructorArgs - objects to pass to constructor.
Returns:
the mock control.

createControl

public static MockClassControl createControl(java.lang.Class classToMock,
                                             java.lang.Class[] constructorTypes,
                                             java.lang.Object[] constructorArgs,
                                             java.lang.reflect.Method[] mockedMethods)
Do the same as above but allows to pass a list of methods to mock. All the others won't be. If you pass null, no methods will be mocked.


createControl

public static org.easymock.MockControl createControl(java.lang.Class classToMock)
Does the same thing as above, but tries to use the best constructor. The algorithm is pretty basic. It first search for an empty constructor. If none exists, it will just use the first constructor it finds. The constructor params will be mocked (in case of interfaces and not final classes) or filled with default values (for final classes or primitive types). If the picked constructor is using it's parameters to do some business treatment, it is highly possible that the generated params won't be enough and it will crash. In this case you should use createControl(Class, Class[], Object[]) to be able to use your own params and constructor.

See Also:
org.easymock.MockClassControl#createControl(java.lang.Class, java.lang.Class[], java.lang.Object[])

createStrictControl

public static MockClassControl createStrictControl(java.lang.Class classToMock,
                                                   java.lang.Class[] constructorTypes,
                                                   java.lang.Object[] constructorArgs)
Creates a mock control object for the specified class and construct an instance using the constructor that matches constructorTypes with parameters constructorArgs. 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:
classToMock - the class to mock.
constructorTypes - Class types of arguments in constructor to use to instantiate object
constructorArgs - objects to pass to constructor.
Returns:
the mock control.

createStrictControl

public static MockClassControl createStrictControl(java.lang.Class classToMock,
                                                   java.lang.Class[] constructorTypes,
                                                   java.lang.Object[] constructorArgs,
                                                   java.lang.reflect.Method[] mockedMethods)
Do the same as above but allows to pass a list of methods to mock. All the others won't be. If you pass null, no methods will be mocked.


createStrictControl

public static org.easymock.MockControl createStrictControl(java.lang.Class classToMock)
Does the same thing as above, but tries to use the first constructor found.

See Also:
org.easymock.MockClassControl#createStrictControl(java.lang.Class, java.lang.Class[], java.lang.Object[])

createNiceControl

public static MockClassControl createNiceControl(java.lang.Class classToMock,
                                                 java.lang.Class[] constructorTypes,
                                                 java.lang.Object[] constructorArgs)
Creates a mock control object for the specified class and construct an instance using the constructor that matches constructorTypes with parameters constructorArgs. The MockControl and its associated mock object will not the order of expected method calls. An unexpected method call on the mock object will return an empty value (0, null, false).

Parameters:
classToMock - the class to mock.
constructorTypes - Class types of arguments in constructor to use to instantiate object
constructorArgs - objects to pass to constructor.
Returns:
the mock control.

createNiceControl

public static MockClassControl createNiceControl(java.lang.Class classToMock,
                                                 java.lang.Class[] constructorTypes,
                                                 java.lang.Object[] constructorArgs,
                                                 java.lang.reflect.Method[] mockedMethods)
Do the same as above but allows to pass a list of methods to mock. All the others won't be. If you pass null, no methods will be mocked.


createNiceControl

public static org.easymock.MockControl createNiceControl(java.lang.Class classToMock)
Does the same thing as above, but tries to use the first constructor found.

See Also:
org.easymock.MockClassControl#createNiceControl(java.lang.Class, java.lang.Class[], java.lang.Object[])