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 2011/06/28 20:00:51 UTC
svn commit: r1140763 -
/tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
Author: markt
Date: Tue Jun 28 18:00:50 2011
New Revision: 1140763
URL: http://svn.apache.org/viewvc?rev=1140763&view=rev
Log:
Add a test case for https://issues.apache.org/bugzilla/show_bug.cgi?id=51445
Modified:
tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
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=1140763&r1=1140762&r2=1140763&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java Tue Jun 28 18:00:50 2011
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -326,4 +327,49 @@ public class TestStandardWrapper extends
r.addMapping("/");
}
}
+
+
+ public void testBug51445() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ // Must have a real docBase - just use temp
+ StandardContext ctx = (StandardContext)
+ tomcat.addContext("", System.getProperty("java.io.tmpdir"));
+
+ Tomcat.addServlet(ctx, "Bug51445", new Bug51445Servlet());
+ ctx.addServletMapping("/", "Bug51445");
+
+ tomcat.start();
+
+ ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
+
+ assertEquals("10", res.toString());
+ }
+
+
+ /**
+ * SingleThreadModel servlet that sets a value in the init() method.
+ */
+ @SuppressWarnings("deprecation")
+ private static class Bug51445Servlet extends HttpServlet
+ implements javax.servlet.SingleThreadModel {
+
+ private static final long serialVersionUID = 1L;
+
+ private int data = 0;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ resp.setContentType("text/plain");
+ resp.getWriter().print(data);
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+ data = 10;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org