Failed web service tests behind a proxy in Eclipse

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

+5
source share
1 answer

I found a solution: apparently, you can configure the proxy in the start / debug settings in Eclipse. For this:

  • right click on unit test class
  • debug as - debug configurations
  • go to the "Arguments" tab
  • 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 must add:

  • -Dhttp.proxyUser=someUserName
  • -Dhttp.proxyPassword=somePassword
+11
source

All Articles