Reinhard Pötz wrote:
Luca Morandini wrote:
  
Kamal wrote:
    
Hi,
I have been thinking about testing REST based web services of late. It
occurred to me that these web services are very difficult to test 
      
Really ? My impression is the opposite: a REST-style web service should
be usable by humans and machines alike, which makes them easier to test
 (easier then the RPC-style web services, anyway).
    

Same impression here.

The Cocoon 3 integration tests should give you some hints how the
testing can be done via HTTP. See the cocoon-sample and
cocoon-sample-webapp module.
  
OK, I should clarify. The problem with REST style web services are the same for non-REST style web services. My above statement was probably not the best one. In many cases, you do not own the service. For example, it may be impossible to force certain error conditions. Even for systems that are in your control,  may not be easily mocked. Here is a (fictional) use case. I have a weather forcast interface that relies specifies dates. That is, you specify a date, then you get returned the weather for that day. I could setup requests for a particular date, but those dates may become irrelevant in a couple of months (because the interface only supports forecasting). To make things more difficult, the weather service may return your date in the response. Now, if you could take the request, work out what date it selected and then create a mock response based on those dates, you can unit test your interface.

I realise that Cocoon 2.1 and 2.2 may support this, but I think the syntax described is very, well, cocoon-y. It may be great for those who have been working with Cocoon for years, but it isn't user friendly for the intended purpose. That is why I was thinking about some other process we could use.

Now, all that said, after some more Googling, I did find the following:

http://synapse.apache.org/index.html

So maybe what I want to do is look at that (though the documentation seems a little confusing to me, but only because my understanding of SOAP based interfaces is pretty poor).

  
against. I was thinking that maybe there is some funky way of mocking
a web service, using XPath and regexes to match on the requst, and use
a templating language to generate the response (based on variables
generated from the XPath and regexes). I was thinking maybe Cocoon 3.0
might help me here.
      
I think you could do the same with 2.1 or 2.2 as well.
    

Yes, or you can use the Cocoon 3 REST module which provides a JSR311
inspired controller implementation. Also see
http://cocoon.apache.org/3.0/features.html for a basic example.
  
OK, that is nicer. I may look at that.
Regarding your testing question above, those REST controller classes can
be unit tested easily.

  


-- 
Kamal Bhatt
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to