tiebin-zhang / powermock

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

Getting error mocking intter final class with PowerMock and Mockito #438

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a class to test that calls remote REST endpoing using 
com.sun.jersey.api.client.WebResource: 
webResource.path("url").accept(MediaType.APPLICATION_XML_TYPE).get(String.class)
; 
2. Create a unit test for that class with the @PrepareForTest Attribute
3. Run the test
4. Error occurs with "Invalid length XXXX in LocalVariableTable"

What is the expected output? What do you see instead?
It should not throw an exception

What version of the product are you using? On what operating system?
OS: Win7
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
org.mockito:mockito-all:1.9.5
org.powermock:powermock-api-mockito:1.5
org.powermock:powermock-module-junit4:1.5
junit:junit:4.8.2
com.sun.jersey:jersey-client:1.9.1:compile

Please provide any additional information below.
I tried also on Java(TM) SE Runtime Environment (build 1.6.0_33-b03) with the 
same result

Similar to https://code.google.com/p/powermock/issues/detail?id=266

Original issue reported on code.google.com by Svitlana...@gmail.com on 7 Apr 2013 at 4:01

GoogleCodeExporter commented 9 years ago
I faced the same issue when I was trying to mock WebResource.Builder class, 
which is public final inner in jersey-client 1.9.1. Finally I updated jersey to 
1.17 where this class is not final any more. Not sure if PowerMock is able to 
mock final inner classes.

Original comment by Maksym.F...@gmail.com on 9 Apr 2013 at 11:26