gpt4 book ai didi

java - 模拟创建 ThreadSafeClientConnManager 对象的类

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:22:21 25 4
gpt4 key购买 nike

我无法模拟一个类(使用 PowerMock 的 createMock 方法)。此类正在其构造函数中创建 ThreadSafeClientConnManager 类的对象。我在调用传递我的类名的 createMock 方法的那一行出现异常。以下是异常堆栈跟踪。但是,如果我运行集成测试,它工作正常。可能是什么问题?

[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)

最佳答案

您认为这是系统类加载问题吗?尝试引用此链接,它可能会给您一些指示。 http://code.google.com/p/powermock/wiki/MockSystem .

关于java - 模拟创建 ThreadSafeClientConnManager 对象的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12139662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com