Griffon 0.9.5-rc2

griffon.test
[Java] Class MockClosureProxy

java.lang.Object
  groovy.lang.GroovyObjectSupport
      groovy.lang.Closure
          griffon.test.AbstractClosureProxy
              griffon.test.MockClosureProxy

public class MockClosureProxy
extends AbstractClosureProxy

This closure proxy stores an expectation and checks it before each call to the target closure. It is used by the Griffon mocking framework.

Authors:
Peter Ledbrook (Grails 1.1)


Field Summary
Object expectation

String methodName

 
Fields inherited from class AbstractClosureProxy
target
 
Fields inherited from class Closure
OWNER_FIRST, DELEGATE_FIRST, OWNER_ONLY, DELEGATE_ONLY, TO_SELF, DONE, SKIP, IDENTITY
 
Constructor Summary
MockClosureProxy(Closure target, String methodName, Object expectation)

Constructor.

 
Method Summary
protected Closure createWrapper(Closure c)

Creates a new MockClosureProxy wrapping the given closure.

protected void doAfterCall(Object[] args)

Empty implementation.

protected void doBeforeCall(Object[] args)

Checks whether the target "method" is expected or not, on the basis that this closure is mocking a method with the name methodName.

 
Methods inherited from class AbstractClosureProxy
asWritable, call, createWrapper, curry, doAfterCall, doBeforeCall, equals, getDelegate, getDirective, getMaximumNumberOfParameters, getParameterTypes, getProperty, getResolveStrategy, hashCode, isCase, setDelegate, setDirective, setProperty, setResolveStrategy
 
Methods inherited from class Closure
run, setProperty, getProperty, clone, getParameterTypes, setDelegate, getOwner, leftShift, leftShift, rightShift, call, call, call, getDelegate, getMaximumNumberOfParameters, setResolveStrategy, getResolveStrategy, getThisObject, getDirective, setDirective, isCase, asWritable, curry, rcurry, rcurry, ncurry, ncurry, memoize, memoizeAtMost, memoizeAtLeast, memoizeBetween, trampoline, trampoline, getMetaClass, setMetaClass, invokeMethod, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

expectation

Object expectation


methodName

String methodName


 
Constructor Detail

MockClosureProxy

public MockClosureProxy(Closure target, String methodName, Object expectation)
Constructor.
Parameters:
target
methodName
expectation


 
Method Detail

createWrapper

@Override
protected Closure createWrapper(Closure c)
Creates a new MockClosureProxy wrapping the given closure.
Parameters:
c - The closure to wrap.
Returns:
the new proxy.


doAfterCall

@Override
protected void doAfterCall(Object[] args)
Empty implementation.
Parameters:
args - The arguments to the target closure.


doBeforeCall

@Override
protected void doBeforeCall(Object[] args)
Checks whether the target "method" is expected or not, on the basis that this closure is mocking a method with the name methodName.
Parameters:
args - The arguments to the "method" (actually the argumetns to the target closure invocation).


 

Groovy Documentation