tags:

views:

992

answers:

2

The jetty servlet container is quick and light enough to run in unit tests (indeed I do to serve up files).

It is possible to install actual servlets into it, programmatically (say in a test) and have it run them?

+4  A: 

Yes. We do this on a regular basis with a number of tools. The simpest is probably HTTP-unit. When we deploy in jetty, we usually deploy larger parts of the application and run Selenium. HttpUnit is the simplest, but at some point your application complexity may warrant a more complete deployment. See the documentation section on embedding jetty

krosenvold
Hey wow thanks - that was exactly what I was looking for - didn't really know what to search for (tried a few things - never thought to search for "embedded").
Michael Neale
+1  A: 

Why not use any HttpUnit, HTMLUnit etc.. Create an ANT script to do whatever is needed to run the test.

Adeel Ansari
Oh I have things like that - I just would like to wire it all up in code - no external scripts to run - less likely to fail (as long as the port is free).
Michael Neale