1. Configure HSQLDB data source and JNDI
In the snippet above I've used very useful XAPool project (to manipulate with JDBC data sources).
2. Configure Hibernate
In fact, there is a trick here. I'm using AspectJ to intercept in run-time (weaver) all calls to Hibernate's class method Configuration.configure(). There is an aspect's code.
3. Configure Web Services for Jetty
4. Run Jetty
5. Export database schema (Hibernate)
6. Prepare test dataset (DbUnit)
7. Run test(s) (Java or Groovy)
Let's summarize what we have at this point:
- Jetty is up and running
- Web Services are configured and deployed at: http://localhost:<actual port>/services/*
- Database schema is created and populated with test dataset
So we're ready to pull our web service methods. But for this purpose we need web service client. The first approach is to use raw SOAP requests. Second one is to generate web service (WSDL) stubs (Java). And last but not least is to use some scripting/dynamic language (like Groovy).
My choive was Groovy
- it's easy to consume web services with GroovyWS library
- it's easy to write test code
- it's excellent dynamic scripting language with seamless
Here is code sample:
Looks really great and very promising. The only problem I've encountered that GroovyWS is started recently and is "green". Unfortunately, I've failed to test most web service methods with complex in/out parameters and return types (so I was reluctant to use WSDL generated stubs).
That's it. Our test sandbox is ready for use!