KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > test > mocks > portlet > MockPortletRequest


1 /**
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  **/

5 package org.exoplatform.test.mocks.portlet;
6
7 import java.util.* ;
8 import javax.portlet.* ;
9
10 public class MockPortletRequest implements PortletRequest {
11   private Map parameters_ ;
12   private Map attributes_ ;
13   private PortletSession session_ ;
14   private PortletMode portletMode_ ;
15   private String JavaDoc role_ = "none" ;
16   private String JavaDoc remoteUser_ ;
17   private PortletPreferences prefs_ ;
18    
19   public MockPortletRequest() {
20     parameters_ = new Hashtable() ;
21     attributes_ = new Hashtable() ;
22     session_ = new MockPortletSession() ;
23     portletMode_ = PortletMode.VIEW ;
24     prefs_ = new MockPortletPreferences() ;
25
26   }
27
28   public boolean isWindowStateAllowed(WindowState state) {
29     return true ;
30   }
31
32   public boolean isPortletModeAllowed(PortletMode mode) {
33     return true ;
34   }
35
36   public PortletMode getPortletMode () {
37     return portletMode_ ;
38   }
39
40   public void setPortletMode(PortletMode mode) {
41     portletMode_ = mode ;
42   }
43
44   public WindowState getWindowState () {
45     return WindowState.NORMAL ;
46   }
47   
48   public void setPreferences(PortletPreferences prefs) {
49     prefs_ = prefs ;
50   }
51   
52   public PortletPreferences getPreferences () {
53     return prefs_ ;
54   }
55
56   public PortletSession getPortletSession () {
57     return session_ ;
58   }
59
60   public PortletSession getPortletSession (boolean create) {
61     return session_ ;
62   }
63
64   public String JavaDoc getProperty(String JavaDoc name) {
65     return "not support" ;
66   }
67   
68   public java.util.Enumeration JavaDoc getProperties(String JavaDoc name) {
69     return null ;
70   }
71
72   public java.util.Enumeration JavaDoc getPropertyNames() {
73     return null ;
74   }
75
76   public PortalContext getPortalContext() {
77     return null ;
78   }
79
80   public java.lang.String JavaDoc getAuthType() {
81     return null ;
82   }
83
84   public String JavaDoc getContextPath() {
85     return null ;
86   }
87
88
89   public void setRemoteUser(String JavaDoc user) {
90     remoteUser_ = user ;
91   }
92   public java.lang.String JavaDoc getRemoteUser() {
93     return remoteUser_ ;
94   }
95
96   public java.security.Principal JavaDoc getUserPrincipal() {
97     return null ;
98   }
99   
100   public void setUserInRole(String JavaDoc role) {
101     role_ = role ;
102   }
103   
104   public boolean isUserInRole(java.lang.String JavaDoc role) {
105     return role_.equals(role) ;
106   }
107
108   public Object JavaDoc getAttribute(String JavaDoc name) {
109     return attributes_.get(name) ;
110   }
111
112   public java.util.Enumeration JavaDoc getAttributeNames() {
113     return null ;
114   }
115
116   public String JavaDoc getParameter(String JavaDoc name) {
117     return (String JavaDoc) parameters_.get(name) ;
118   }
119
120   public void setParameter(String JavaDoc name, Object JavaDoc value) {
121     parameters_.put(name,value) ;
122   }
123
124   public java.util.Enumeration JavaDoc getParameterNames() {
125     return null ;
126   }
127
128   public String JavaDoc[] getParameterValues(String JavaDoc name) {
129     return (String JavaDoc[]) parameters_.get(name) ;
130   }
131
132   public java.util.Map JavaDoc getParameterMap() {
133     return parameters_ ;
134   }
135
136   public boolean isSecure() {
137     return false ;
138   }
139
140   public void setAttribute(String JavaDoc name, Object JavaDoc o) {
141     attributes_.put(name, o) ;
142   }
143
144   public void removeAttribute(String JavaDoc name) {
145     attributes_.remove(name) ;
146   }
147
148   public String JavaDoc getRequestedSessionId() {
149     return session_.getId() ;
150   }
151
152   public boolean isRequestedSessionIdValid() {
153     return true ;
154   }
155
156   public String JavaDoc getResponseContentType() {
157     return "txt/html" ;
158   }
159
160   public java.util.Enumeration JavaDoc getResponseContentTypes() {
161     return null ;
162   }
163
164   public java.util.Locale JavaDoc getLocale() {
165     return Locale.US;
166   }
167
168   public java.util.Enumeration JavaDoc getLocales() {
169     return null ;
170   }
171
172   public String JavaDoc getScheme() {
173     return "http://" ;
174   }
175
176   public String JavaDoc getServerName() {
177     return "localhost" ;
178   }
179
180   public int getServerPort() {
181     return 8080 ;
182   }
183 }
Popular Tags