Exception using SpringRunner with PowermockRunner

304 views
Skip to first unread message

Abhishek kumar

unread,
May 14, 2018, 12:04:37 AM5/14/18
to PowerMock
I am trying to test a JavaMail api and using SpringRunner and PowerMockRunner but it is failing. Following is the test config that I am using.

    @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?
Reply all
Reply to author
Forward
0 new messages