Jan and I have run across some annoying problems with test cases and test scoping within jetty recently and it has lead to some discussion on an idea that I have been kicking around for a while. The problem was that we have some useful test cases which are in the form of jetty server configurations in the jetty module and maybe a couple of other module, but since they are test source they are not readily available for consumption in other modules. We ran into this most recently working with eclipse which has no concept of test scoped source vs artifact scoped source so it was merrily working away while the cli maven build was failing because a particular test source was not available in another module.
I worked around that for a little bit by having the jetty module produce a test-component classified artifact which could be pulled in as a test scoped dependency where it was needed. I offered it out as one approach to solve this type of problem but it has the downside of being another bastard artifact being produced by the assembly plugin and being carried along for the ride with the normal jetty artifact. Its also yet another little bit of configuration in that test-component.xml assembly descriptor which would be nice to do without. It would also be possible to use the test-jar mojo on the maven-jar-plugin which would make another artifact again that has the classifier of ‘tests’ which is a bit more standard but is bringing along a whole lot of other classes that we neither want nor need to pass down the classpath to other test modules. I did just dispense with the test-component is favor of using the maven-jar-plugin so we don’t have that one little bit of extra configuration.
We kicked around the idea of just pulling some of these test servers and classes out of the test scope of the jetty module and simply putting them into a jetty-test artifact, but then we suffer the loss of unit test coverage for the jetty module, which is rather core to jetty and not particularly desirable.
Finally we got back around to the idea of making a jetty-server-test module that contained a variety of server configurations suitable for unit testing. It would be a little bit of work but since jetty is just so insanely easy to embed it would really be a pretty trivial job to make a jetty-server-test artifact that contained things like JettyWebappServer, JettySslServer, JettyWebServer all with simple default configurations and coming packaged with keystores, etc for common testing needs. Then it would be a matter of simply instantiating the server you want, maybe setting a path or three and using it in unit tests.
I guess my question now would be, ‘Is it worth it?’ and ‘Would it be generally useful to people or just us inside of jetty?’