I am trying to test a JavaMail api and using SpringRunner and PowerMockRunner but it is failing.
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringRunner.class)
@PowerMockIgnore(value = {"javax.management.*"})
@SpringBootTest
public class BaseITest {
@PrepareForTest(value = {MyStaticHelper.class})
@Test
public void testListFolders() {
// mock static method
// Use JavaMail API
}
}
I am getting this exception:
javax.mail.MessagingException: java.security.NoSuchAlgorithmException: class configured for SSLContext: sun.security.ssl.SSLContextImpl$DefaultSSLContext not a SSLContext
If I remove @PowerMockIgnore(value = {"javax.management.*"}) then I am getting this exception:
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/powermock/core/classloader/MockClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer"
The dependency versions used are:
- powermock-api-mockito: 1.7.1
- powermock-module-junit4: 1.7.1
- mockito-all: 2.0.2-beta
- mockito-core: 2.8.9
Can someone help?