Eclipse中代理背后的Web服务单元测试失败

时间:2009-09-30 13:02:12

标签: eclipse unit-testing proxy junit

我在Eclipse中在代理后面执行单元测试时遇到问题,因为单元测试使用的类调用一些代理后面的Web服务。在Tomcat中,我当然可以指定要使用的代理,但是当我直接从Eclipse运行单元测试时,Eclipse的代理配置似乎被忽略了。在这种情况下,如何配置单元测试或Eclipse以使用代理?

1 个答案:

答案 0 :(得分:11)

我找到了解决方案:显然可以在Eclipse中的运行/调试设置中配置代理。要做到这一点:

  1. 右键单击单元测试类
  2. debug as - debug configurations
  3. 转到标签“参数”
  4. 将代理配置添加到“VM参数”:

    • -Dhttp.proxyHost=proxy.host.com
    • -Dhttp.proxyPort=8080
    • -Dhttp.nonProxyHosts=[list of hosts separated with pipe character]
  5. 如果您位于受密码保护的代理服务器后面,则必须添加:

    • -Dhttp.proxyUser=someUserName
    • -Dhttp.proxyPassword=somePassword