Integration of PowerMockRunner with JbpmJUnitTestCase

Solution Unverified - Updated -

Issue

  • There is a requirement to mock objects with PowerMockRunner with @RunWith(PowerMockRunner.class) and extending JbpmJUnitTestCase to test a BPMN2 process in jBPM5. The mocking is necessary since the jBPM5 makes use of a java class (methods of the java class are static).
    However, it is found that while running the Junit tests it gives an exception like following.
java.lang.IllegalStateException: Failed to transform class with name org.jbpm.test.JbpmJUnitTestCase. Reason: javassist.NotFoundException: org.h2.tools.DeleteDbFiles
                at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:207)
                at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:145)
                at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:65)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
                at java.lang.ClassLoader.defineClass1(Native Method)
                at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
                at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
                at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:210)
                at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:145)
                at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:65)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
                at java.lang.Class.forName0(Native Method)
                at java.lang.Class.forName(Class.java:270)
...

How to fix this issue?

Environment

  • Red Hat JBoss BRMS (BRMS)
    • 5.3.x
  • PowerMock

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content