tests.modjy.java.org.python.util.PyFilterTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jython Show documentation
Show all versions of jython Show documentation
Jython is an implementation of the high-level, dynamic, object-oriented
language Python written in 100% Pure Java, and seamlessly integrated with
the Java platform. It thus allows you to run Python on any Java platform.
package org.python.util;
import javax.servlet.http.HttpServletResponse;
import com.mockrunner.mock.web.MockFilterConfig;
public class PyFilterTest extends PyServletTest {
@Override
protected void setUp() throws Exception {
super.setUp();
setDoChain(true);
}
public void testFilter() {
getWebMockObjectFactory().getMockRequest().setServletPath(getTestPath("basic"));
doGet();
assertFalse(((HttpServletResponse)getFilteredResponse()).containsHeader("X-LookMaNoJava"));
clearOutput();
MockFilterConfig cfg = getWebMockObjectFactory().getMockFilterConfig();
cfg.setInitParameter(PyFilter.FILTER_PATH_PARAM, getTestPath("filter"));
cfg.setInitParameter("header", "X-LookMaNoJava");
// Set that PyServlet initialization has run as mockrunner's context doesn't indicate that
// it happened.
getWebMockObjectFactory().getMockServletContext().setAttribute(PyServlet.INIT_ATTR, "true");
createFilter(PyFilter.class);
doGet();
HttpServletResponse resp = (HttpServletResponse)getFilteredResponse();
assertTrue(resp.containsHeader("X-LookMaNoJava"));
}
}