Re: [powermock] java.lang.VerifyError: Wrong return type in function

954 views
Skip to first unread message

Johan Haleby

unread,
Jan 9, 2013, 7:38:36 AM1/9/13
to powe...@googlegroups.com
Hi, 

What JDK version are you using? What rule implementation are you using? (java agent or classloader based?)

Regards,
/Johan

On Wed, Jan 9, 2013 at 1:23 PM, Jumwah <james.mil...@gmail.com> wrote:
Hello everyone,

I am using Powermockito 1.5 (with mockito 1.9.5), using junit4-rule-1.5.  I'm mocking a static method which is checked through production code called indirectly by the test.  However, when I try to set up the test, I need to create a JMenu object - however, this throws a VerifyError - I think because the method it is complaining about is static - but I am not trying to (nor want to) mock it.

My test class looks basically like this:

@PrepareForTest( {MyClassWithStaticMethod.class} )
public class tester
{
@Rule
        public PowerMockRule rule = new PowerMockRule();
@Test
public void test()
{  
 mockStatic( MyClassWithStaticMethod .class);
 when( MyClassWithStaticMethod.staticMethod(true)).thenReturn(true);

 JMenuItem menuthing = new JMenu("hello");
                 
                 // the rest of the test
        }
}

and I get this error message when I run it....

java.lang.VerifyError: (class: javax/swing/plaf/metal/MetalLookAndFeel, method: getLayoutStyle signature: ()Ljavax/swing/LayoutStyle;) Wrong return type in function
at javax.swing.UIManager.setLookAndFeel(UIManager.java:554)
at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1317)
at javax.swing.UIManager.initialize(UIManager.java:1406)
at javax.swing.UIManager.maybeInitialize(UIManager.java:1394)
at javax.swing.UIManager.getUI(UIManager.java:980)
at javax.swing.JMenu.updateUI(JMenu.java:206)
at javax.swing.JMenuItem.init(JMenuItem.java:194)
at javax.swing.JMenuItem.<init>(JMenuItem.java:133)
at javax.swing.JMenuItem.<init>(JMenuItem.java:110)
at javax.swing.JMenu.<init>(JMenu.java:158)

Any ideas what I am doing wrong?

Thanks,
James.

--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To view this discussion on the web visit https://groups.google.com/d/msg/powermock/-/d3a8oupNBLQJ.
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.

Jumwah

unread,
Jan 9, 2013, 7:45:27 AM1/9/13
to powe...@googlegroups.com
Hi,

Currently using 1.6.0_30 and using classloading objenesis.  I couldn't get the xstream to work either.

Cheers,
James.

Johan Haleby

unread,
Jan 9, 2013, 7:48:38 AM1/9/13
to powe...@googlegroups.com
They are all experimental, I would try the Java agent based rule and see if that works. 

Regards,
/Johan

To view this discussion on the web visit https://groups.google.com/d/msg/powermock/-/BWkT1V2BvSwJ.

Jumwah

unread,
Jan 9, 2013, 7:57:49 AM1/9/13
to powe...@googlegroups.com
Ah, excellent, yes, changed to the agent and it all works perfectly now, thank you very much!

Cheers,
James.

Johan Haleby

unread,
Jan 9, 2013, 8:34:27 AM1/9/13
to powe...@googlegroups.com
Great!

To view this discussion on the web visit https://groups.google.com/d/msg/powermock/-/q7ulla9XI4sJ.
Reply all
Reply to author
Forward
0 new messages