Repository: incubator-brooklyn Updated Branches: refs/heads/master 125f01e00 -> 1e04ec160
bump httpclient version replace LocalTestServer usage with HttpServer as per http://mail-archives.apache.org/mod_mbox/hc-httpclient-users/201504.mbox/%[email protected]%3E Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/3fb4d9ae Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/3fb4d9ae Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/3fb4d9ae Branch: refs/heads/master Commit: 3fb4d9ae89894f15eab0f9df867f8f2e67e2b6bc Parents: 125f01e Author: Andrea Turli <[email protected]> Authored: Wed May 13 13:44:01 2015 +0200 Committer: Andrea Turli <[email protected]> Committed: Wed May 13 13:56:40 2015 +0200 ---------------------------------------------------------------------- .../brooklyn/util/ResourceUtilsHttpTest.java | 44 +++++++++----------- pom.xml | 2 +- 2 files changed, 21 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3fb4d9ae/core/src/test/java/brooklyn/util/ResourceUtilsHttpTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/util/ResourceUtilsHttpTest.java b/core/src/test/java/brooklyn/util/ResourceUtilsHttpTest.java index 56d8166..f47a6fa 100644 --- a/core/src/test/java/brooklyn/util/ResourceUtilsHttpTest.java +++ b/core/src/test/java/brooklyn/util/ResourceUtilsHttpTest.java @@ -20,11 +20,9 @@ package brooklyn.util; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; import java.io.IOException; import java.io.InputStream; -import java.net.InetSocketAddress; import org.apache.http.Header; import org.apache.http.HttpException; @@ -32,7 +30,8 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.entity.StringEntity; -import org.apache.http.localserver.LocalTestServer; +import org.apache.http.impl.bootstrap.HttpServer; +import org.apache.http.impl.bootstrap.ServerBootstrap; import org.apache.http.localserver.RequestBasicAuth; import org.apache.http.localserver.ResponseBasicUnauthorized; import org.apache.http.message.BasicHeader; @@ -51,7 +50,7 @@ import brooklyn.util.text.Strings; public class ResourceUtilsHttpTest { private ResourceUtils utils; - private LocalTestServer server; + private HttpServer server; private String baseUrl; @BeforeClass(alwaysRun=true) @@ -65,21 +64,22 @@ public class ResourceUtilsHttpTest { httpProcessor.addInterceptor(new RequestBasicAuth()); httpProcessor.addInterceptor(new ResponseBasicUnauthorized()); - server = new LocalTestServer(httpProcessor, null); - server.register("/simple", new SimpleResponseHandler("OK")); - server.register("/empty", new SimpleResponseHandler(HttpStatus.SC_NO_CONTENT, "")); - server.register("/missing", new SimpleResponseHandler(HttpStatus.SC_NOT_FOUND, "Missing")); - server.register("/redirect", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "/simple"))); - server.register("/cycle", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "/cycle"))); - server.register("/secure", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "https://0.0.0.0/"))); - server.register("/auth", new AuthHandler("test", "test", "OK")); - server.register("/auth_escape", new AuthHandler("test@me:/", "test", "OK")); - server.register("/auth_escape2", new AuthHandler("test@me:test", "", "OK")); - server.register("/no_credentials", new CheckNoCredentials()); + server = ServerBootstrap.bootstrap() + .setListenerPort(8080) + .setHttpProcessor(httpProcessor) + .registerHandler("/simple", new SimpleResponseHandler("OK")) + .registerHandler("/empty", new SimpleResponseHandler(HttpStatus.SC_NO_CONTENT, "")) + .registerHandler("/missing", new SimpleResponseHandler(HttpStatus.SC_NOT_FOUND, "Missing")) + .registerHandler("/redirect", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "/simple"))) + .registerHandler("/cycle", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "/cycle"))) + .registerHandler("/secure", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "https://0.0.0.0/"))) + .registerHandler("/auth", new AuthHandler("test", "test", "OK")) + .registerHandler("/auth_escape", new AuthHandler("test@me:/", "test", "OK")) + .registerHandler("/auth_escape2", new AuthHandler("test@me:test", "", "OK")) + .registerHandler("/no_credentials", new CheckNoCredentials()) + .create(); server.start(); - - InetSocketAddress addr = server.getServiceAddress(); - baseUrl = "http://" + addr.getHostName() + ":" + addr.getPort(); + baseUrl = "http://" + server.getInetAddress().getHostName() + ":" + server.getLocalPort(); } @AfterClass(alwaysRun=true) @@ -149,13 +149,9 @@ public class ResourceUtilsHttpTest { utils.getResourceFromUrl(baseUrl + "/missing"); } - @Test + @Test(expectedExceptions = RuntimeException.class) public void testFollowsProtoChange() throws Exception { - try { - utils.getResourceFromUrl(baseUrl + "/secure"); - } catch (Exception e) { - assertTrue(e.getMessage().contains("Connection to https://0.0.0.0 refused")); - } + utils.getResourceFromUrl(baseUrl + "/secure"); } // See https://github.com/brooklyncentral/brooklyn/issues/1338 http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3fb4d9ae/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index b4f2e3e..62dc798 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,7 @@ <jackson.version>1.9.13</jackson.version> <!-- codehaus jackson, used by brooklyn rest server --> <fasterxml.jackson.version>2.4.2</fasterxml.jackson.version> <!-- more recent jackson, but not compatible with old annotations! --> <jersey.version>1.18.1</jersey.version> - <httpclient.version>4.2.5</httpclient.version> + <httpclient.version>4.4.1</httpclient.version> <commons-lang3.version>3.1</commons-lang3.version> <groovy.version>2.3.4</groovy.version> <!-- Version supported by https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-2.9.0-Release-Notes --> <jsr305.version>2.0.1</jsr305.version>
