Update test to use a resource that does exist.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 21 Sep 2009 11:06:52 +0000 (11:06 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 21 Sep 2009 11:06:52 +0000 (11:06 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@817207 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/catalina/startup/TestTomcat.java

index 8420569..9bae9d4 100644 (file)
@@ -184,19 +184,20 @@ public class TestTomcat extends TestTomcatBase {
     public void testGetResource() throws Exception {
         Tomcat tomcat = getTomcatInstance();
         
-        // Must have a real docBase - just use temp
-        StandardContext ctx = 
-            tomcat.addContext("/", System.getProperty("java.io.tmpdir"));
-        // You can customize the context by calling 
-        // its API
+        String contextPath = "/examples";
         
-        Tomcat.addServlet(ctx, "myServlet", new GetResource());
-        ctx.addServletMapping("/", "myServlet");
+        File appDir = new File("output/build/webapps" + contextPath);
+        // app dir is relative to server home
+        StandardContext ctx =
+            tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
+        
+        Tomcat.addServlet(ctx, "testGetResource", new GetResource());
+        ctx.addServletMapping("/testGetResource", "testGetResource");
         
         tomcat.start();
         
-        int rc =getUrl("http://localhost:" + getPort() + "/", new ByteChunk(),
-                null);
+        int rc =getUrl("http://localhost:" + getPort() + contextPath +
+                "/testGetResource", new ByteChunk(), null);
         assertEquals(HttpServletResponse.SC_OK, rc);
     }