01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.mock.web.portlet;
18:
19: import java.util.Enumeration;
20: import java.util.List;
21: import java.util.Properties;
22: import java.util.Vector;
23:
24: import javax.portlet.PortalContext;
25: import javax.portlet.PortletMode;
26: import javax.portlet.WindowState;
27:
28: /**
29: * Mock implementation of the {@link javax.portlet.PortalContext} interface.
30: *
31: * @author John A. Lewis
32: * @author Juergen Hoeller
33: * @since 2.0
34: */
35: public class MockPortalContext implements PortalContext {
36:
37: private final Properties properties = new Properties();
38:
39: private final Vector portletModes;
40:
41: private final Vector windowStates;
42:
43: /**
44: * Create a new MockPortalContext
45: * with default PortletModes (VIEW, EDIT, HELP)
46: * and default WindowStates (NORMAL, MAXIMIZED, MINIMIZED).
47: * @see javax.portlet.PortletMode
48: * @see javax.portlet.WindowState
49: */
50: public MockPortalContext() {
51: this .portletModes = new Vector(3);
52: this .portletModes.add(PortletMode.VIEW);
53: this .portletModes.add(PortletMode.EDIT);
54: this .portletModes.add(PortletMode.HELP);
55:
56: this .windowStates = new Vector(3);
57: this .windowStates.add(WindowState.NORMAL);
58: this .windowStates.add(WindowState.MAXIMIZED);
59: this .windowStates.add(WindowState.MINIMIZED);
60: }
61:
62: /**
63: * Create a new MockPortalContext with the given PortletModes and WindowStates.
64: * @param supportedPortletModes the List of supported PortletMode instances
65: * @param supportedWindowStates the List of supported WindowState instances
66: * @see javax.portlet.PortletMode
67: * @see javax.portlet.WindowState
68: */
69: public MockPortalContext(List supportedPortletModes,
70: List supportedWindowStates) {
71: this .portletModes = new Vector(supportedPortletModes);
72: this .windowStates = new Vector(supportedWindowStates);
73: }
74:
75: public String getPortalInfo() {
76: return "MockPortal/1.0";
77: }
78:
79: public String getProperty(String name) {
80: return this .properties.getProperty(name);
81: }
82:
83: public Enumeration getPropertyNames() {
84: return this .properties.propertyNames();
85: }
86:
87: public Enumeration getSupportedPortletModes() {
88: return this .portletModes.elements();
89: }
90:
91: public Enumeration getSupportedWindowStates() {
92: return this.windowStates.elements();
93: }
94:
95: }
|