KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > mock > web > portlet > MockPortalContext


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Properties JavaDoc;
22 import java.util.Vector JavaDoc;
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 JavaDoc properties = new Properties JavaDoc();
38
39     private final Vector JavaDoc portletModes;
40
41     private final Vector JavaDoc windowStates;
42
43
44     /**
45      * Create a new MockPortalContext
46      * with default PortletModes (VIEW, EDIT, HELP)
47      * and default WindowStates (NORMAL, MAXIMIZED, MINIMIZED).
48      * @see javax.portlet.PortletMode
49      * @see javax.portlet.WindowState
50      */

51     public MockPortalContext() {
52         this.portletModes = new Vector JavaDoc(3);
53         this.portletModes.add(PortletMode.VIEW);
54         this.portletModes.add(PortletMode.EDIT);
55         this.portletModes.add(PortletMode.HELP);
56
57         this.windowStates = new Vector JavaDoc(3);
58         this.windowStates.add(WindowState.NORMAL);
59         this.windowStates.add(WindowState.MAXIMIZED);
60         this.windowStates.add(WindowState.MINIMIZED);
61     }
62
63     /**
64      * Create a new MockPortalContext with the given PortletModes and WindowStates.
65      * @param supportedPortletModes the List of supported PortletMode instances
66      * @param supportedWindowStates the List of supported WindowState instances
67      * @see javax.portlet.PortletMode
68      * @see javax.portlet.WindowState
69      */

70     public MockPortalContext(List JavaDoc supportedPortletModes, List JavaDoc supportedWindowStates) {
71         this.portletModes = new Vector JavaDoc(supportedPortletModes);
72         this.windowStates = new Vector JavaDoc(supportedWindowStates);
73     }
74
75
76     public String JavaDoc getPortalInfo() {
77         return "MockPortal/1.0";
78     }
79
80     public String JavaDoc getProperty(String JavaDoc name) {
81         return this.properties.getProperty(name);
82     }
83
84     public Enumeration JavaDoc getPropertyNames() {
85         return this.properties.propertyNames();
86     }
87
88     public Enumeration JavaDoc getSupportedPortletModes() {
89         return this.portletModes.elements();
90     }
91
92     public Enumeration JavaDoc getSupportedWindowStates() {
93         return this.windowStates.elements();
94     }
95
96 }
97
Popular Tags