Hi all,

I'm currently using Tomcat's embedded feature for unit testing of a web
service. This web service displays different behaviour depending on the
contents of the web.xml file. I therefore want to exercise different web.xml
configurations in my unit tests. Currently the setup code I'm using is as
follows:

Tomcat tomcat = new Tomcat();
tomcat.setBaseDir(catalinaHome);
tomcat.setPort(port);
tomcat.addWebapp("/ServiceTest", System.getProperty("user.dir") +
"build/web");
tomcat.setHostname("localhost");
tomcat.enableNaming();
tomcat.start();

As you can see, the webapp is currently sourced from the NetBeans build
directory.

What is the best way for me to test different web.xml files? Is there a way
I can set the webapp to the same directory as I am currently, but point at a
web.xml file that is somewhere else?

(I'm not too keen on altering the build/web directory just in case the test
fails and ends up breaking the real web.xml file.)

My fall-back position is to have my test cases make a temporary copy of the
build/web directory and then override the web.xml file with the one I want
to use in that specific test case, but I was wondering if there is a more
elegant solution.



My environment is:

Tomcat 7.0.11
NetBeans 7.0
Windows XP


Thanks,

Andrew

Reply via email to