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.ServletConfig;
23 import javax.servlet.ServletContext;
24
25 /***
26 * Mock implementation of the ServletConfig interface.
27 *
28 * <p>Used for testing the web framework; typically not
29 * necessary for testing application controllers.
30 *
31 * @author Rod Johnson
32 * @author Juergen Hoeller
33 * @since 1.0.2
34 */
35 public class MockServletConfig implements ServletConfig {
36
37 private final ServletContext servletContext;
38
39 private final String name;
40
41 private final Hashtable initParameters = new Hashtable();
42
43
44 /***
45 * Create new MockServletConfig with empty String as name.
46 * @param servletContext the ServletContext that the servlet runs in
47 */
48 public MockServletConfig(ServletContext servletContext) {
49 this(servletContext, "");
50 }
51
52 /***
53 * Create new MockServletConfig.
54 * @param servletContext the ServletContext that the servlet runs in
55 * @param name the name of the servlet
56 */
57 public MockServletConfig(ServletContext servletContext, String name) {
58 this.servletContext = servletContext;
59 this.name = name;
60 }
61
62
63 public void addInitParameter(String name, String value) {
64 this.initParameters.put(name, value);
65 }
66
67 public String getInitParameter(String name) {
68 return (String) this.initParameters.get(name);
69 }
70
71 public Enumeration getInitParameterNames() {
72 return this.initParameters.keys();
73 }
74
75 public ServletContext getServletContext() {
76 return servletContext;
77 }
78
79 public String getServletName() {
80 return name;
81 }
82
83 }