org.unitils.mock.mockbehavior.impl
Class OriginalBehaviorInvokingMockBehavior

java.lang.Object
  extended by org.unitils.mock.mockbehavior.impl.OriginalBehaviorInvokingMockBehavior
All Implemented Interfaces:
MockBehavior, ValidatableMockBehavior

public class OriginalBehaviorInvokingMockBehavior
extends Object
implements ValidatableMockBehavior

Mock behavior that, instead of mocking the method invocation, performs the actual behavior of the mocked class. This is used to implement the partial mock behavior. If there is no original behavior, e.g. mocking of an interface or abstract method, an exception is raised.

Author:
Filip Neven, Tim Ducheyne, Kenny Claes

Constructor Summary
OriginalBehaviorInvokingMockBehavior()
           
 
Method Summary
 void assertCanExecute(ProxyInvocation proxyInvocation)
          Checks whether the mock behavior can be executed for the given invocation.
 Object execute(ProxyInvocation proxyInvocation)
          Executes the mock behavior.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OriginalBehaviorInvokingMockBehavior

public OriginalBehaviorInvokingMockBehavior()
Method Detail

assertCanExecute

public void assertCanExecute(ProxyInvocation proxyInvocation)
                      throws UnitilsException
Checks whether the mock behavior can be executed for the given invocation. An exception is raised if the method is a void method or has a non-assignable return type.

Specified by:
assertCanExecute in interface ValidatableMockBehavior
Parameters:
proxyInvocation - The proxy method invocation, not null
Throws:
UnitilsException

execute

public Object execute(ProxyInvocation proxyInvocation)
               throws Throwable
Executes the mock behavior.

Specified by:
execute in interface MockBehavior
Parameters:
proxyInvocation - The proxy method invocation, not null
Returns:
The result value
Throws:
Throwable


Copyright © 2011. All Rights Reserved.