I am unable to mock a class (using PowerMock's createMock method). This class is creating an object of ThreadSafeClientConnManager class in its constructor. I get exception at the line where I called createMock method passing my class name. Following is the exception stack trace. It is working fine if I run an integration test however. What could be the issue ?
[junit] Caused by: java.lang.IllegalStateException: Failure initializing default SSL context
[junit] at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:211)
[junit] at org.apache.http.conn.ssl.SSLSocketFactory.<init>(SSLSocketFactory.java:333)
[junit] at org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(SSLSocketFactory.java:165)
[junit] at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:45)
[junit] at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager.<init>(ThreadSafeClientConnManager.java:98)
[junit] at com.amazon.marketplace.payment.tsf.TSFClient.<init>(TSFClient.java:109)
[junit] at com.amazon.marketplace.payment.tsf.TSFClient.<clinit>(TSFClient.java:95)
[junit] Caused by: java.security.NoSuchAlgorithmException: class configured for KeyManagerFactory: com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$SunX509 not a KeyManagerFactory
[junit] at sun.security.jca.GetInstance.checkSuperClass(GetInstance.java:242)
[junit] at sun.security.jca.GetInstance.getInstance(GetInstance.java:221)
[junit] at sun.security.jca.GetInstance.getInstance(GetInstance.java:147)
[junit] at javax.net.ssl.KeyManagerFactory.getInstance(KeyManagerFactory.java:121)
[junit] at org.apache.http.conn.ssl.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:184)
[junit] at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:209)
Do you think it's a system class loading issue? try referring to this link it might give you some pointers . http://code.google.com/p/powermock/wiki/MockSystem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With