TestNG PowerMockObjectFactory and Thread's contextClassLoader #335

johanhaleby opened this Issue Jul 24, 2015 · 1 comment


None yet
1 participant

johanhaleby commented Jul 24, 2015

From mathos.m...@gmail.com on March 10, 2011 19:16:32

The PowerMockRunner class sets the current's thread contextClassLoader with the mock'd classloader, this is not done in TestNG PowerMockObjectFactory. Consequently if there is dependent classes that are using reflection by pulling the contextClassLoader from the current thread, it has class cast exception issues.

I ran accross the issue trying to use Drools with TestNG + PowerMock. Simply ignoring the drools packages keeps the rules it runs to properly recognize the classes.

I've attached a patch that will set the thread accordingly.

Attachment: testng_mock.diff

Original issue: http://code.google.com/p/powermock/issues/detail?id=315


johanhaleby commented Jul 24, 2015

From johan.ha...@gmail.com on April 05, 2011 11:45:49

Sorry for taking so long to reply. I've applied your patch and committed the result to trunk ( r1592 ). Thanks for the patch!

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment