我正在使用httpunit访问服务器。
我需要配置代理设置,包括http和https。
我在settings.xml文件中设置了配置,但是surefire似乎忽略了它!?
我希望尽可能减少重复配置。
在surefire插件配置中,我尝试过:
<systemPropertyVariables>
<http.proxyHost>${http.proxyHost}</http.proxyHost>
</systemPropertyVariables>
和
<argLine>-Dhttp.proxyHost=${http.proxyHost}</argLine>
和
<argLine>-Dhttp.proxyHost=${settings.proxies[protocol=http].host}</argLine>
还有其他几种组合。
我在单元测试中使用以下代码打印系统属性:
for (String propertyName : new TreeSet<String>(System.getProperties().stringPropertyNames())){
System.out.println(propertyName + ": " + System.getProperty(propertyName));
}
到目前为止唯一有效的是明确指定数值,例如:
<systemPropertyVariables>
<http.proxyHost>myProxy</http.proxyHost>
</systemPropertyVariables>
或者<argLine>-Dhttp.proxyHost=myProxy</argLine>
但正如我所说,如果可能的话,我不想重复配置。
我该如何在单元测试中使用在settings.xml文件中设置的代理设置?
settings.xml
中将http.proxyHost
作为一个property
属性怎么样?我猜目前你正在尝试使用代理设置值。 - Raghuram