hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: HttpCore to mock remote servers in unit tests?
Date Fri, 06 Apr 2007 18:02:55 GMT
On Fri, 2007-04-06 at 18:26 +0200, Stefan Hübner wrote:
> Thanks for clarifying that to me, Roland!
> 
> Tomcat on the other hand is way too oversized, since I just want to
> start a small service with a few lines of code, inject a
> request/response-handler (e.g. based on JMock) run a test and shut
> that thing down again. Thought, HttpCore could provide me with the
> service part of it, but ok, that's what prototypes are good for,
> right?
> 
> Regards,
> Stefan
> 

Stefan and all,

HttpCore is not meant to be a replacement or a competitor to Servlet
API. It is a merely bunch of low level components one can use to put
together a custom client, proxy or server side HTTP service. If all you
want is a lightweight Servlet container Jetty indeed appears to be the
best choice. At the same one can easily emulate Servlet API on top of
HttpCore (see to SimpleHttpServer used in Axis2 [1] for example)   

One may still consider using HttpCore 
(1) to be able to use the same API and the same components on the client
and the server side  
(2) to have a greater control over HTTP protocol than it is possible
with Servlet API
(3) to emulate various HTTP spec non-compliant behaviors 
(4) to take a full advantage of NIO buffering primitives

Hope this helps

Oleg

[1]
http://svn.apache.org/repos/asf/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/http/server/



> 2007/4/6, Roland Weber <ossfwot@dubioso.net>:
> > Hi Stefan,
> >
> > > So I thought, I could set up a small server based on
> > > HttpCore-components.
> >
> > There's one in the test code for HttpCore, and a slightly different
> > one in the test code for HttpClient (though the latter still lacks
> > some pieces for expect-continue handling). Both are based on the
> > HttpService class and the ElementalHttpServer example.
> >
> > > I progressed up to the point where I actually
> > > were about to check parameters of the requests, the mocked server
> > > received. There I stuck since HttpCore's HttpRequest-Interface is
> > > lacking any higher level API to read it's parameters.
> > >
> > > Maybe, that interface is just not intended to serve use cases like the
> > > one described above?
> >
> > Exactly. "Core" is not a higher level API. See our project charter,
> > section "Project Scope", item 2:
> >
> >    Jakarta HttpComponents will provide ONLY a toolset of low level
> >    generic transport APIs. In particular, server side application
> >    layer APIs WILL NOT be developed.
> >    http://jakarta.apache.org/httpcomponents/charter.html
> >
> > Please use the Servlet API for that purpose, for example in Tomcat:
> >         http://tomcat.apache.org/
> > Our project charter was specifically drafted to avoid scope clashes
> > with other Apache projects.
> >
> > cheers,
> >   Roland
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message