KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > helpers > FilterTestHelper


1 package com.mockobjects.helpers;
2
3 import com.mockobjects.servlet.MockFilterChain;
4 import com.mockobjects.servlet.MockFilterConfig;
5
6 import javax.servlet.Filter JavaDoc;
7 import javax.servlet.ServletException JavaDoc;
8 import java.io.IOException JavaDoc;
9
10 /**
11  * $Revision: 1.1 $
12  */

13 public class FilterTestHelper extends AbstractServletTestHelper {
14     private final Filter JavaDoc filter;
15     private final MockFilterChain filterChain = new MockFilterChain();
16     private final MockFilterConfig filterConfig = new MockFilterConfig();
17
18     public FilterTestHelper(Filter JavaDoc filter) {
19         this.filter = filter;
20         filterConfig.setupGetServletContext(servletContext);
21     }
22
23     public MockFilterChain getFilterChain() {
24         return filterChain;
25     }
26
27     public MockFilterConfig getFilterConfig() {
28         return filterConfig;
29     }
30
31     public void testInit() throws ServletException JavaDoc {
32         filter.init(filterConfig);
33     }
34
35     public void testDoFilter() throws ServletException JavaDoc, IOException JavaDoc {
36         filter.doFilter(request, response, filterChain);
37     }
38 }
39
Popular Tags