001: /*
002: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package de.odysseus.calyxo.base.test;
017:
018: import java.util.Collections;
019: import java.util.Enumeration;
020: import java.util.HashMap;
021: import java.util.Map;
022:
023: import javax.servlet.ServletConfig;
024: import javax.servlet.ServletContext;
025:
026: /**
027: *
028: * @author Christoph Beck
029: */
030: public class TestServletConfig implements ServletConfig {
031: private Map parameters;
032: private String servlet;
033: private ServletContext context;
034:
035: /**
036: * Constructor using {@link TestServletContext}, no init parameters.
037: * @param servlet servlet name
038: */
039: public TestServletConfig(String servlet) {
040: this (servlet, new TestServletContext());
041: }
042:
043: /**
044: * Constructor, no init parameters.
045: * @param servlet servlet name
046: * @param context servlet context we're in
047: */
048: public TestServletConfig(String servlet, ServletContext context) {
049: this (servlet, context, new HashMap());
050: }
051:
052: /**
053: * Constructor using {@link TestServletContext}.
054: * @param servlet servlet name
055: * @param map init parameter map
056: */
057: public TestServletConfig(String servlet, Map map) {
058: this (servlet, new TestServletContext(), map);
059: }
060:
061: /**
062: * Constructor.
063: * @param servlet servlet name
064: * @param context servlet context we're in
065: * @param map init parameter map
066: */
067: public TestServletConfig(String servlet, ServletContext context,
068: Map map) {
069: super ();
070:
071: this .servlet = servlet;
072: this .context = context;
073: this .parameters = map;
074: }
075:
076: /* (non-Javadoc)
077: * @see javax.servlet.ServletConfig#getServletName()
078: */
079: public String getServletName() {
080: return servlet;
081: }
082:
083: /* (non-Javadoc)
084: * @see javax.servlet.ServletConfig#getServletContext()
085: */
086: public ServletContext getServletContext() {
087: return context;
088: }
089:
090: /* (non-Javadoc)
091: * @see javax.servlet.ServletConfig#getInitParameter(java.lang.String)
092: */
093: public String getInitParameter(String arg0) {
094: return (String) parameters.get(arg0);
095: }
096:
097: /* (non-Javadoc)
098: * @see javax.servlet.ServletConfig#getInitParameterNames()
099: */
100: public Enumeration getInitParameterNames() {
101: return Collections.enumeration(parameters.keySet());
102: }
103:
104: }
|