KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > test > mock > MockServletConfig


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

15 package org.apache.tapestry.test.mock;
16
17 import java.util.Collections JavaDoc;
18 import java.util.Enumeration JavaDoc;
19 import java.util.HashMap JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import javax.servlet.ServletConfig JavaDoc;
23 import javax.servlet.ServletContext JavaDoc;
24
25 /**
26  * An implementation of {@link javax.servlet.ServletConfig} used
27  * for Mock testing.
28  *
29  * @author Howard Lewis Ship
30  * @since 4.0
31  */

32
33 public class MockServletConfig implements ServletConfig JavaDoc, InitParameterHolder
34 {
35     private String JavaDoc _name;
36     private ServletContext JavaDoc _context;
37     private Map JavaDoc _initParameters = new HashMap JavaDoc();
38
39     public MockServletConfig(String JavaDoc name, ServletContext JavaDoc context)
40     {
41         _name = name;
42         _context = context;
43     }
44
45     public String JavaDoc getInitParameter(String JavaDoc name)
46     {
47         return (String JavaDoc) _initParameters.get(name);
48     }
49
50     public Enumeration JavaDoc getInitParameterNames()
51     {
52         return Collections.enumeration(_initParameters.keySet());
53     }
54
55     public ServletContext JavaDoc getServletContext()
56     {
57         return _context;
58     }
59
60     public String JavaDoc getServletName()
61     {
62         return _name;
63     }
64
65     public void setInitParameter(String JavaDoc name, String JavaDoc value)
66     {
67         _initParameters.put(name, value);
68     }
69
70 }
71
Popular Tags