Groups | Search | Server Info | Login | Register


Groups > comp.client-server > #3

Re: Testing the Post request

From Stanimir Stamenkov <s7an10@netscape.net>
Newsgroups comp.lang.java.programmer, comp.lang.java.help, comp.client-server
Subject Re: Testing the Post request
Date 2011-06-18 17:42 +0300
Organization A noiseless patient Spider
Message-ID <itidgd$l0h$1@dont-email.me> (permalink)
References <df9cb1d7-c953-49ed-851b-c309a034a3a9@x3g2000yqj.googlegroups.com>

Cross-posted to 3 groups.

Show all headers | View raw


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.  For this 
you'll need to create (if there's not one already) a test service 
receiving and handling the requests.  I 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.  The 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

Back to comp.client-server | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Testing the Post request Pete <vw_bora@sky.com> - 2011-06-18 04:41 -0700
  Re: Testing the Post request Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-18 17:42 +0300
    Re: Testing the Post request Pete <vw_bora@sky.com> - 2011-06-18 08:54 -0700
      Re: Testing the Post request Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-18 19:33 +0300
        Re: Testing the Post request Pete <vw_bora@sky.com> - 2011-06-18 10:40 -0700
          Re: Testing the Post request Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-18 23:36 +0300
            Re: Testing the Post request Pete <vw_bora@sky.com> - 2011-06-18 15:33 -0700
              Re: Testing the Post request Abu Yahya <abu_yahya@invalid.com> - 2011-06-19 23:10 +0530
      Re: Testing the Post request markspace <-@.> - 2011-06-18 11:11 -0700

csiph-web