1   /*
2    * Copyright 2002-2004 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }