001: /*
002: * Copyright (c) 2003, Rafael Steil
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * Created on 04/12/2004 16:00:46
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.http;
044:
045: import java.util.Enumeration;
046: import java.util.HashMap;
047: import java.util.Map;
048:
049: import javax.servlet.ServletContext;
050: import javax.servlet.http.HttpSession;
051: import javax.servlet.http.HttpSessionContext;
052:
053: /**
054: * @author Rafael Steil
055: * @version $Id: FakeHttpSession.java,v 1.5 2007/08/01 22:30:04 rafaelsteil Exp $
056: */
057: public class FakeHttpSession implements HttpSession {
058: private Map attributes = new HashMap();
059:
060: /**
061: * @see javax.servlet.http.HttpSession#getCreationTime()
062: */
063: public long getCreationTime() {
064:
065: return 0;
066: }
067:
068: /**
069: * @see javax.servlet.http.HttpSession#getId()
070: */
071: public String getId() {
072: return "jforum-testcase";
073: }
074:
075: /**
076: * @see javax.servlet.http.HttpSession#getLastAccessedTime()
077: */
078: public long getLastAccessedTime() {
079:
080: return 0;
081: }
082:
083: /**
084: * @see javax.servlet.http.HttpSession#getServletContext()
085: */
086: public ServletContext getServletContext() {
087:
088: return null;
089: }
090:
091: /**
092: * @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int)
093: */
094: public void setMaxInactiveInterval(int arg0) {
095:
096: }
097:
098: /**
099: * @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
100: */
101: public int getMaxInactiveInterval() {
102:
103: return 0;
104: }
105:
106: public HttpSessionContext getSessionContext() {
107:
108: return null;
109: }
110:
111: /**
112: * @see javax.servlet.http.HttpSession#getAttribute(java.lang.String)
113: */
114: public Object getAttribute(String name) {
115: return this .attributes.get(name);
116: }
117:
118: public Object getValue(String arg0) {
119:
120: return null;
121: }
122:
123: /**
124: * @see javax.servlet.http.HttpSession#getAttributeNames()
125: */
126: public Enumeration getAttributeNames() {
127:
128: return null;
129: }
130:
131: public String[] getValueNames() {
132:
133: return null;
134: }
135:
136: /**
137: * @see javax.servlet.http.HttpSession#setAttribute(java.lang.String, java.lang.Object)
138: */
139: public void setAttribute(String name, Object value) {
140: this .attributes.put(name, value);
141: }
142:
143: public void putValue(String arg0, Object arg1) {
144:
145: }
146:
147: /**
148: * @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String)
149: */
150: public void removeAttribute(String name) {
151: this .attributes.remove(name);
152: }
153:
154: public void removeValue(String arg0) {
155:
156: }
157:
158: /**
159: * @see javax.servlet.http.HttpSession#invalidate()
160: */
161: public void invalidate() {
162:
163: }
164:
165: /**
166: * @see javax.servlet.http.HttpSession#isNew()
167: */
168: public boolean isNew() {
169:
170: return false;
171: }
172: }
|