Powermock - Mock final Classes - BootstrapSecurityManager
This post has NOT been accepted by the mailing list yet.
Unit Test with default java security manager
I use powermock. I use also advanced feature to mock classes which are declared as 'final'. In order to make that work I have to set the security manager of the test execution to the default java security manager
def agent = project.configurations.agent.asPath
def policy = rootProject.file('osgi/security.policy')
// Gradle will execute the tests with a own security manager.
// This security manager will make PowerMock tests fail
// Note: -Djava.security.manager <- doesn't work, manager must be specified explicitly.
In general that works fine but from time to time the tests fail. It seems like that sometimes a test case will be executed with the gradle security manager (BootstrapSecurityManager) and sometimes with the the default java security manager.
Any idea why it behaves inconsistent from build to build?