KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > servlet > MockHttpSession


1 package com.mockobjects.servlet;
2
3 import com.mockobjects.*;
4
5 import javax.servlet.ServletContext JavaDoc;
6 import javax.servlet.http.HttpSession JavaDoc;
7 import javax.servlet.http.HttpSessionContext JavaDoc;
8 import java.util.Enumeration JavaDoc;
9
10 public class MockHttpSession extends MockObject implements HttpSession JavaDoc, Verifiable {
11     private ExpectationSet myAttributes = new ExpectationSet("session attributes");
12     private ExpectationSet myRemovedAttributes = new ExpectationSet("removed session attributes");
13     private ReturnObjectBag myAttributeValues = new ReturnObjectBag("attributes");
14     private Enumeration JavaDoc attributeNames;
15
16     private ServletContext JavaDoc servletContext;
17
18     public Object JavaDoc getAttribute(String JavaDoc anAttributeName) {
19         return myAttributeValues.getNextReturnObject(anAttributeName);
20     }
21
22     public void setupGetAttributeNames(Enumeration JavaDoc attributeNames) {
23         this.attributeNames = attributeNames;
24     }
25
26     public Enumeration JavaDoc getAttributeNames() {
27         return attributeNames;
28     }
29
30     public long getCreationTime() {
31         notImplemented();
32         return 0;
33     }
34
35     public String JavaDoc getId() {
36         notImplemented();
37         return null;
38     }
39
40     public long getLastAccessedTime() {
41         notImplemented();
42         return 0;
43     }
44
45     public int getMaxInactiveInterval() {
46         notImplemented();
47         return 0;
48     }
49
50     public HttpSessionContext JavaDoc getSessionContext() {
51         notImplemented();
52         return null;
53     }
54
55     public void setupServletContext(ServletContext JavaDoc servletContext) {
56         this.servletContext = servletContext;
57     }
58
59     public ServletContext JavaDoc getServletContext() {
60         return servletContext;
61     }
62
63     public Object JavaDoc getValue(String JavaDoc arg1) {
64         notImplemented();
65         return null;
66     }
67
68     public String JavaDoc[] getValueNames() {
69         notImplemented();
70         return null;
71     }
72
73     public void invalidate() {
74         notImplemented();
75     }
76
77     public boolean isNew() {
78         notImplemented();
79         return false;
80     }
81
82     public void putValue(String JavaDoc arg1, Object JavaDoc arg2) {
83         notImplemented();
84     }
85
86     public void setExpectedRemoveAttribute(String JavaDoc anAttributeName){
87         myRemovedAttributes.addExpected(anAttributeName);
88     }
89
90     public void removeAttribute(String JavaDoc anAttributeName) {
91         myRemovedAttributes.addActual(anAttributeName);
92     }
93
94     public void removeValue(String JavaDoc arg1) {
95         notImplemented();
96     }
97
98     public void setupGetAttribute(String JavaDoc key, Object JavaDoc value){
99         myAttributeValues.putObjectToReturn(key, value);
100     }
101
102     public void setAttribute(String JavaDoc aKey, Object JavaDoc aValue) {
103         myAttributes.addActual(new MapEntry(aKey, aValue));
104     }
105
106     public void setExpectedAttribute(String JavaDoc aKey, Object JavaDoc aValue) {
107         myAttributes.addExpected(new MapEntry(aKey, aValue));
108     }
109
110     public void setMaxInactiveInterval(int arg1) {
111         notImplemented();
112     }
113 }
114
Popular Tags