2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
17
package org.apache.commons.fileupload;
19
import java.util.Enumeration;
20
import java.util.Hashtable;
21
import javax.portlet.PortletContext;
22
import javax.portlet.PortletSession;
25
* A mock portlet session, useful for unit testing and offline utilities
26
* Note: currently doesn't support scoping
28
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
29
* @version $Id: MockPortletSession.java 479262 2006-11-26 03:09:24Z niallp $
31
public class MockPortletSession implements PortletSession
33
// Hashtable (not HashMap) makes enumerations easier to work with
34
Hashtable attributes = new Hashtable();
36
public MockPortletSession()
42
* @see javax.portlet.PortletSession#getAttribute(java.lang.String)
44
public Object getAttribute(String name)
46
return attributes.get(name);
50
* @see javax.portlet.PortletSession#getAttribute(java.lang.String, int)
52
public Object getAttribute(String name, int scope)
54
return attributes.get(name);
58
* @see javax.portlet.PortletSession#getAttributeNames(int)
60
public Enumeration getAttributeNames(int scope)
62
return attributes.keys();
66
* @see javax.portlet.PortletSession#getCreationTime()
68
public long getCreationTime()
70
// TODO Auto-generated method stub
75
* @see javax.portlet.PortletSession#getId()
79
// TODO Auto-generated method stub
84
* @see javax.portlet.PortletSession#getLastAccessedTime()
86
public long getLastAccessedTime()
88
// TODO Auto-generated method stub
93
* @see javax.portlet.PortletSession#getMaxInactiveInterval()
95
public int getMaxInactiveInterval()
97
// TODO Auto-generated method stub
102
* @see javax.portlet.PortletSession#invalidate()
104
public void invalidate()
106
// TODO Auto-generated method stub
110
* @see javax.portlet.PortletSession#isNew()
112
public boolean isNew()
114
// TODO Auto-generated method stub
119
* @see javax.portlet.PortletSession#removeAttribute(java.lang.String)
121
public void removeAttribute(String name)
123
attributes.remove(name);
127
* @see javax.portlet.PortletSession#removeAttribute(java.lang.String, int)
129
public void removeAttribute(String name, int scope)
131
attributes.remove(name);
135
* @see javax.portlet.PortletSession#setAttribute(java.lang.String, java.lang.Object)
137
public void setAttribute(String name, Object value)
139
attributes.put(name, value);
142
public Enumeration getAttributeNames()
144
return this.getAttributeNames(PortletSession.PORTLET_SCOPE);
149
* @see javax.portlet.PortletSession#setAttribute(java.lang.String, java.lang.Object, int)
151
public void setAttribute(String name, Object value, int scope)
153
attributes.put(name, value);
157
* @see javax.portlet.PortletSession#setMaxInactiveInterval(int)
159
public void setMaxInactiveInterval(int interval)
161
// TODO Auto-generated method stub
164
* @see javax.portlet.PortletSession#getPortletContext()
166
public PortletContext getPortletContext()
168
// TODO Auto-generated method stub