NoSuchAlgorithmException
今天在写UT时遇到了下面的问题:
1. 使用的powermock来处理static方法;
2. 静态方法里的却有使用到org.apache.http.client(4.3.1)的方法
异常如下:
Caused by: org.apache.http.conn.ssl.SSLInitializationException: class configured for SSLContext: sun.security.ssl.SSLContextImpl$TLS10Context not a SSLContext at org.apache.http.conn.ssl.SSLContexts.createDefault(SSLContexts.java:58) at org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(SSLSocketFactory.java:162) at com.taobao.tae.security.topscan.TaeTopScanClient.<clinit>(TaeTopScanClient.java:73) ... 37 more Caused by: java.security.NoSuchAlgorithmException: class configured for SSLContext: sun.security.ssl.SSLContextImpl$TLS10Context not a SSLContext at sun.security.jca.GetInstance.checkSuperClass(GetInstance.java:258) at sun.security.jca.GetInstance.getInstance(GetInstance.java:237) at sun.security.jca.GetInstance.getInstance(GetInstance.java:164) at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156) at org.apache.http.conn.ssl.SSLContexts.createDefault(SSLContexts.java:54) ... 39 more
google了一下,倒不是应为包版本或者不存在的问题,是powermock机制的问题。
解决方法:
在UTclass上增加annotation:
@PowerMockIgnore("javax.net.ssl.*")