Eclipse中的代理服务器测试失败 [英] Failed web service unit tests behind a proxy in Eclipse

查看:157
本文介绍了Eclipse中的代理服务器测试失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

我找到了解决方案:显然可以在Eclipse中的运行/调试设置中配置代理。要执行此操作:


  1. 右键单击单元测试类

  2. 调试为 - 调试配置

  3. 转到标签参数

  4. 将代理配置添加到VM参数:




    • -Dhttp.proxyHost = proxy.host.com

    • -Dhttp.proxyPort = 8080

    • -Dhttp.nonProxyHosts = [用管道字符分隔的主机列表]


如果您在密码保护代理后面,您必须添加:




  • -Dhttp.proxyUser = someUserName

  • -Dhttp.proxyPassword = somePassword


I have a problem executing unit tests in Eclipse behind a proxy, as the classes used by the unit tests call some web services, which are behind a proxy. In Tomcat I can of course specify a proxy to be used, but when I run unit tests directly from Eclipse, the proxy configuration of Eclipse seems to be ignored. How can I configure my unit tests or Eclipse to use a proxy in this case?

解决方案

I found the solution: apparently one can configure the proxy in run/debug settings in Eclipse. To do this:

  1. right click on the unit test class
  2. debug as - debug configurations
  3. go to tab "Arguments"
  4. add proxy configuration to "VM arguments":

    • -Dhttp.proxyHost=proxy.host.com
    • -Dhttp.proxyPort=8080
    • -Dhttp.nonProxyHosts=[list of hosts separated with pipe character]

If you are behind a password protected proxy, you have to add:

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

这篇关于Eclipse中的代理服务器测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆