|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hammingweight.hammock.ATestDoubleHandler
com.hammingweight.hammock.Hamspy
public class Hamspy
The Hamspy
class is an IInvocationHandler
that
causes a test double associated with the handler to behave like a spy object.
The Hamspy
class can also behave like a mock object that
responds to methods set via the setExpectation() method.
Field Summary |
---|
Fields inherited from interface com.hammingweight.hammock.IClassDefinitions |
---|
BOOLEAN_CLASS, BYTE_CLASS, CHARACTER_CLASS, DOUBLE_CLASS, FLOAT_CLASS, IMOCKOBJECT_CLASS, INTEGER_CLASS, LONG_CLASS, OBJECT_CLASS, SHORT_CLASS, THROWABLE_CLASS |
Constructor Summary | |
---|---|
Hamspy()
Constructor; equivalent to Hamspy(false) . |
|
Hamspy(boolean stubConcreteMethods)
A constructor that determines whether this spy handler should respond to invocations of non-abstract methods. |
Method Summary | |
---|---|
InvocationVerifier |
getExpectation(MockMethod method)
A method to get a verifier for checking that a method was invoked as expected. |
InvocationVerifier |
getExpectation(MockMethod method,
IMockObject mockObject)
A method to get a verifier for checking that a method was invoked as expected. |
InvocationVerifier |
getExpectation(MockMethod method,
IMockObject mockObject,
java.lang.Object[] methodArgs)
A method to get a verifier for checking that a method was invoked as expected. |
InvocationVerifier |
getExpectation(MockMethod method,
java.lang.Object[] methodArgs)
A method to get a verifier for checking that a method was invoked as expected. |
MethodInvocation[] |
getInvocations()
A method to get all the invocations that were spied on. |
MethodInvocation[] |
getInvocations(MockMethod method)
A method to get all invocations of a particular method. |
MethodInvocation[] |
getInvocations(MockMethod method,
IMockObject mockObject)
A method to get the invocations of a particular method on a specific (mock) object. |
void |
invoke(MethodInvocation mi)
Processes a method invocation on a spy object. |
Methods inherited from class com.hammingweight.hammock.ATestDoubleHandler |
---|
getExpectation, getNumberOfExpectations, setExpectation, setExpectation, setExpectation, setExpectation, setStubExpectation, setStubExpectation, setStubExpectation, setStubExpectation |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Hamspy()
Hamspy(false)
.
public Hamspy(boolean stubConcreteMethods)
false
, the handler will allow the mocked class's
superclass to respond to a method invocation.
If true
, the handler will respond with a default value (e.g.
false
if the return type is boolean
or 0 if the
return type is int
).
stubConcreteMethods
- Should this handler handle invocations of concrete methods or
delegate them to the superclass?Method Detail |
---|
public MethodInvocation[] getInvocations()
public MethodInvocation[] getInvocations(MockMethod method)
method
- The method that was spied on.
public InvocationVerifier getExpectation(MockMethod method)
method
- The method of interest.
public MethodInvocation[] getInvocations(MockMethod method, IMockObject mockObject)
method
- The method of interest.mockObject
- The object of interest.
public InvocationVerifier getExpectation(MockMethod method, IMockObject mockObject)
method
- The method of interest.mockObject
- The mock object on which we were spying.
public InvocationVerifier getExpectation(MockMethod method, IMockObject mockObject, java.lang.Object[] methodArgs)
method
- The method of interest.mockObject
- The mock object on which we were spying.methodArgs
- The expected arguments.
public InvocationVerifier getExpectation(MockMethod method, java.lang.Object[] methodArgs)
method
- The method of interest.methodArgs
- The expected arguments.
public void invoke(MethodInvocation mi)
false
if the return type is a boolean
) if the
method in the superclass is abstract. If the super class has a concrete
implementation of the method, the call is delegated to the super class.
mi
- The method invocation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |