All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tests.modjy.java.org.python.util.PyFilterTest Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 2.7.4
Show newest version
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"));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy