001: /*
002: * Copyright 2006 The Apache Software Foundation
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 org.apache.commons.chain.web.portlet;
017:
018: import javax.portlet.Portlet;
019: import javax.portlet.PortletContext;
020: import javax.portlet.PortletRequestDispatcher;
021: import java.io.InputStream;
022: import java.net.MalformedURLException;
023: import java.net.URL;
024: import java.util.Enumeration;
025: import java.util.Hashtable;
026: import java.util.Set;
027:
028: // Mock Object for PortletContext
029: public class MockPortletContext implements PortletContext {
030:
031: private int majorVersion = 1;
032: private int minorVersion = 0;
033: private String portletContextName = "MockPortletContext";
034: private String serverInfo = portletContextName;
035: private Hashtable parameters = new Hashtable();
036: private Hashtable attributes = new Hashtable();
037:
038: // --------------------------------------------------------- Public Methods
039:
040: public void setPortletContextName(String portletContextName) {
041: this .portletContextName = portletContextName;
042: }
043:
044: public void setServerInfo(String serverInfo) {
045: this .serverInfo = serverInfo;
046: }
047:
048: public void addInitParameter(String name, String value) {
049: parameters.put(name, value);
050: }
051:
052: // ------------------------------------------------- PortletContext Methods
053:
054: public Object getAttribute(String name) {
055: return attributes.get(name);
056: }
057:
058: public Enumeration getAttributeNames() {
059: return attributes.keys();
060: }
061:
062: public String getInitParameter(String name) {
063: return (String) parameters.get(name);
064: }
065:
066: public Enumeration getInitParameterNames() {
067: return parameters.keys();
068: }
069:
070: public int getMajorVersion() {
071: return majorVersion;
072: }
073:
074: public String getMimeType(String path) {
075: throw new UnsupportedOperationException();
076: }
077:
078: public int getMinorVersion() {
079: return minorVersion;
080: }
081:
082: public PortletRequestDispatcher getNamedDispatcher(String name) {
083: throw new UnsupportedOperationException();
084: }
085:
086: public String getPortletContextName() {
087: return portletContextName;
088: }
089:
090: public String getRealPath(String path) {
091: throw new UnsupportedOperationException();
092: }
093:
094: public PortletRequestDispatcher getRequestDispatcher(String path) {
095: throw new UnsupportedOperationException();
096: }
097:
098: public URL getResource(String path) throws MalformedURLException {
099: throw new UnsupportedOperationException();
100: }
101:
102: public InputStream getResourceAsStream(String path) {
103: throw new UnsupportedOperationException();
104: }
105:
106: public Set getResourcePaths(String path) {
107: throw new UnsupportedOperationException();
108: }
109:
110: public String getServerInfo() {
111: return serverInfo;
112: }
113:
114: public void log(String message) {
115: throw new UnsupportedOperationException();
116: }
117:
118: public void log(String message, Throwable exception) {
119: throw new UnsupportedOperationException();
120: }
121:
122: public void removeAttribute(String name) {
123: attributes.remove(name);
124: }
125:
126: public void setAttribute(String name, Object value) {
127: attributes.put(name, value);
128: }
129:
130: }
|