001: /**
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * Licensed under the Common Development and Distribution License,
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at
006: *
007: * http://www.sun.com/cddl/
008: *
009: * Unless required by applicable law or agreed to in writing, software
010: * distributed under the License is distributed on an "AS IS" BASIS,
011: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
012: * implied. See the License for the specific language governing
013: * permissions and limitations under the License.
014: */package com.sun.facelets.mock;
015:
016: import java.util.Enumeration;
017: import java.util.Hashtable;
018:
019: import javax.servlet.ServletContext;
020: import javax.servlet.http.HttpSession;
021: import javax.servlet.http.HttpSessionContext;
022:
023: /**
024: *
025: * @author Jacob Hookom
026: * @version $Id: MockHttpSession.java,v 1.2 2005/07/19 00:49:02 jhook Exp $
027: */
028: public class MockHttpSession implements HttpSession {
029:
030: private final Hashtable attributes = new Hashtable();
031: private final long creationTime;
032: private String id;
033: private long lastAccessedTime;
034: private final ServletContext servletContext;
035: private int maxInactiveInterval = 20;
036:
037: public MockHttpSession(ServletContext servletContext) {
038: this .servletContext = servletContext;
039: this .creationTime = System.currentTimeMillis();
040: this .id = "" + this .creationTime;
041: this .lastAccessedTime = this .creationTime;
042: }
043:
044: public long getCreationTime() {
045: return this .creationTime;
046: }
047:
048: public String getId() {
049: return this .id;
050: }
051:
052: public long getLastAccessedTime() {
053: return this .lastAccessedTime;
054: }
055:
056: public ServletContext getServletContext() {
057: return this .servletContext;
058: }
059:
060: public void setMaxInactiveInterval(int interval) {
061: this .maxInactiveInterval = interval;
062: }
063:
064: public int getMaxInactiveInterval() {
065: return this .maxInactiveInterval;
066: }
067:
068: public HttpSessionContext getSessionContext() {
069: throw new UnsupportedOperationException();
070: }
071:
072: public Object getAttribute(String name) {
073: return this .attributes.get(name);
074: }
075:
076: public Object getValue(String name) {
077: throw new UnsupportedOperationException();
078: }
079:
080: public Enumeration getAttributeNames() {
081: return this .attributes.keys();
082: }
083:
084: public String[] getValueNames() {
085: throw new UnsupportedOperationException();
086: }
087:
088: public void setAttribute(String name, Object value) {
089: this .attributes.put(name, value);
090: }
091:
092: public void putValue(String arg0, Object arg1) {
093: throw new UnsupportedOperationException();
094:
095: }
096:
097: public void removeAttribute(String name) {
098: this .attributes.remove(name);
099: }
100:
101: public void removeValue(String arg0) {
102: throw new UnsupportedOperationException();
103: }
104:
105: public void invalidate() {
106:
107: }
108:
109: public boolean isNew() {
110: return false;
111: }
112:
113: }
|