jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pedro Nevado" <pnev...@javato.com>
Subject FilterRedirector does not initialize sessions. - IS THIS A BUG ??
Date Tue, 14 Sep 2004 10:55:46 GMT
Hi there,

In the Cactus documentation says that the Redirector proxy " creates an HTTP
Session if the user has expressed the wish (using the
WebRequest.setAutomaticSession(boolean)  code in the beginXXX() method. By
default a session is always created) and the redirector fills by reflection
the session implicit object."

If my understanding of the previous paragraph is correct, the following two
tests should not fail:

............................................................................
...

public class SessionServlet extends HttpServlet {

}

public class SessionServletTest extends ServletTestCase {

    public void beginSessionNull(WebRequest request) {
        request.setAutomaticSession(true);
    }

    public void testSessionNull() {
        SessionServlet sessionServlet = new SessionServlet();
        assertNotNull("There should be a session", session);
    }

}
............................................................................
...

public class SessionFilter {

    private FilterConfig filterConfig;

    public SessionFilter() {
    }

    public void init(FilterConfig filterConfig) {
        this.filterConfig = filterConfig;
    }

    public void doFilter(ServletRequest req, ServletResponse resp,
FilterChain filterChain) throws IOException,
            ServletException {
    }

    public void destroy() {
        this.filterConfig = null;
    }
}

public class SessionFilterTest extends FilterTestCase {

    public void beginSessionNotNull(WebRequest request) {
        request.setAutomaticSession(true);
    }

    public void testSessionNotNull() throws ServletException, IOException{
        HttpSession session = request.getSession(false);
        SessionFilter sessionFilter = new SessionFilter();
        sessionFilter.init(config);
        FilterChain mockFilterChain = new FilterChain() {
            public void doFilter(ServletRequest theRequest, ServletResponse
theResponse) {
            }

            public void init(FilterConfig theConfig) {
            }

            public void destroy() {
            }
        };
        sessionFilter.doFilter(request, response, mockFilterChain);
        assertNotNull("There should be a session", session);
    }
}
............................................................................
...........................

Well, the ServletSessionTest is OK, but the SessionFilterTest fails,
although both of them "have expressed the wish (using the
WebRequest.setAutomaticSession(boolean)  code in the beginXXX() method".

Could anybody tell me if I am overlookin something? I would really
appreciate it.
Regards,

Pedro Nevado



Mime
View raw message