|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.exolab.jmscts.core.MethodInvoker
A helper class for invoking methods, and verifying that any exception thrown matches that expected.
Constructor Summary | |
MethodInvoker()
Construct an instance with that expects no exceptions when a method is invoked |
|
MethodInvoker(java.lang.Class clazz,
java.lang.Class exception)
Construct an instance that expects a single expected exception when a method is invoked. |
Method Summary | |
protected void |
fail(java.lang.reflect.Method method)
Helper to raise an exception when a method doesn't throw the expected exception |
java.lang.Object |
invoke(java.lang.Object object,
java.lang.reflect.Method method)
Invoke a method taking no arguments |
java.lang.Object |
invoke(java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object argument)
Invoke a method taking a single argument |
java.lang.Object |
invoke(java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object[] arguments)
Invoke a method taking a list of arguments |
java.lang.Object |
invoke(java.lang.Object object,
java.lang.String method)
Invoke a method taking no arguments |
java.lang.Object |
invoke(java.lang.Object object,
java.lang.String method,
java.lang.Object argument)
Invoke a method taking a single argument |
java.lang.Object |
invoke(java.lang.Object object,
java.lang.String method,
java.lang.Object[] arguments)
Invoke a method taking a list of arguments |
protected void |
verify(java.lang.reflect.Method method,
java.lang.Exception exception)
Helper to verify that an exception matches that expected |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MethodInvoker()
public MethodInvoker(java.lang.Class clazz, java.lang.Class exception)
clazz
- the class to introspect. May be null
exception
- the expected exception when methods are invoked,
or null
if no exceptions are expected.Method Detail |
public java.lang.Object invoke(java.lang.Object object, java.lang.String method) throws java.lang.Exception, java.lang.NoSuchMethodException
If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is wrapped in an object. If the underlying method return type is void, the invocation returns null.
object
- the object to invoke the method onmethod
- the method namejava.lang.Exception
- if an exception is thrown and it doesn't match
the expected exception. If no exception is expected, then the exception
will be propagatedjava.lang.NoSuchMethodException
- if the method doesn't existpublic java.lang.Object invoke(java.lang.Object object, java.lang.reflect.Method method) throws java.lang.Exception
If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is wrapped in an object. If the underlying method return type is void, the invocation returns null.
object
- the object to invoke the method onmethod
- the method to invokejava.lang.Exception
- if an exception is thrown and it doesn't match
the expected exception. If no exception is expected, then the exception
will be propagatedpublic java.lang.Object invoke(java.lang.Object object, java.lang.String method, java.lang.Object argument) throws java.lang.Exception, java.lang.NoSuchMethodException
If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is wrapped in an object. If the underlying method return type is void, the invocation returns null.
object
- the object to invoke the method onmethod
- the method nameargument
- the argument to pass to the methodjava.lang.Exception
- if an exception is thrown and it doesn't match
the expected exception. If no exception is expected, then the exception
will be propagatedjava.lang.NoSuchMethodException
- if the method doesn't existpublic java.lang.Object invoke(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object argument) throws java.lang.Exception
If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is wrapped in an object. If the underlying method return type is void, the invocation returns null.
object
- the object to invoke the method onmethod
- the method to invokeargument
- the argument to pass to the methodjava.lang.Exception
- if an exception is thrown and it doesn't match
the expected exception. If no exception is expected, then the exception
will be propagatedpublic java.lang.Object invoke(java.lang.Object object, java.lang.String method, java.lang.Object[] arguments) throws java.lang.Exception, java.lang.NoSuchMethodException
If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is wrapped in an object. If the underlying method return type is void, the invocation returns null.
object
- the object to invoke the method onmethod
- the method namearguments
- the arguments to pass to the methodjava.lang.Exception
- if an exception is thrown and it doesn't match
the expected exception. If no exception is expected, then the exception
will be propagatedjava.lang.NoSuchMethodException
- if the method doesn't existpublic java.lang.Object invoke(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object[] arguments) throws java.lang.Exception
If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is wrapped in an object. If the underlying method return type is void, the invocation returns null.
object
- the object to invoke the method onmethod
- the method to invokearguments
- the arguments to pass to the methodjava.lang.Exception
- if an exception is thrown and it doesn't match
the expected exception. If no exception is expected, then the exception
will be propagatedprotected void fail(java.lang.reflect.Method method) throws java.lang.Exception
method
- the methodjava.lang.Exception
- details the expected exceptionprotected void verify(java.lang.reflect.Method method, java.lang.Exception exception) throws java.lang.Exception
method
- the methodexception
- the exception thrown by the methodjava.lang.Exception
- if exception
isn't of the expected type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |