|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
MockServletConfig.java | - | 100% | 100% | 100% |
|
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; | |
18 | import java.util.Enumeration; | |
19 | import java.util.HashMap; | |
20 | import java.util.Map; | |
21 | ||
22 | import javax.servlet.ServletConfig; | |
23 | import javax.servlet.ServletContext; | |
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, InitParameterHolder | |
34 | { | |
35 | private String _name; | |
36 | private ServletContext _context; | |
37 | private Map _initParameters = new HashMap(); | |
38 | ||
39 | 41 | public MockServletConfig(String name, ServletContext context) |
40 | { | |
41 | 41 | _name = name; |
42 | 41 | _context = context; |
43 | } | |
44 | ||
45 | 1335 | public String getInitParameter(String name) |
46 | { | |
47 | 1335 | return (String) _initParameters.get(name); |
48 | } | |
49 | ||
50 | 21 | public Enumeration getInitParameterNames() |
51 | { | |
52 | 21 | return Collections.enumeration(_initParameters.keySet()); |
53 | } | |
54 | ||
55 | 237 | public ServletContext getServletContext() |
56 | { | |
57 | 237 | return _context; |
58 | } | |
59 | ||
60 | 363 | public String getServletName() |
61 | { | |
62 | 363 | return _name; |
63 | } | |
64 | ||
65 | 37 | public void setInitParameter(String name, String value) |
66 | { | |
67 | 37 | _initParameters.put(name, value); |
68 | } | |
69 | ||
70 | } |
|