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 2013/07/11 16:38:56 UTC

svn commit: r1502237 - /tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestStandardContextResources.java

Author: markt
Date: Thu Jul 11 14:38:55 2013
New Revision: 1502237

URL: http://svn.apache.org/r1502237
Log:
Confirm proxy resources are not cached when context has caching disabled.

Modified:
    tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestStandardContextResources.java

Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestStandardContextResources.java?rev=1502237&r1=1502236&r2=1502237&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestStandardContextResources.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestStandardContextResources.java Thu Jul 11 14:38:55 2013
@@ -25,6 +25,7 @@ import java.net.URL;
 import java.util.Arrays;
 import java.util.List;
 
+import javax.naming.directory.DirContext;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -34,6 +35,7 @@ import javax.servlet.http.HttpServletRes
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import org.junit.Assert;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
@@ -45,6 +47,7 @@ import org.apache.catalina.startup.Const
 import org.apache.catalina.startup.ContextConfig;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.naming.resources.ProxyDirContext;
 import org.apache.tomcat.util.buf.ByteChunk;
 
 public class TestStandardContextResources extends TomcatBaseTest {
@@ -225,6 +228,36 @@ public class TestStandardContextResource
                 "<p>resourceE.jsp in the web application</p>");
     }
 
+
+    @Test
+    public void testResourceCaching() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+
+        File appDir = new File("test/webapp-3.0-fragments");
+        // app dir is relative to server home
+        StandardContext ctx = (StandardContext) tomcat.addWebapp(
+                null, "/test", appDir.getAbsolutePath());
+        ctx.setCachingAllowed(false);
+
+        tomcat.start();
+
+        DirContext resources = ctx.getResources();
+
+        Assert.assertTrue(resources instanceof ProxyDirContext);
+
+        ProxyDirContext proxyResources = (ProxyDirContext) resources;
+
+        // Caching should be disabled
+        Assert.assertNull(proxyResources.getCache());
+
+        ctx.stop();
+        ctx.start();
+
+        // Caching should still be disabled
+        Assert.assertNull(proxyResources.getCache());
+    }
+
+
     /**
      * A servlet that prints the requested resource. The path to the requested
      * resource is passed as a parameter, <code>path</code>.



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