I am new to Powermockito. I have a Junit4 setup with Ant1.7.1. I am mocking a final class using
mockito 1.8.5
When I run this
test using Eclipse, it runs fine. When I run the test using my
ant build I get the following error. From this error it looks like it can find Powermockito and mockito in its classpath and there is just one mockito jar in the lib (claspath).
[
junit] java.lang.ExceptionInInitializerError
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:169)
[junit] Caused by: java.lang.IllegalArgumentException: Cannot subclass final class class com.company.FinalDB
[junit] at org.mockito.cglib.proxy.Enhancer.generateClass(Enhancer.java:447)
[junit] at org.mockito.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
[junit] at org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:217)
[junit] at org.mockito.cglib.proxy.Enhancer.createHelper(Enhancer.java:378)
[junit] at org.mockito.cglib.proxy.Enhancer.createClass(Enhancer.java:318)
[junit] at org.mockito.internal.creation.jmock.ClassImposterizer.createProxyClass(ClassImposterizer.java:93)
[junit] at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:50)
[junit] at org.powermock.api.mockito.internal.mockcreation.MockCreator.createMethodInvocationControl(MockCreator.java:100)
[junit] at org.powermock.api.mockito.internal.mockcreation.MockCreator.mock(MockCreator.java:58)
[junit] at org.powermock.api.mockito.PowerMockito.mock(PowerMockito.java:138)
[junit] at com.hp.platform.store.archiver.SomeClassTest.getMockSomeClass(SomeClassTest.java:78)
My eclipse and Ant are pointing to the same junit. I dont think this is a Junit issue, but a mockito issue but I cannot figure out how to start figuring out the issue.
Why does it work with Eclipse and not with Ant? How can I figure out the order in which the Classloaders are loaded?
Thanks in advance.
Seema.