The problem is with new Object[]{foo, bar}, which is being interpreted
as a single object and checked for equality. If you want to match two
parameters, you need new Predicate{} { IsEqual(foo), IsEqual(bar) }. Or,
alternatively, P.args(P.eq(foo), P.eq(bar)).
S.
Barry Kaplan wrote:
> AbstractMockCall.checkArguments() always seem to say the number of
> arguments is wrong. Consider the following code snippets:
>
> ----
> public interface PositionMemento {
> int getQuantity(Object foo, Object bar);
> }
>
> private Mock mock = new Mock(PositionMemento.class);
> private PositionMemento mockProxy = (PositionMemento) mock.proxy();
> mock.expectAndReturn("getQuantity", new Object[]{foo, bar}, new
> Integer(1));
> int q = mockProxy.getQuantity(foo, bar);
> ----
>
> The AbstractMockCall.getArgumentsCounts() checks the length of
> '_expected_args'. But this object always seems to be a Constraint (an
> and constraint containing the two method parameter objects), with a
> length of 1. But the 'args' parameter is an array of the actual args
> (ie, foo and bar) with a length of 2. Thus checkArguments() always fails.
>
> Any clues? Is this a known problem.
> thanks!
>
> (BTW, I tried running the junit task from my CVS checkout to see if
> maybe mockobjects was broke, but that seemed to do nothing. I also tried
> to search the mailing list, but alas there are not archives.)
>
>
>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: To learn the basics of securing your
> web site with SSL, click here to get a FREE TRIAL of a Thawte Server
> Certificate: http://www.gothawte.com/rd524.html
> _______________________________________________
> Mockobjects-java-dev mailing list
> Moc...@li...
> https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev
|