public class SimpleMock extends Object implements InvocationHandler
All invoked methods return null
. Override invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
if you want to change this behavior, but be sure to call the superclass
implementation (otherwise it won't record the invocation).
A single instance can mock multiple objects, however method invocations will be interleaved. Doing so is primarily useful when you simply need a dummy object as a method parameter, and don't actually use it.
Constructor and Description |
---|
SimpleMock() |
Modifier and Type | Method and Description |
---|---|
void |
assertCall(int callNum,
String methodName,
Object... args)
Asserts the method name and parameter of a specific invocation.
|
void |
assertCallCount(int expected)
Asserts that we received the expected number of invocations.
|
<T> T |
getInstance(Class<T> classToMock) |
Object |
invoke(Object proxy,
Method method,
Object[] args) |
public <T> T getInstance(Class<T> classToMock)
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
invoke
in interface InvocationHandler
Throwable
public void assertCallCount(int expected)