KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > filters > RequestFilterTest


1 package org.roller.presentation.filters;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4
5 import junit.framework.Test;
6 import junit.framework.TestSuite;
7
8 import org.roller.presentation.RollerRequest;
9 import org.roller.presentation.VelocityServletTestBase;
10 import org.roller.presentation.velocity.PageServlet;
11
12 import com.mockrunner.mock.web.MockHttpServletRequest;
13
14 /**
15  * @author Dave Johnson
16  */

17 public class RequestFilterTest extends VelocityServletTestBase {
18     public void setUp() throws Exception JavaDoc
19     {
20         super.setUp();
21     }
22     public RequestFilterTest() {
23     }
24     public void testRequestFilter() throws Exception JavaDoc {
25         
26         servletModule.setServlet(
27            servletModule.createServlet(PageServlet.class));
28
29         MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
30         mockRequest.setContextPath("/roller/page");
31         mockRequest.setPathInfo("/testuser/20050101");
32         mockRequest.setRequestURL("http://localost:8080");
33
34         servletModule.createFilter(PersistenceSessionFilter.class);
35         servletModule.createFilter(RequestFilter.class);
36         servletModule.setDoChain(true);
37
38         servletModule.doFilter();
39         
40         HttpServletRequest JavaDoc req = (HttpServletRequest JavaDoc)
41             servletModule.getFilteredRequest();
42         RollerRequest rreq = RollerRequest.getRollerRequest(req);
43         assertNotNull(rreq);
44     }
45     public static Test suite()
46     {
47         return new TestSuite(RequestFilterTest.class);
48     }
49 }
50
Popular Tags