« Return to Thread: Using Custom Actions

Using Custom Actions

by Andy.Bell :: Rate this Message:

Reply to Author | View in Thread

Hi

I'm trying to write a custom action, using the example at this page:
http://www.jmock.org/custom-actions.html

I'm setting my expectations as follows:

checking(new Expectations() {
            {
               
one(mockValidationServer).invokeValidation(with(equal("Validate")),
with(a(Object[].class)));
                will(setResponseValues());
                will(returnValue(true));
            }
        });

and I have a factory method setResponseValues as follows:

private static <T> Action setResponseValues() {
        return new SetSuccessResponse<T>(999);
    }
   
(999 being just a bit of test data while I'm trying to make this work);

My SetSuccessResponse class is as follows:

public class SetSuccessResponse<T> implements Action {
       
        private int responseValue;
       
        public SetSuccessResponse(int value) {
                responseValue = value;
        }
       
        public Object invoke(Invocation invocation) throws Throwable {
        Object [] params = (Object [] )invocation.getParameter(1);
        params[2] = responseValue;
        return null;
        }
       
    public void describeTo(Description description) {
            description.appendText("Test...");
    }
}

The constructor of the class is called OK and the test passes BUT I don't think
the invoke method of SetSuccessResponse is ever called. If I set a breakpoint in
it the invoke method and debug the test, the code never stops at the breakpoint
nor is the responseValue ever passed into the params array.

Any ideas?

AndyB



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Using Custom Actions