Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D919566D8 for ; Fri, 24 Jun 2011 12:53:59 +0000 (UTC) Received: (qmail 21196 invoked by uid 500); 24 Jun 2011 12:53:56 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 21033 invoked by uid 500); 24 Jun 2011 12:53:56 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 21024 invoked by uid 99); 24 Jun 2011 12:53:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Jun 2011 12:53:56 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of catchwa@gmail.com designates 74.125.82.173 as permitted sender) Received: from [74.125.82.173] (HELO mail-wy0-f173.google.com) (74.125.82.173) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Jun 2011 12:53:48 +0000 Received: by wyf28 with SMTP id 28so2476214wyf.18 for ; Fri, 24 Jun 2011 05:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=+/L5SiXCODhLc023Zn5fKpu6lm51luXov5IHIBdid34=; b=O9CZIXHskJJo250hY1do1WueVn0uLxMm2SWBbLe1KYFbyKUon5kfSuY6DujOJKuviI BitTehspMfk9xNIjonI+zhPDoCvunr/THVPp8m67R9g+rN6AVbIDblGBVr9dWO4JmI9t sUpO4udeij4WYnY0E+F4sVNZw2cKkz/pY7fSU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=gNL7vfVNo2z5Vn8ggULllw+5oXHnFiUCtrE5CUAqW+DsUJ2gUyjwDicVPWtyru2xxV dWapF9RzSfQEC4WLCs8qT2lpflsmvGu4RwRRoUjQLuBpKrtTxXrHpFqmMnhOKsM91CME pAAVIkkkjrSQasBTmsUHwzc7udaEl2fZX7/fk= Received: by 10.227.198.197 with SMTP id ep5mr3127952wbb.33.1308920008077; Fri, 24 Jun 2011 05:53:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.135.146 with HTTP; Fri, 24 Jun 2011 05:53:08 -0700 (PDT) From: Andrew Brock Date: Fri, 24 Jun 2011 22:23:08 +0930 Message-ID: Subject: Programatically setting web.xml in embedded Tomcat To: users@tomcat.apache.org Content-Type: multipart/alternative; boundary=0015174760ea1ef33004a674b02e X-Virus-Checked: Checked by ClamAV on apache.org --0015174760ea1ef33004a674b02e Content-Type: text/plain; charset=ISO-8859-1 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 --0015174760ea1ef33004a674b02e--