Package net.tirasa.connid.commons.db
Class ExpectProxy<T>
- java.lang.Object
-
- net.tirasa.connid.commons.db.ExpectProxy<T>
-
- Type Parameters:
T- Type of the interface for testing
- All Implemented Interfaces:
InvocationHandler
public class ExpectProxy<T> extends Object implements InvocationHandler
This is a Test helper class for testing expected method calls and return values of interfacesLimitation:
First implementation supports just a method name checking
- Since:
- 1.0
- Version:
- $Revision 1.0$
-
-
Constructor Summary
Constructors Constructor Description ExpectProxy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpectProxy<T>expect(String methodName)Program the expected method callExpectProxy<T>expectAndReturn(String methodName, Object retVal)Program the expected function callExpectProxy<T>expectAndThrow(String methodName, Throwable throwEx)Program the expected method callTgetProxy(Class<T> clazz)Return the Proxy implementation of the InterfaceObjectinvoke(Object proxy, Method method, Object[] args)booleanisDone()Test that all expected was called in the order
-
-
-
Method Detail
-
expectAndReturn
public ExpectProxy<T> expectAndReturn(String methodName, Object retVal)
Program the expected function call- Parameters:
methodName- the expected method nameretVal- the expected return value or proxy- Returns:
- the proxy
-
expect
public ExpectProxy<T> expect(String methodName)
Program the expected method call- Parameters:
methodName- the expected method name- Returns:
- the proxy
-
expectAndThrow
public ExpectProxy<T> expectAndThrow(String methodName, Throwable throwEx)
Program the expected method call- Parameters:
methodName- the expected method namethrowEx- the expected exception- Returns:
- the proxy
-
isDone
public boolean isDone()
Test that all expected was called in the order- Returns:
- true/false all was called
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable
-
-