With the recent release of Turmeric SOA 1.1.0, I thought it was a good time to revist some of the tutorials around Turmeric. While working on updating some these, I realised we can make testing of the web services a lot more painless. Enter the jetty-maven-plugin.
We will use the jetty:run-war plugin. To get started create a maven war project. You can use the maven webapp archetype to create the project. Once that is completed, you will need to add a dependency to your Turmeric SOA service implementation project and add a plugin entry to specify the version of jetty to use. You will end up with something like this:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example.test</groupId> <artifactId>test-hello-world</artifactId> <version>1.0.0-SNAPSHOT</version> <name>Test Hello World Web App</name> <packaging>war</packaging> <dependencies> <dependency> <groupId>org.ebayopensource.turmeric.impl</groupId> <artifactId>DemoHelloWorldV1</artifactId> <version>1.0.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>7.5.4.v20111024</version> </plugin> </plugins> </build> </project>
To test and deploy your web service, you just need to type run: mvn jetty:run-war
You can test that the service is deployed by point your favorite web browser to
Remember to replace the above with the name of your service.
I typically use this for some quick testing of changes done to a service, or items that need some sort of integration testing. You could also use this to help with some automated testing, but in those cases I recommend writing your test to extend from the Turmeric SOA jetty-common-tests framework. This framework provides an embedded instance of jetty that can be used in integration tests.