1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.huihoo.jfox.soaf.util.filter;
18
19 import java.util.Enumeration;
20 import java.util.Hashtable;
21
22 import javax.servlet.FilterConfig;
23 import javax.servlet.ServletContext;
24
25 /***
26 * Mock implementation of the FilterConfig interface.
27 *
28 * <p>Used for testing the web framework; typically not
29 * necessary for testing application controllers.
30 *
31 * @author Juergen Hoeller
32 * @since 1.0.2
33 */
34 public class MockFilterConfig implements FilterConfig {
35
36 private final ServletContext servletContext;
37
38 private final String name;
39
40 private final Hashtable initParameters = new Hashtable();
41
42
43 /***
44 * Create new MockServletConfig with empty String as name.
45 * @param servletContext the ServletContext that the servlet runs in
46 */
47 public MockFilterConfig(ServletContext servletContext) {
48 this(servletContext, "");
49 }
50
51 /***
52 * Create new MockServletConfig.
53 * @param servletContext the ServletContext that the servlet runs in
54 * @param name the name of the servlet
55 */
56 public MockFilterConfig(ServletContext servletContext, String name) {
57 this.servletContext = servletContext;
58 this.name = name;
59 }
60
61
62 public void addInitParameter(String name, String value) {
63 this.initParameters.put(name, value);
64 }
65
66 public String getInitParameter(String name) {
67 return (String) this.initParameters.get(name);
68 }
69
70 public Enumeration getInitParameterNames() {
71 return this.initParameters.keys();
72 }
73
74 public ServletContext getServletContext() {
75 return servletContext;
76 }
77
78 public String getFilterName() {
79 return name;
80 }
81
82 }