String path = request.getUrl().getPath();
WebApplicationDeploymentContext deployment = this.getContext(path);
if (deployment == null)
throw new MockBrowserException(request, "No context could be found to handle request", null);
MockHttpServletContext ctx = (MockHttpServletContext) deployment.getServletContext();
path = path.length() == ctx.getContextPath().length() ? "/" : path.substring(ctx.getContextPath().length());
if (!path.startsWith("/")) path = "/" + path;
Thread.currentThread().setContextClassLoader(ctx.getParentClassLoader());
MockServletSetup servlet = ctx.findServlet(path);
List<Filter> filters = ctx.getFilters(servlet, path);
WebApplicationServletContext wrapper = new WebApplicationServletContext(ctx, ctx.application);
MockHttpServletRequest httpRequest = new MockHttpServletRequest(wrapper, ctx.getSessionManager(), path);
for (String name : request.getCookies().keySet()) {
httpRequest.addCookie(request.getCookies().get(name));
}
if (request.getUrl().getQuery() != null) {