« 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

=============================================================================================================================

http://www.dstinternational.com

Notice: This e-mail and any attachments are intended only for the individual or company to which it is addressed and may contain information which is privileged, confidential and prohibited from disclosure or unauthorized use under applicable law.  If you are not the intended recipient of this e-mail, you are hereby notified that any use, dissemination or copying of this e-mail or the information contained in this e-mail is strictly prohibited by the sender.

Whilst we run anti-virus software on all internet e-mails we are not liable for any loss or damage.  The recipient is advised to run their own anti-virus software.

If you have received this transmission in error, please return the material  received to the sender and delete all copies from your system. Thank you.

DST International Limited is a company registered in England and Wales with company number 1772349.
DST International Group Services Limited is a company registered in England and Wales with company number 5211646.
DST International Billing Limited is a company registered in England and Wales with company number 4370287.
DST International Output Limited is a company registered in England and Wales with company number 4220397.
The registered office for all the above mentioned companies is: DST House, St Mark's Hill, Surbiton, Surrey, KT6 4QD, England.


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

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Using Custom Actions