Mocking com.ibm.mq.jms.MQQueueConnectionFactory

1,027 views
Skip to first unread message

ron.difrango

unread,
Jun 3, 2014, 5:02:26 PM6/3/14
to powe...@googlegroups.com
I'm attempting to mock com.ibm.mq.jms.MQQueueConnectionFactory and when I do, I get the following error:

java.lang.VerifyError: (class: com/ibm/msg/client/jms/internal/JmsReadablePropertyContextImpl, method: toString signature: ()Ljava/lang/String;) Unable to pop operand off an empty stack
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at javassist.runtime.Desc.getClassObject(Desc.java:43)
at javassist.runtime.Desc.getClassType(Desc.java:152)
at javassist.runtime.Desc.getType(Desc.java:122)
at javassist.runtime.Desc.getType(Desc.java:78)
at com.capitalone.api.commons.web.config.MQAuditSpringConfigTest.testAuditTemplate(MQAuditSpringConfigTest.java:55)

My test starts with:

@RunWith(PowerMockRunner.class)
@MockPolicy(Slf4jMockPolicy.class)
@PrepareForTest({MQAuditSpringConfig.class, MQAuditSpringConfigTest.class, MQConnectionFactory.class,
        MQQueueConnectionFactory.class, JmsJndiConnectionFactoryImpl.class, JmsConnectionFactoryImpl.class,
        JmsPropertyContextImpl.class, JmsReadablePropertyContextImpl.class})
@SuppressStaticInitializationFor({"com.ibm.mq.jms.MQConnectionFactory", "com.ibm.mq.jms.MQQueueConnectionFactory",
        "com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl",
        "com.ibm.msg.client.jms.admin.JmsJndiConnectionFactoryImpl",
        "com.ibm.msg.client.jms.internal.JmsPropertyContextImpl",
        "com.ibm.msg.client.jms.internal.JmsReadablePropertyContextImpl"})

And then the line in question is:

MQQueueConnectionFactory mqFactory = new MQQueueConnectionFactory();

ron.difrango

unread,
Jun 3, 2014, 5:05:53 PM6/3/14
to powe...@googlegroups.com
MQQueueConnectionFactory mqFactory = PowerMockito.mock(MQQueueConnectionFactory.class);

Johan Haleby

unread,
Jun 4, 2014, 1:30:50 AM6/4/14
to powe...@googlegroups.com
Seems like a complicated test setup. Perhaps you could just use an in-memory JMS provider such as ActiveMQ when you run your tests? Otherwise you could try starting your JVM with "-XX:-UseSplitVerifier".


/Johan


MQQueueConnectionFactory mqFactory = PowerMockito.mock(MQQueueConnectionFactory.class);
--
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.
To post to this group, send email to powe...@googlegroups.com.
Visit this group at http://groups.google.com/group/powermock.
For more options, visit https://groups.google.com/d/optout.

ron.difrango

unread,
Jun 4, 2014, 9:42:31 AM6/4/14
to powe...@googlegroups.com
Johan,

Unfortunately that is not an option as our production code needs to use IBM MQ and therefore I was trying to build unit tests that we build the classes appropriate, but I wanted to do so via mocks.

I'll try the -XX:-UseSplitVerifier and see if that works.

Thanks,

Ron
Reply all
Reply to author
Forward
0 new messages