On 1/31/09, Oleg Kalnichevski <[email protected]> wrote:
> ying lcs wrote:
> > I have the following code which uses HttpClient to do a post request.
> > Can you please tell tell me what is a good way to test it? Can I
> > create a mock http server object for the test to run against?
> >
> > HttpClient cli = getClient();
> > HttpPost method;
> >
> > method = new HttpPost(url);
> > HttpResponse resp = null;
> > resp = cli.execute(method);
> >
> > Thank you.
> >
> >
>
> Yes, you can.
>
> There is a mock HTTP server implementation for HttpClient 3.x we use to test
> more complex HTTP scenarios:
>
> http://svn.apache.org/repos/asf/httpcomponents/oac.hc3x/trunk/src/test/org/apache/commons/httpclient/server/
>
> However, I would _strongly_ recommend using the testing framework of
> HttpClient 4.0 instead of the old 3.x stuff:
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/
>
> It is actually a complete, HTTP/1.1 compliant, embeddable HTTP server based
> on HttpCore, the same component stack used internally by HttpClient 4.0.
>

Thank you.  If I use the mock HTTP server from HttpClient4.0 does that
mean I have to upgrade my Http client to 4.0 version? Can I just pull
the 'localserver' code from HttpClient4.0 and use that against my
current version of HttpClient?

Moreover, what is the dependencies of the 'localserver' code of HttpClient 4.0?

Thank you.


> Hope this helps.
>
> Oleg
>
>
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [email protected]
> > For additional commands, e-mail:
> [email protected]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [email protected]
> For additional commands, e-mail:
> [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to