Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #485

Closed
johanhaleby opened this issue Jul 25, 2015 · 1 comment
Closed

Issue #485

johanhaleby opened this issue Jul 25, 2015 · 1 comment

Comments

@johanhaleby
Copy link
Collaborator

From ande.brb on October 10, 2013 15:20:40

What steps will reproduce the problem? 1. Run the test class attached. Error will be thrown. What is the expected output? What do you see instead? String "mocked" in the console but I got an error. What version of the product are you using? On what operating system? R: powermock-mockito-1.5.1-full.jar, jdk7. Please provide any additional information below. The problem is on line 37 of the class DefaultPrivatelyExpectedArguments.

Note the declaration of the following methods:

DefaultPrivatelyExpectedArguments#withArguments(Object firstArgument, Object... additionalArguments)
Method#invoke(Object obj, Object... args)

And the method call:
method.invoke(mock, firstArgument, additionalArguments);

If I call the method withArguments with more than two arguments, held that: the call to the invoke method will always be considered to have only two parameters. One being the first argument and the other an array with the other arguments.

Solution: change the method signature to DefaultPrivatelyExpectedArguments#withArguments(Object... arguments) or create a temporary array for the arguments,

Object[] array = new Object[additionalArguments.length + 1];
array[0] = firstArgument;
System.arraycopy(additionalArguments, 0, array, 1, additionalArguments.length);
method.invoke(mock, array);

Attachment: PowerMockitoIssue.java

Original issue: http://code.google.com/p/powermock/issues/detail?id=465

@johanhaleby
Copy link
Collaborator Author

From johan.ha...@gmail.com on January 21, 2014 05:04:49

This has been fixed in trunk.

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant