01: package com.mockrunner.mock.web;
02:
03: import java.util.Enumeration;
04: import java.util.HashMap;
05: import java.util.Map;
06: import java.util.Vector;
07:
08: import javax.servlet.FilterConfig;
09: import javax.servlet.ServletContext;
10:
11: /**
12: * Mock implementation of <code>FilterConfig</code>.
13: */
14: public class MockFilterConfig implements FilterConfig {
15: private ServletContext context;
16: private Map initParameters;
17: private String name;
18:
19: public MockFilterConfig() {
20: initParameters = new HashMap();
21: }
22:
23: /**
24: * Sets the <code>ServletContext</code>.
25: * @param context the <code>ServletContext</code>
26: */
27: public synchronized void setupServletContext(ServletContext context) {
28: this .context = context;
29: }
30:
31: public synchronized String getFilterName() {
32: return name;
33: }
34:
35: public synchronized void setFilterName(String name) {
36: this .name = name;
37: }
38:
39: public synchronized ServletContext getServletContext() {
40: return context;
41: }
42:
43: public synchronized void clearInitParameters() {
44: initParameters.clear();
45: }
46:
47: /**
48: * Clears the init parameters.
49: */
50: public synchronized String getInitParameter(String name) {
51: return (String) initParameters.get(name);
52: }
53:
54: /**
55: * Sets an init parameter.
56: * @param name the name
57: * @param value the value
58: */
59: public synchronized void setInitParameter(String name, String value) {
60: initParameters.put(name, value);
61: }
62:
63: /**
64: * Sets several init parameters.
65: * @param parameters the parameter map
66: */
67: public synchronized void setInitParameters(Map parameters) {
68: initParameters.putAll(parameters);
69: }
70:
71: public synchronized Enumeration getInitParameterNames() {
72: return new Vector(initParameters.keySet()).elements();
73: }
74: }
|