chcchangchc / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

impossible to mock private methods with multiple arguments #289

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When you try to mock private methods with multiple arguments via 
any PowerMockito method using DefaultMethodExpectationSetup
you get 
java.lang.IllegalArgumentException: wrong number of arguments

The problem is reproducible in 1.4.6 version. 

It is caused by wrong arguments passed into method.invoke:
method.invoke(object, firstArgument, additionalArguments)
where an array of additional arguments is treated as single argument.
Instead it should be 
method.invoke(object, firstAndAdditionalArgumentsArray)

See patch and test attached.

Mvh,
Stas Chizhov

Original issue reported on code.google.com by schiz...@gmail.com on 6 Nov 2010 at 11:46

Attachments:

GoogleCodeExporter commented 9 years ago
Hi, 

Thanks for the report and a big thanks for the patch. I'll evaluate it when I 
get some time over.

/Johan

Original comment by johan.ha...@gmail.com on 15 Nov 2010 at 7:32

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 15 Nov 2010 at 7:34

GoogleCodeExporter commented 9 years ago
Just applied the patch and it's now committed to trunk. Thank you very much for 
the help, really appreciated!

Original comment by johan.ha...@gmail.com on 16 Nov 2010 at 8:01

GoogleCodeExporter commented 9 years ago
Glad to help. You guys are doing great stuff :)

Original comment by schiz...@gmail.com on 16 Nov 2010 at 10:31