Open GoogleCodeExporter opened 8 years ago
I get the error even if I use the latest binaries of Powermock and associated
dependencies. I am attaching the error stack
java.lang.IllegalArgumentException: Cannot subclass final class class
...SessionManagerHelper at
net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:446) at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.jav
a:25) at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at
net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317) at
org.easymock.internal.ClassProxyFactory.createProxy(ClassProxyFactory.java:181)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:60) at
org.powermock.api.easymock.PowerMock.doCreateMock(PowerMock.java:2212) at
org.powermock.api.easymock.PowerMock.doMock(PowerMock.java:2163) at
org.powermock.api.easymock.PowerMock.mockStatic(PowerMock.java:287) at
...ApplicationStateHelperTest.setUp(Unknown Source)
Original comment by praya...@gmail.com
on 19 Jun 2012 at 9:00
Perhaps there's a JUnit conflict in the classpath?
Original comment by johan.ha...@gmail.com
on 13 Jul 2012 at 7:05
Please use Powermock to resolve this issue.
For ex: if u are trying to mock URL (java.net.URL) class using easymock it will
throw the above mentioned exception. Use Powermock instead of easymock.
URL url = EasyMock.createMock(URL.class) --> Will throw exception
URL url = PowerMock.createMock(URL.class) --> Works fine (But do not forget to
add the class in @PrepareForTest).
Original comment by bharath...@gmail.com
on 27 Jul 2012 at 12:24
I am facing the same problem with Ant 1.8.2+. In eclipse and Ant 1.7.1 every
thing is working fine but not working in Ant 1.8.2 and above. I also tried
PowerMock.createMock instead Mockito.createMock and @PrepareForTest on class
level but no luck.
PowerMockito.mockStatic(StringUtils.class);
PowerMockito.when(StringUtils.getTerm("abcd")).thenReturn("xyz");
Original comment by ashishdu...@gmail.com
on 18 Sep 2012 at 3:35
Ehi guys ? Have you solved ?
I'm getting a lot of problem with Ant and @PrepareTest !
Original comment by Benedett...@gmail.com
on 15 Jan 2014 at 11:30
Is your test case class extending from TestCase?
Note that if you are using a mixed Junit3/4 style test then Ant will prioritise
v3 over v4 and fail to invoke the PowerMock runner.
I had a very similar problem and sorted it out by converting the test case
class to annotations only.
Please see here for a related example that might help you:
http://stackoverflow.com/questions/7796295/running-junit-through-ant-does-not-se
em-to-use-custom-class-runner
Original comment by leonardo...@gmail.com
on 19 Aug 2014 at 9:10
Original issue reported on code.google.com by
praya...@gmail.com
on 19 Jun 2012 at 8:46