org.unitils.mock.core.proxy
Class ProxyInvocation

java.lang.Object
  extended by org.unitils.mock.core.proxy.ProxyInvocation
Direct Known Subclasses:
BehaviorDefiningInvocation, CglibProxyMethodInterceptor.CglibProxyInvocation, ObservedInvocation

public class ProxyInvocation
extends Object

An invocation of a proxy method.

Author:
Filip Neven, Tim Ducheyne, Kenny Claes

Constructor Summary
ProxyInvocation(ProxyInvocation proxyInvocation)
          Creates a copy of the given proxy invocation.
ProxyInvocation(String mockName, Object proxy, Method method, List<Object> arguments, StackTraceElement[] invokedAtTrace)
          Creates an invocation.
 
Method Summary
 List<Object> getArguments()
           
 List<Object> getArgumentsAtInvocationTime()
          The arguments at the time that they were used.
 StackTraceElement getInvokedAt()
           
 StackTraceElement[] getInvokedAtTrace()
           
 int getLineNumber()
           
 Method getMethod()
           
 String getMockName()
           
 int getNrOfNotNullArguments()
           
 Object getProxy()
           
 Object invokeOriginalBehavior()
          Calls the actual method that was proxied using the same arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxyInvocation

public ProxyInvocation(String mockName,
                       Object proxy,
                       Method method,
                       List<Object> arguments,
                       StackTraceElement[] invokedAtTrace)
Creates an invocation.

Parameters:
mockName - The name of the mock, e.g. the field name, not null
proxy - The proxy on which the method was called, not null
method - The method that was called, not null
arguments - The arguments that were used, not null
invokedAtTrace - The trace of the invocation, not null

ProxyInvocation

public ProxyInvocation(ProxyInvocation proxyInvocation)
Creates a copy of the given proxy invocation. The argumentsAtInvocationTime will be set as copies (deep clones) of the arguments at the time of the invocation. This way the original values can still be used later-on even when changes occur to the original values (pass-by-value vs pass-by-reference). If not explicitly set, this will return the same values as the arguments.

Parameters:
proxyInvocation - The proxy invocation to copy, not null
Method Detail

invokeOriginalBehavior

public Object invokeOriginalBehavior()
                              throws Throwable
Calls the actual method that was proxied using the same arguments.

Returns:
The result value
Throws:
Throwable

getNrOfNotNullArguments

public int getNrOfNotNullArguments()
Returns:
The nr of arguments at invocation time that were not null

getMockName

public String getMockName()
Returns:
The name of the mock, e.g. the field name, not null

getProxy

public Object getProxy()
Returns:
The proxy on which the method was called, not null

getMethod

public Method getMethod()
Returns:
The method that was called, not null

getArguments

public List<Object> getArguments()
Returns:
The arguments that were used, not null

getArgumentsAtInvocationTime

public List<Object> getArgumentsAtInvocationTime()
The arguments at the time that they were used. The argumentsAtInvocationTime can be set as copies (deep clones) of the arguments at the time of the invocation. This way the original values can still be used later-on even when changes occur to the original values (pass-by-value vs pass-by-reference). If not explicitly set, this will return the same values as the arguments.

Returns:
The arguments, not null

getInvokedAtTrace

public StackTraceElement[] getInvokedAtTrace()
Returns:
The trace of the invocation, not null

getInvokedAt

public StackTraceElement getInvokedAt()
Returns:
The location of the invocation, not null

getLineNumber

public int getLineNumber()
Returns:
The line nr of the invocation


Copyright © 2011. All Rights Reserved.