You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Bob Arnott <bo...@aungate.com> on 2005/04/11 15:22:55 UTC

Testing a service that uses HTTPClient

Hello, what is the general consencus on how to test a service that uses
HttpClient...? For example, say I have a server that talks XML-RPC and
I've writen a client service that creates the XML-RPC request and sends
it via HttpClient.

I want to be able to unit test my service without having my server running.
If the HttpClient is an itegral part of hte service and not exposed to the
user of the service, how do I go about testing correct and incorrect
behaviour?

Do I mock the HttpClient or mock the server, or is there another way...?

Thanks,

-- 
Bob Arnott


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


Re: Testing a service that uses HTTPClient

Posted by Roland Weber <RO...@de.ibm.com>.
Hello Bob,

do you want to test the service, or the application using the service?
In the first case, I don't see how you could do that without the service
being available. In the second case, you are the only one qualified to
decide how your service can be mocked. Personally, I would try to
substitute the fake on the highest level possible, that is even before
the XML is created. If replay is an option, you could substitute the
RPC by returning an XML document from a file. Both would be above the
HttpClient level.
There is no general consencus on this in the HttpClient community, since
HttpClient is not actually concerned. Either you use it, or you don't ;-)
If you use it, you need an HTTP server to which the client can connect.

hope that helps,
  Roland





Bob Arnott <bo...@aungate.com> 
11.04.2005 15:22
Please respond to
"HttpClient User Discussion"


To
HttpClient User <ht...@jakarta.apache.org>
cc

Subject
Testing a service that uses HTTPClient






Hello, what is the general consencus on how to test a service that uses
HttpClient...? For example, say I have a server that talks XML-RPC and
I've writen a client service that creates the XML-RPC request and sends
it via HttpClient.

I want to be able to unit test my service without having my server 
running.
If the HttpClient is an itegral part of hte service and not exposed to the
user of the service, how do I go about testing correct and incorrect
behaviour?

Do I mock the HttpClient or mock the server, or is there another way...?

Thanks,

-- 
Bob Arnott


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