Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!news.glorb.com!postnews.google.com!c9g2000yqp.googlegroups.com!not-for-mail From: Pete Newsgroups: comp.lang.java.programmer,comp.lang.java.help,comp.client-server Subject: Re: Testing the Post request Date: Sat, 18 Jun 2011 08:54:20 -0700 (PDT) Organization: http://groups.google.com Lines: 55 Message-ID: <3ea90246-d6b2-4ce2-9a20-d3273d35530a@c9g2000yqp.googlegroups.com> References: NNTP-Posting-Host: 90.202.43.193 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1308412553 2668 127.0.0.1 (18 Jun 2011 15:55:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 18 Jun 2011 15:55:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c9g2000yqp.googlegroups.com; posting-host=90.202.43.193; posting-account=WJOPywoAAACR5fu5y-AcGCF6AHoK1Cxw User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.30729; .NET4.0C; .NET CLR 3.0.30729),gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5360 comp.lang.java.help:780 comp.client-server:4 On Jun 18, 3:42=A0pm, Stanimir Stamenkov wrote: > Sat, 18 Jun 2011 04:41:54 -0700 (PDT), /Pete/: > > > Below is a bit of code that I intend to use to perform a http "Post" > > request to an another application - which is still under development. > > I would like to verify the implemention of this method ie it will > > perform a http POST request with the xml content to the specified URL. > > I want to avoid mocking the HttpClient class. I would like to > > effectively see this method perform the a actions and and some stub > > application receive the request ( get I presume). Any help, with > > example code pls, would be very much appreciated. > > While I don't see anything wrong with mocking the HttpClient to > perform a unit test of you code (i.e. to verify it interacts with > the HttpClient in the intended way), it seems you want an > integration test performing real HTTP communication. =A0For this > you'll need to create (if there's not one already) a test service > receiving and handling the requests. =A0I can't give you specific > example code to build the test service but I guess you could create > it as simple servlet application. > > I don't know if creating the test service would be any easier than > creating unit tests, mocking the HttpClient (using Mockito [1] I > have experience with, is quite easy), but in the end you might want > having both type of tests. =A0The integration test however would > require specific test service environment setup and running which is > usually better suited for running by a continuous integration > system, while the unit tests could be run by anyone as part of the > standard build. > > -- > Stanimir Hi Stanimir, Thank you for your response. My main concern for not mocking the HTTPClient is really that it is NOT going to give me the confidence I would like of my implementation. If I had missed to configure something eg "String url =3D "URL";", when the function is called nothing would received at the other end - mocking the HTTPClient is not going to highlight this until I get to really integrate with the other application. However,if I did something like your other suggestion - "a test service receiving and handling the requests" - this would highlight any issues with my implementation in advance. This is subject matter is relatively new to me - even my logic of my function, I got from the internate. So I wonder if you have any suggestions how I can create a SIMPLE "a test service receiving and handling the requests" to test my function. Again example would very much be appreciated. Thank You again. Pete