1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.chain.web.portlet;
17
18
19 import javax.portlet.Portlet;
20 import javax.portlet.PortletContext;
21 import javax.portlet.PortletRequestDispatcher;
22 import java.io.InputStream;
23 import java.net.MalformedURLException;
24 import java.net.URL;
25 import java.util.Enumeration;
26 import java.util.Hashtable;
27 import java.util.Set;
28
29
30
31 public class MockPortletContext implements PortletContext {
32
33
34 private int majorVersion = 1;
35 private int minorVersion = 0;
36 private String portletContextName = "MockPortletContext";
37 private String serverInfo = portletContextName;
38 private Hashtable parameters = new Hashtable();
39 private Hashtable attributes = new Hashtable();
40
41
42
43
44
45 public void setPortletContextName(String portletContextName) {
46 this.portletContextName = portletContextName;
47 }
48
49 public void setServerInfo(String serverInfo) {
50 this.serverInfo = serverInfo;
51 }
52
53 public void addInitParameter(String name, String value) {
54 parameters.put(name, value);
55 }
56
57
58
59
60
61 public Object getAttribute(String name) {
62 return attributes.get(name);
63 }
64
65 public Enumeration getAttributeNames() {
66 return attributes.keys();
67 }
68
69 public String getInitParameter(String name) {
70 return (String)parameters.get(name);
71 }
72
73 public Enumeration getInitParameterNames() {
74 return parameters.keys();
75 }
76
77 public int getMajorVersion() {
78 return majorVersion;
79 }
80
81 public String getMimeType(String path) {
82 throw new UnsupportedOperationException();
83 }
84
85 public int getMinorVersion() {
86 return minorVersion;
87 }
88
89 public PortletRequestDispatcher getNamedDispatcher(String name) {
90 throw new UnsupportedOperationException();
91 }
92
93 public String getPortletContextName() {
94 return portletContextName;
95 }
96
97 public String getRealPath(String path) {
98 throw new UnsupportedOperationException();
99 }
100
101 public PortletRequestDispatcher getRequestDispatcher(String path) {
102 throw new UnsupportedOperationException();
103 }
104
105 public URL getResource(String path) throws MalformedURLException {
106 throw new UnsupportedOperationException();
107 }
108
109 public InputStream getResourceAsStream(String path) {
110 throw new UnsupportedOperationException();
111 }
112
113 public Set getResourcePaths(String path) {
114 throw new UnsupportedOperationException();
115 }
116
117 public String getServerInfo() {
118 return serverInfo;
119 }
120
121 public void log(String message) {
122 throw new UnsupportedOperationException();
123 }
124
125 public void log(String message, Throwable exception) {
126 throw new UnsupportedOperationException();
127 }
128
129 public void removeAttribute(String name) {
130 attributes.remove(name);
131 }
132
133 public void setAttribute(String name, Object value) {
134 attributes.put(name, value);
135 }
136
137 }