org.unitils.mock.mockbehavior.impl
Class ExceptionThrowingMockBehavior

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

public class ExceptionThrowingMockBehavior
extends Object
implements ValidatableMockBehavior

Mock behavior that throws a given exception.

Author:
Filip Neven, Tim Ducheyne, Kenny Claes

Constructor Summary
ExceptionThrowingMockBehavior(Throwable exceptionToThrow)
          Creates the throwing behavior for the given exception.
 
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

ExceptionThrowingMockBehavior

public ExceptionThrowingMockBehavior(Throwable exceptionToThrow)
Creates the throwing behavior for the given exception.

Parameters:
exceptionToThrow - The exception, not null
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:
Nothing
Throws:
Throwable


Copyright © 2011. All Rights Reserved.