org.jmock.internal
Class ReturnDefaultValueAction

java.lang.Object
  extended by org.jmock.internal.ReturnDefaultValueAction
All Implemented Interfaces:
org.hamcrest.SelfDescribing, Action, Invokable

public class ReturnDefaultValueAction
extends Object
implements Action

Returns a value of the invoked method's result type. Returns nothing from void methods. Zero or false results are returned for primitive types. Arrays and strings are returned with a length of zero. Types that can be imposterised by the action's Imposteriser are returned as Null Objects. Otherwise null is returned. The default value can be overridden for specific types.

Author:
nat

Constructor Summary
ReturnDefaultValueAction()
           
ReturnDefaultValueAction(Imposteriser imposteriser)
           
 
Method Summary
 void addResult(Class<?> resultType, Object resultValue)
           
protected  void createDefaultResults()
           
 void describeTo(org.hamcrest.Description description)
           
 Object invoke(Invocation invocation)
          Performs an action in response to an invocation.
 void setImposteriser(Imposteriser newImposteriser)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReturnDefaultValueAction

public ReturnDefaultValueAction(Imposteriser imposteriser)

ReturnDefaultValueAction

public ReturnDefaultValueAction()
Method Detail

setImposteriser

public void setImposteriser(Imposteriser newImposteriser)

describeTo

public void describeTo(org.hamcrest.Description description)
Specified by:
describeTo in interface org.hamcrest.SelfDescribing

addResult

public void addResult(Class<?> resultType,
                      Object resultValue)

invoke

public Object invoke(Invocation invocation)
              throws Throwable
Description copied from interface: Invokable
Performs an action in response to an invocation.

Specified by:
invoke in interface Invokable
Parameters:
invocation - The invocation to perform.
Returns:
The result of the invocation, if not throwing an exception. Must return null if the invoked method has a void return type.
Throws:
Throwable - An exception to be thrown to the caller, if not returning a value. Any checked exception thrown must be in the throws list of the invoked method.

createDefaultResults

protected void createDefaultResults()


Copyright © 2003-2012 jMock. All Rights Reserved.