Class 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 interfaces

    Limitation:

    First implementation supports just a method name checking

    Since:
    1.0
    Version:
    $Revision 1.0$
    • Constructor Detail

      • ExpectProxy

        public ExpectProxy()
    • Method Detail

      • expectAndReturn

        public ExpectProxy<T> expectAndReturn​(String methodName,
                                              Object retVal)
        Program the expected function call
        Parameters:
        methodName - the expected method name
        retVal - 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 name
        throwEx - 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
      • getProxy

        public T getProxy​(Class<T> clazz)
        Return the Proxy implementation of the Interface
        Parameters:
        clazz - of the interface
        Returns:
        the proxy