Thursday, October 15, 2009

Spring, Web Services and Functional Testing

Functional tests are particularly interesting for web services as they allow to test a fully integrated web service stack from the outside, thus giving the same point of view of the clients. In a sense, what really matters in a web service is its interface rather than its implementation, and functional testing allows to focus on that.

In this post I'd like to present an automated way to implement functional tests for your web services using Spring. The approach relies mainly on Spring TestContext Framework, an embedded Jetty instance and Spring Web Services (you saw it coming, didn't you?).
The outline is as follows: functional tests are implemented using Spring TestContext and JUnit 4 (or any of the other supported testing frameworks). In the ApplicationContext that Spring TestContext creates for the test, we include an embedded Jetty instance that loads and runs the target web service application. The actual test consists simply of invoking that web service through a WebServiceTemplate (Spring-WS) and validating the response with XMLUnit. Finally, we run our tests using Maven (mvn test, simply).

Friday, October 9, 2009

WS-Security Support in Spring-WS Grails Plugin

I've been busy lately working on adding WS-Security support to the Spring-WS Grails plugin and I'm pleased to tell you that we're just about to release a new version containing that work. When I first learned about the plugin from Russ Miles, I was pretty excited I must say; the perspective of bringing together Grails and Spring-WS opens up a whole new world of possibilities. The goal of the Spring-WS plugin is to make developing contract-first web services easy and productive, and to that end, we wanted to provide an easy way to add security to your endpoints, based on a convention-over-configuration approach and on other niceties that Groovy offers.