1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
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  package org.portletbridge.mock;
17  
18  import java.util.Enumeration;
19  import java.util.Hashtable;
20  
21  import javax.servlet.ServletContext;
22  import javax.servlet.http.HttpSession;
23  import javax.servlet.http.HttpSessionContext;
24  
25  /***
26   * @author JMcCrindle
27   */
28  public class MockHttpSession implements HttpSession {
29      
30      private Hashtable attributes = new Hashtable();
31  
32      /***
33       * 
34       */
35      public MockHttpSession() {
36          super();
37      }
38  
39      /* (non-Javadoc)
40       * @see javax.servlet.http.HttpSession#getCreationTime()
41       */
42      public long getCreationTime() {
43          // TODO Auto-generated method stub
44          return 0;
45      }
46  
47      /* (non-Javadoc)
48       * @see javax.servlet.http.HttpSession#getId()
49       */
50      public String getId() {
51          // TODO Auto-generated method stub
52          return null;
53      }
54  
55      /* (non-Javadoc)
56       * @see javax.servlet.http.HttpSession#getLastAccessedTime()
57       */
58      public long getLastAccessedTime() {
59          // TODO Auto-generated method stub
60          return 0;
61      }
62  
63      /* (non-Javadoc)
64       * @see javax.servlet.http.HttpSession#getServletContext()
65       */
66      public ServletContext getServletContext() {
67          // TODO Auto-generated method stub
68          return null;
69      }
70  
71      /* (non-Javadoc)
72       * @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int)
73       */
74      public void setMaxInactiveInterval(int arg0) {
75          // TODO Auto-generated method stub
76          
77      }
78  
79      /* (non-Javadoc)
80       * @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
81       */
82      public int getMaxInactiveInterval() {
83          // TODO Auto-generated method stub
84          return 0;
85      }
86  
87      /* (non-Javadoc)
88       * @see javax.servlet.http.HttpSession#getSessionContext()
89       */
90      public HttpSessionContext getSessionContext() {
91          // TODO Auto-generated method stub
92          return null;
93      }
94  
95      /* (non-Javadoc)
96       * @see javax.servlet.http.HttpSession#getAttribute(java.lang.String)
97       */
98      public Object getAttribute(String name) {
99          if(name == null) {
100             return null;
101         }
102         return attributes.get(name);
103     }
104 
105     /* (non-Javadoc)
106      * @see javax.servlet.http.HttpSession#getValue(java.lang.String)
107      */
108     public Object getValue(String name) {
109         // TODO Auto-generated method stub
110         return null;
111     }
112 
113     /* (non-Javadoc)
114      * @see javax.servlet.http.HttpSession#getAttributeNames()
115      */
116     public Enumeration getAttributeNames() {
117         return attributes.keys();
118     }
119 
120     /* (non-Javadoc)
121      * @see javax.servlet.http.HttpSession#getValueNames()
122      */
123     public String[] getValueNames() {
124         // TODO Auto-generated method stub
125         return null;
126     }
127 
128     /* (non-Javadoc)
129      * @see javax.servlet.http.HttpSession#setAttribute(java.lang.String, java.lang.Object)
130      */
131     public void setAttribute(String name, Object value) {
132         attributes.put(name, value);
133     }
134 
135     /* (non-Javadoc)
136      * @see javax.servlet.http.HttpSession#putValue(java.lang.String, java.lang.Object)
137      */
138     public void putValue(String arg0, Object arg1) {
139         // TODO Auto-generated method stub
140         
141     }
142 
143     /* (non-Javadoc)
144      * @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String)
145      */
146     public void removeAttribute(String arg0) {
147         // TODO Auto-generated method stub
148         
149     }
150 
151     /* (non-Javadoc)
152      * @see javax.servlet.http.HttpSession#removeValue(java.lang.String)
153      */
154     public void removeValue(String arg0) {
155         // TODO Auto-generated method stub
156         
157     }
158 
159     /* (non-Javadoc)
160      * @see javax.servlet.http.HttpSession#invalidate()
161      */
162     public void invalidate() {
163         // TODO Auto-generated method stub
164         
165     }
166 
167     /* (non-Javadoc)
168      * @see javax.servlet.http.HttpSession#isNew()
169      */
170     public boolean isNew() {
171         // TODO Auto-generated method stub
172         return false;
173     }
174 
175 }