[英]System properties in unit tests when run with intellij
我正在使用intellij跑步程序进行单元测试。
在应用程序的主要方法中,我们将密钥库设置为以下值:
/home/oozen/workspace/wakeup/src/main/resources/Certif.p12
public void run(String... args){
System.setProperty("javax.net.ssl.keyStore", vodafoneKeystore);
System.setProperty("javax.net.ssl.keyStorePassword", vodafoneKeystorePassword);
logger.info(" **************** WakeUpApp **************** ");
logger.info("vodafoneKeystore is set to {}", vodafoneKeystore);
}
这样可以正常生产。 但是当我使用intellij时,没有进行单元测试。
在测试中,当我记录getProperty的结果时,我看到了我们在代码中设置的内容。
在测试方法的开始,我可以看到该值已正确设置:
logger.info(" ################## KEYSTORE : {}", System.getProperty("javax.net.ssl.keyStore"));
################## KEYSTORE : /home/oozen/workspace/wakeup/src/main/resources/Certif.p12
但是在握手期间,我看到消息: no certificate found
导致身份验证失败。
有什么想法吗?
我知道我可以使用arg来运行测试:... -Djavax.net.ssl.keyStore=...
但我不想.... :)
另外,@ Thiru显示了一种在外部进行设置的方法,但我的目标是能够从代码中进行设置,并能够在单元测试中依赖它。
提前致谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.