【发布时间】:2011-11-24 18:12:41
【问题描述】:
我正在使用 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怎么样?我猜目前您正在尝试使用proxy设置值。
标签: java maven proxy maven-surefire-plugin http-unit