|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.mock.controller.MockController
@Deprecated public class MockController
This class can be used to better "formalise" the use of EasyMock MockControl
objects to mock out
interfaces in unit tests.
This class should not be used / extended from anymore as the current approach to unit testing in JIRA is
to use Mockito
.
Nested Class Summary | |
---|---|
static class |
MockController.ControllerState
Deprecated. An enumeration to show the different states of the MockController |
Constructor Summary | |
---|---|
MockController()
Deprecated. Instantiates a MockController that produces strict MockControl objects by default |
Method Summary | ||
---|---|---|
|
addObjectInstance(T objectInstance)
Deprecated. This method allow you to add an actual object instance to be added into the mix. |
|
|
createMock(Class<T> aClass)
Deprecated. Synonym for getMock(Class) to be more EasyMock like |
|
static MockController |
createNiceContoller()
Deprecated. |
|
|
createNiceMock(Class<T> aClass)
Deprecated. Synonym for getNiceMock(Class) to be more EasyMock like |
|
static MockController |
createStrictContoller()
Deprecated. |
|
|
createStrictMock(Class<T> aClass)
Deprecated. Synonym for getStrictMock(Class) to be more EasyMock like |
|
org.easymock.MockControl |
getCurrentMockControl()
Deprecated. This method allows you access to the current MockControl. |
|
|
getMock(Class<T> aClass)
Deprecated. This returns a mocked out implementation of aClass AND creates a MockControl under to covers for this
interface. |
|
org.easymock.MockControl |
getMockControl(Class<?> interfaceClass)
Deprecated. This method allows you access to the underlying MockControl objects. |
|
List<org.easymock.MockControl> |
getMockControls()
Deprecated. This method allows you access to the MockControl instances that have been created by this MockController. |
|
List<Object> |
getMockedObjects()
Deprecated. This method allows you access to the mocked object instances that have been mocked out by this MockController. |
|
List<Class<?>> |
getMockedTypes()
Deprecated. This method allows you access to the interfaces and classes that have been mocked out by this MockController. |
|
|
getNiceMock(Class<T> aClass)
Deprecated. This returns a mocked out implementation of aClass AND creates a nice MockControl under to covers for
this interface. |
|
List<Object> |
getObjectInstances()
Deprecated. This method allows you access to the object instances that have been placed in the mix by called to addObjectInstance(Object) . |
|
MockController.ControllerState |
getState()
Deprecated. Returns the current state of the MockController |
|
|
getStrictMock(Class<T> aClass)
Deprecated. This returns a mocked out implementation of aClass AND creates a strict MockControl under to covers for
this interface. |
|
|
instantiate(Class<T> classUnderTest)
Deprecated. This will create an instance of the passed class for testing. |
|
|
instantiateAndReplay(Class<T> classUnderTest)
Deprecated. This will try to use the mock interfaces that have been previously been added to the MockController to instantiate a new instance of implementationClass. |
|
|
instantiateAndReplayNice(Class<T> classUnderTest,
Constructor<T> constructor)
Deprecated. Try an create an instance of the passed class for testing. |
|
void |
onTestEnd()
Deprecated. This method can be called at the end of a TestCase to check that the MockController is in a good state. |
|
void |
replay(Object... easyMockedCreatedObjects)
Deprecated. Called to replay ALL of the MockControl objects inside this MockController as well as replay any EasyMock created mocks that where created outside the mock controller. |
|
void |
reset(Object... easyMockedCreatedObjects)
Deprecated. Called to reset ALL of the MockControl objects inside this MockController as well as reset any EasyMock created mocks that where created outside the mock controller. |
|
void |
setDefaultReturnValue(boolean b)
Deprecated. since we moved to EasyMock . Use EasyMock expectations instead |
|
void |
setDefaultReturnValue(Object o)
Deprecated. since we moved to EasyMock . Use EasyMock expectations instead |
|
void |
setReturnValue(boolean b)
Deprecated. since we moved to EasyMock . Use EasyMock expectations instead |
|
void |
setReturnValue(long l)
Deprecated. since we moved to EasyMock . Use EasyMock expectations instead |
|
void |
setReturnValue(Object o)
Deprecated. since we moved to EasyMock . Use EasyMock expectations instead |
|
void |
setReturnValue(Object o,
int i)
Deprecated. since we moved to EasyMock . Use EasyMock expectations instead |
|
void |
setThrowable(Throwable throwable)
Deprecated. since we moved to EasyMock . Use EasyMock expectations instead |
|
String |
toString()
Deprecated. |
|
void |
verify(Object... easyMockedCreatedObjects)
Deprecated. Called to verify ALL of the MockControl objects inside this MockController as well as verify any EasyMock created mocks that where created outside the mock controller. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MockController()
Method Detail |
---|
public static MockController createStrictContoller()
MockControl
's by default when getMock(Class)
is calledpublic static MockController createNiceContoller()
MockControl
's by default when getMock(Class)
is calledpublic MockController.ControllerState getState()
public String toString()
toString
in class Object
public <T> T getMock(Class<T> aClass)
MockControl
under to covers for this
interface. The type of MockControl (strict or nice) depends on the default behaviour for this MockController.
The created MockControl then becomes the current MockControl in play
If you have already asked for an instance of interfaceClass, then the same mock object is returned to the caller
and now extra objects will be created.
aClass
- the class or interface class to mock out
public <T> T createMock(Class<T> aClass)
getMock(Class)
to be more EasyMock like
aClass
- the class or interface class to mock out
public <T> T getStrictMock(Class<T> aClass)
MockControl
under to covers for
this interface. This MockControl then becomes the current MockControl in play
If you have already asked for an instance of interfaceClass, then the same mock object is returned to the caller
and now extra objects will be created.
aClass
- the class or interface class to mock out
public <T> T createStrictMock(Class<T> aClass)
getStrictMock(Class)
to be more EasyMock like
aClass
- the class or interface class to mock out
public <T> T getNiceMock(Class<T> aClass)
MockControl
under to covers for
this interface. This MockControl then becomes the current MockControl in play
If you have already asked for an instance of interfaceClass, then the same mock object is returned to the caller
and now extra objects will be created.
aClass
- the class or interface class to mock out
public <T> T createNiceMock(Class<T> aClass)
getNiceMock(Class)
to be more EasyMock like
aClass
- the class or interface class to mock out
public <T> T addObjectInstance(T objectInstance)
objectInstance
- a non null object instance
public org.easymock.MockControl getMockControl(Class<?> interfaceClass)
interfaceClass
- the interface class that is being mocked out
public org.easymock.MockControl getCurrentMockControl()
public List<Class<?>> getMockedTypes()
Class
espublic List<Object> getMockedObjects()
Object
spublic List<org.easymock.MockControl> getMockControls()
MockControl
spublic List<Object> getObjectInstances()
addObjectInstance(Object)
. Ordinarily you should not have to call this method but its here for completeness.
Object
spublic <T> T instantiateAndReplay(Class<T> classUnderTest)
classUnderTest
- the class to instantiate. It must be non null and it must not be an Interface.
IllegalStateException
- if an instance cannot be instantiated because of a lack of mocked interfaces.public <T> T instantiateAndReplayNice(Class<T> classUnderTest, Constructor<T> constructor)
classUnderTest
- the class to attempt to create.constructor
- the constructor to call.
IllegalStateException
- if the controller is unable to create the object for any reason.public <T> T instantiate(Class<T> classUnderTest)
instantiate(Class)
with the added bonus of being less characters to
read and write ;)
This is the method you will most likely call on the MockController to instatiate the class under test
classUnderTest
- the class to attempt to create.
IllegalStateException
- if the controller is unable to create the object for any reason.public void onTestEnd()
IllegalStateException
- if you haven't called replay() (eg you are in RECORD state.public void replay(Object... easyMockedCreatedObjects)
easyMockedCreatedObjects
- any EasyMocks created via EasyMock.createMock(Class)
that
you also want to replaypublic final void verify(Object... easyMockedCreatedObjects)
easyMockedCreatedObjects
- any EasyMocks created via EasyMock.createMock(Class)
that you also want
to verifypublic final void reset(Object... easyMockedCreatedObjects)
easyMockedCreatedObjects
- any EasyMocks created via EasyMock.createMock(Class)
that you also want
to verify@Deprecated public void setThrowable(Throwable throwable)
EasyMock
. Use EasyMock expectations instead
@Deprecated public void setReturnValue(boolean b)
EasyMock
. Use EasyMock expectations instead
@Deprecated public void setReturnValue(long l)
EasyMock
. Use EasyMock expectations instead
@Deprecated public void setReturnValue(Object o)
EasyMock
. Use EasyMock expectations instead
@Deprecated public void setReturnValue(Object o, int i)
EasyMock
. Use EasyMock expectations instead
@Deprecated public void setDefaultReturnValue(boolean b)
EasyMock
. Use EasyMock expectations instead
@Deprecated public void setDefaultReturnValue(Object o)
EasyMock
. Use EasyMock expectations instead
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |