diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java new file mode 100644 index 00000000000..2397faec6ca --- /dev/null +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java @@ -0,0 +1,65 @@ +// +// ======================================================================== +// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.test.jsp; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class FakeJspServlet extends HttpServlet +{ + + /* ------------------------------------------------------------ */ + /* + * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException + { + String path = req.getServletPath(); + URL url =getServletContext().getResource(path); + if (url==null) + { + response.sendError(404); + return; + } + + try + { + File file=new File(url.toURI()); + if (file.exists()) + { + response.sendError(200,"fake JSP response"); + return; + } + } + catch (Exception e) + { + e.printStackTrace(); + } + + response.sendError(404); + } + +} diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java index 6dc439d017f..019a3c70030 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java @@ -34,6 +34,7 @@ import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.servlet.DefaultServlet; +import org.eclipse.jetty.servlet.NoJspServlet; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; @@ -106,7 +107,8 @@ public class JspAndDefaultWithAliasesTest defaultServHolder.setInitParameter("aliases","true"); // important! must be TRUE // add jsp - ServletHolder jsp = context.addServlet(JspServlet.class,"*.jsp"); + ServletHolder jsp = new ServletHolder(new FakeJspServlet()); + context.addServlet(jsp,"*.jsp"); jsp.setInitParameter("classpath",context.getClassPath()); // add context @@ -157,6 +159,9 @@ public class JspAndDefaultWithAliasesTest return; } + if (conn.getResponseCode()!=404) + System.err.println(conn.getResponseMessage()); + // Of other possible paths, only 404 Not Found is expected Assert.assertThat("Response Code",conn.getResponseCode(),is(404)); } diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java index 8ff51609240..3a82d88b4c5 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java @@ -106,7 +106,8 @@ public class JspAndDefaultWithoutAliasesTest defaultServHolder.setInitParameter("aliases","false"); // important! must be FALSE // add jsp - ServletHolder jsp = context.addServlet(JspServlet.class,"*.jsp"); + ServletHolder jsp = new ServletHolder(new FakeJspServlet()); + context.addServlet(jsp,"*.jsp"); jsp.setInitParameter("classpath",context.getClassPath()); // add context