01: package org.vraptor.test;
02:
03: import java.util.Enumeration;
04: import java.util.HashMap;
05: import java.util.Map;
06:
07: import javax.servlet.ServletContext;
08: import javax.servlet.http.HttpSession;
09:
10: /**
11: * Default http session implementation.
12: *
13: * @author Guilherme Silveira
14: */
15: public class MockedHttpSession implements HttpSession {
16:
17: private Map<String, Object> attributes = new HashMap<String, Object>();
18:
19: private ServletContext servletContext;
20:
21: public MockedHttpSession(ServletContext servletContext) {
22: this .servletContext = servletContext;
23: }
24:
25: public long getCreationTime() {
26: return 0;
27: }
28:
29: public String getId() {
30: return null;
31: }
32:
33: public long getLastAccessedTime() {
34: return 0;
35: }
36:
37: public ServletContext getServletContext() {
38: return this .servletContext;
39: }
40:
41: public void setMaxInactiveInterval(int arg0) {
42: // mock, does nothing
43: }
44:
45: public int getMaxInactiveInterval() {
46: return 0;
47: }
48:
49: @SuppressWarnings("deprecation")
50: public javax.servlet.http.HttpSessionContext getSessionContext() {
51: return null;
52: }
53:
54: public Object getValue(String arg0) {
55: return null;
56: }
57:
58: public String[] getValueNames() {
59: return null;
60: }
61:
62: public void putValue(String arg0, Object arg1) {
63: // mock, does nothing
64: }
65:
66: public void removeValue(String arg0) {
67: // mock, does nothing
68: }
69:
70: public void invalidate() {
71: // mock, does nothing
72: }
73:
74: public boolean isNew() {
75: return false;
76: }
77:
78: public void setAttribute(String key, Object value) {
79: this .attributes.put(key, value);
80: }
81:
82: public void removeAttribute(String key) {
83: this .attributes.remove(key);
84: }
85:
86: public Object getAttribute(String key) {
87: return this .attributes.get(key);
88: }
89:
90: public Enumeration getAttributeNames() {
91: return null;
92: }
93:
94: }
|