You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/11/03 12:42:23 UTC

svn commit: r1636325 - in /tomcat/trunk/test/org/apache/catalina/core: TestStandardContext.java TestStandardWrapper.java

Author: markt
Date: Mon Nov  3 11:42:22 2014
New Revision: 1636325

URL: http://svn.apache.org/r1636325
Log:
Reduce boilerplate code.

Modified:
    tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java
    tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java

Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java?rev=1636325&r1=1636324&r2=1636325&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java Mon Nov  3 11:42:22 2014
@@ -292,50 +292,45 @@ public class TestStandardContext extends
         // called only once, even if is selected by several mapping
         // url-patterns or by both a url-pattern and a servlet-name.
 
-        // Set up a container
-        Tomcat tomcat = getTomcatInstance();
-
-        File root = new File("test/webapp");
-        tomcat.addWebapp("", root.getAbsolutePath());
+        getTomcatInstanceTestWebapp(false, true);
 
-        tomcat.start();
         ByteChunk result = new ByteChunk();
 
         // Check filter and servlet aren't called
         int rc = getUrl("http://localhost:" + getPort() +
-                "/bug49922/foo", result, null);
+                "/test/bug49922/foo", result, null);
         assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
         assertTrue(result.getLength() > 0);
 
         // Check extension mapping works
-        result = getUrl("http://localhost:" + getPort() + "/foo.do");
+        result = getUrl("http://localhost:" + getPort() + "/test/foo.do");
         assertEquals("FilterServlet", result.toString());
 
         // Check path mapping works
-        result = getUrl("http://localhost:" + getPort() + "/bug49922/servlet");
+        result = getUrl("http://localhost:" + getPort() + "/test/bug49922/servlet");
         assertEquals("FilterServlet", result.toString());
 
         // Check servlet name mapping works
-        result = getUrl("http://localhost:" + getPort() + "/foo.od");
+        result = getUrl("http://localhost:" + getPort() + "/test/foo.od");
         assertEquals("FilterServlet", result.toString());
 
         // Check filter is only called once
         result = getUrl("http://localhost:" + getPort() +
-                "/bug49922/servlet/foo.do");
+                "/test/bug49922/servlet/foo.do");
         assertEquals("FilterServlet", result.toString());
         result = getUrl("http://localhost:" + getPort() +
-                "/bug49922/servlet/foo.od");
+                "/test/bug49922/servlet/foo.od");
         assertEquals("FilterServlet", result.toString());
 
         // Check dispatcher mapping
         result = getUrl("http://localhost:" + getPort() +
-                "/bug49922/target");
+                "/test/bug49922/target");
         assertEquals("Target", result.toString());
         result = getUrl("http://localhost:" + getPort() +
-                "/bug49922/forward");
+                "/test/bug49922/forward");
         assertEquals("FilterTarget", result.toString());
         result = getUrl("http://localhost:" + getPort() +
-                "/bug49922/include");
+                "/test/bug49922/include");
         assertEquals("IncludeFilterTarget", result.toString());
     }
 
@@ -934,16 +929,9 @@ public class TestStandardContext extends
 
     @Test
     public void testBug56085() throws Exception {
-        // Set up a container
-        Tomcat tomcat = getTomcatInstance();
-
-        File docBase = new File("test/webapp");
-        Context ctx = tomcat.addContext("", docBase.getAbsolutePath());
-
-        // Start the context
-        tomcat.start();
+        Tomcat tomcat = getTomcatInstanceTestWebapp(false, true);
 
-        String realPath = ctx.getRealPath("\\");
+        String realPath = ((Context) tomcat.getHost().findChildren()[0]).getRealPath("\\");
 
         Assert.assertNull(realPath);
     }

Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java?rev=1636325&r1=1636324&r2=1636325&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java Mon Nov  3 11:42:22 2014
@@ -169,19 +169,12 @@ public class TestStandardWrapper extends
 
     @Test
     public void testSecurityAnnotationsMetaDataPriority() throws Exception {
-
-        // Setup Tomcat instance
-        Tomcat tomcat = getTomcatInstance();
-
-        File appDir = new File("test/webapp");
-        tomcat.addWebapp(null, "", appDir.getAbsolutePath());
-
-        tomcat.start();
+        getTomcatInstanceTestWebapp(false, true);
 
         ByteChunk bc = new ByteChunk();
         int rc;
         rc = getUrl("http://localhost:" + getPort() +
-                "/testStandardWrapper/securityAnnotationsMetaDataPriority",
+                "/test/testStandardWrapper/securityAnnotationsMetaDataPriority",
                 bc, null, null);
 
         assertEquals("OK", bc.toString());



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org