hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thom Nichols <tmnich...@gmail.com>
Subject Re: Fluent interface to httpclient in Stanbol, should that move here?
Date Wed, 23 Feb 2011 21:10:00 GMT
FWIW, the HTTPBuilder project also aims to "put a pretty face" on
HttpClient.  However HTTPBuilder is written for Groovy, so...  You have to
write Groovy to use it :)

http://groovy.codehaus.org/modules/http-builder

-Thom


On Wed, Feb 23, 2011 at 4:05 AM, Bertrand Delacretaz <bdelacretaz@apache.org
> wrote:

> Hi,
>
> (just subscribed here - I'm a committer on Stanbol and Sling, using
> httpclient in both for integration testing)
>
> Longish message ahead, here's the short version: I'm currently working
> on http-based integration test tools (SLING-1981, STANBOL-19), created
> a few utility classes that provide a simplified "fluent" interface [1]
> to httpclient, and I was wondering if it would make sense to move that
> code to this project as an optional simplified API.
>
> Here's an example that runs a request against a running http server.
> executor is a RequestExecutor that's configured with the server's base
> URL.
>
> executor.execute(
>  builder.buildGetRequest("/foo", "queryParam1", "value1")
>  .withBasicCredentials("me", "pwd")
>  .withRedirects(true)
>  .withHeader("Accept","text/rdf+nt")
> )
>
> Then, as my goal is testing, you can run some assertions on the executor:
>
> executor
>  .assertStatus(200)
>  .assertContentType("text/rdf+nt")
>  .assertContentRegexp(
>    "foo.*bar",
>    "some other [rR]egexp"
>  )
>
> etc...you could also have a different executor that just provides
> access to the response content, headers etc. if the goal is not
> testing.
>
> Would it make sense to have such an API as an optional component in
> this project? That would probably not provide access to the whole
> httpclient feature set, but rather provide a very simple way of
> executing http requests for the most common use cases.
>
> If yes I'm happy to contribute that code here, assuming the stanbol
> folks (where this code currently resides [2]) agree to let it go. I'll
> be using that code in various testing scenarios in Stanbol, Sling and
> $dayjob, so planning to keep maintaining it, it's not just a fun
> short-term experiment.
>
> Let me know what you think.
>
> -Bertrand
>
> [1] http://en.wikipedia.org/wiki/Fluent_interface
> [2]
> http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/testing/http
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message