I seem to get this anytime I use PowerMock.create(Class)... I searched
the issues and this forum and didn't find anything about it. I
verified that @PrepareForTest was being picked up, because when I
tried to use EasyMock.create(Class) I got the Logging problem... If I
got rid of @PrepareForTest, the log4j problem went away, and then I
solved it with @PowerMockIgnore({"org.apache.log4j",
"org.apache.commons.logging"}), and put PowerMock.create() back in...
But I still get:
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass
(MockClassLoader.java:144)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass
(DeferSupportingClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at
org.powermock.api.easymock.internal.signedsupport.SignedSupportingClassProxyFactory.createProxy
(SignedSupportingClassProxyFactory.java:78)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:
51)
at org.powermock.api.easymock.PowerMock.doCreateMock(PowerMock.java:
2155)
at org.powermock.api.easymock.PowerMock.doMock(PowerMock.java:2110)
at org.powermock.api.easymock.PowerMock.createMock(PowerMock.java:92)
at com.aspentech.imos.test.AutoMock.createMock(AutoMock.java:276)
at com.aspentech.imos.test.AutoMock.initMocks(AutoMock.java:262)
at com.aspentech.imos.model.PipelineCycleTest.<init>
(PipelineCycleTest.java:43)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.createTestInstance
(PowerMockJUnit44RunnerDelegateImpl.java:201)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.createTest
(PowerMockJUnit44RunnerDelegateImpl.java:186)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod
(PowerMockJUnit44RunnerDelegateImpl.java:208)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods
(PowerMockJUnit44RunnerDelegateImpl.java:161)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl
$1.run(PowerMockJUnit44RunnerDelegateImpl.java:135)
at org.junit.internal.runners.ClassRoadie.runUnprotected
(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected
(ClassRoadie.java:37)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run
(PowerMockJUnit44RunnerDelegateImpl.java:133)
at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run
(JUnit4TestSuiteChunkerImpl.java:112)
at
org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run
(AbstractCommonPowerMockRunner.java:55)
at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:
85)
at com.intellij.rt.execution.junit.JUnitStarter.main
(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
90)
Never seen this before. If you upgrade to Javassist 3.11 do you still
get the same problem? If you do could you please attach an example
demonstrating the issue to our google group?
/Johan
Test is run both via ant and via intellij with the same results....
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
@RunWith( value = PowerMockRunner.class )
@PrepareForTest(value = {SomeObject.class})
public class PowerMockBugTest
{
@Test
public void testRecalc() {
PowerMock.createMock( SomeObject.class );
}
}
public class SomeObject
{
private int foo;
private SomeOtherObject bar = new SomeOtherObject();
public int getFoo()
{
return foo;
}
private void setFoo( int foo )
{
bar.notifyMe();
this.foo = foo;
}
public void recalc(int baz) {
setFoo(baz/2);
}
}
public class SomeOtherObject
{
public void notifyMe() {
// consider your self warned :)
public class SomeObject
{
private int foo;
public int getFoo()
{
return foo;
}
private void setFoo( int foo )
{
this.foo = foo;
}
public void recalc(int baz) {
setFoo(baz/2);
}
}
On Jan 25, 3:46 pm, Johan Haleby <johan.hal...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To post to this group, send email to powe...@googlegroups.com.
To unsubscribe from this group, send email to powermock+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/powermock?hl=en.
Which version of JUnit are you using? I am experiencing a similar
problem on our build server, but my tests run OK in Eclipse.
Currently, I am trying to figure out whether it was caused by the
older version of JUnit (version 4.4).
Thanks,
Ben
Michael
On Mar 3, 12:07 pm, Aneesh PU <anees...@gmail.com> wrote:
> I have the exact same exception happening from within eclipse. I am
> usingpowermock-easymock-1.3.5, Junit 4.4,easymock-2.5.2 and
> easymockclassextension-2.5.2. The exception seems to be getting thrown
> when I mock the parse method of android.net.Uri
>
> On Feb 8, 9:34 pm, Ben <wuhanch...@gmail.com> wrote:
>
>
>
> > Hi Gus,
>
> > Whichversionof JUnit are you using? I am experiencing a similar
> > problem on our build server, but my tests run OK in Eclipse.
> > Currently, I am trying to figure out whether it was caused by the
> > olderversionof JUnit (version4.4).
>
> > Thanks,
>
> > Ben
>
> > On Jan 25, 6:23 pm, Gus <gus.h...@gmail.com> wrote:
>
> > > Actually, I simplified it further... you can ignore SomeOtherObject,
> > > and just use this SomeObject...
>
> > > public class SomeObject
> > > {
> > > private int foo;
>
> > > public int getFoo()
> > > {
> > > return foo;
> > > }
>
> > > private void setFoo( int foo )
> > > {
> > > this.foo = foo;
> > > }
>
> > > public void recalc(int baz) {
> > > setFoo(baz/2);
> > > }
>
> > > }
>
> > > On Jan 25, 3:46 pm, Johan Haleby <johan.hal...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > Never seen this before. If you upgrade to Javassist 3.11 do you still
> > > > get the same problem? If you do could you please attach an example
> > > > demonstrating the issue to our google group?
>
> > > > /Johan
>
> > > > On Jan 25, 5:18 pm, Gus <gus.h...@gmail.com> wrote:
>
> > > > > I'm a bit stuck here...
>
> > > > > I seem to get this anytime I usePowerMock.create(Class)... I searched
> > > > > the issues and this forum and didn't find anything about it. I
> > > > > verified that @PrepareForTest was being picked up, because when I
> > > > > tried to useEasyMock.create(Class) I got the Logging problem... If I
> > > > > got rid of @PrepareForTest, the log4j problem went away, and then I
> > > > > solved it with @PowerMockIgnore({"org.apache.log4j",
> > > > > "org.apache.commons.logging"}), and putPowerMock.create() back in...
Hey Johan,
I am using PowerMockito.
Here is what I am doing:
@RunWith(PowerMockRunner.class)
@PrepareForTest(Foo.class)
public class PowerMockTest {
@Test
public void testSomething() throws Exception {
Bar bar = new Bar(null, null, null);
PowerMockito.mockStatic(Foo.class);
Mockito.when(Foo.someMethod(Mockito.anyString())).thenReturn("success");
String str = bar.someOtherMethod();
}
}
//Foo is my class which has a static method someMethod()
//Bar calls this static method from someOtherMethod()
I am getting the following error:
java.lang.IncompatibleClassChangeError: Class com.sun.jmx.mbeanserver.JmxMBeanServer does not implement the requested interface javax.management.MBeanServerConnection
...
...
...
I am using the following versions:
powermock-mockito-1.5
mockito-core-1.9.5
junit-4.7
objenesis-1.2
javassist-3.17.1
Help much appreciated!
Thanks
Pranay
--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to powermock+...@googlegroups.com.
Visit this group at http://groups.google.com/group/powermock?hl=en.For more options, visit https://groups.google.com/groups/opt_out.