cloudfoundry/vcap-java-client — pull request #90 by gberche-orange (2013-09-20 11:23:49+00:00)
Title: Live tests for HTTP proxy support

With this PR CloudFoundryClientTest now goes systematically through an inJvm proxy to quickly detect proxy-related regressions

This is done by starting an inJvm Jetty proxy, and detecting direct network calls that don't go through the proxy using byteman rules that throw an IOException. The jetty proxy is started before all tests (@BeforeClass) and shutdown at the end of tests, so it should have little impact on overall tests duration. Byteman rules are injected into the JDK bytecode by a JVM agent in a distinct jvm. I tested this on windows7 with both direct internet connectivity and restricted connectivity behing a corporate proxy. The pom.xml dependency on tools.jar inspired from byteman sources aims at getting this portable on any JVM (platform specifics on location of tools.jar. Heuristic relies on java.home property to find it.) I hope there won't be surprises on other platforms including travis.

A specific CloudFoundryClientTest.checkByteManrulesAndInJvmProxyAssertMechanisms() test case verifies that the jetty and byteman assertion mechanism properly work for different ways of making outgoing HTTP calls.

The proxy behavior can be disabled by defining the http.skipInJvmProxy system property. Also refer to checkByteManrulesAndInJvmProxyAssertMechanisms() javadoc for more details on how to troubleshoot detected direct connections if needed.

OAuth unit test were removed since they were too fragile. @scottfrederick thanks for pointing that out in https://github.com/cloudfoundry/vcap-java-client/pull/88

Note: I had to submit a distinct branch because the https://github.com/Orange-OpenSource/vcap-java-client/tree/oauth-proxy-fix was polluted with too many transient commits, I'm therefore closing the original https://github.com/cloudfoundry/vcap-java-client/pull/69 (see discussions there) in favor of this PR for branch https://github.com/Orange-OpenSource/vcap-java-client/tree/proxy-tests Sorry for polluting GH PRs with this.