1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package nl.openedge.baritus.test.mock;
33
34 import java.util.Enumeration;
35 import java.util.HashMap;
36 import java.util.Iterator;
37 import java.util.Locale;
38 import java.util.Map;
39
40 /***
41 * @author Eelco Hillenius
42 */
43 public class MockHttpServletRequest extends com.mockobjects.servlet.MockHttpServletRequest
44 {
45
46 private Map attributes = new HashMap();
47
48 /***
49 * @see javax.servlet.http.HttpServletRequest#getDateHeader(java.lang.String)
50 */
51 public long getDateHeader(String arg0)
52 {
53 return System.currentTimeMillis();
54 }
55
56 /***
57 * @see javax.servlet.ServletRequest#getLocale()
58 */
59 public Locale getLocale()
60 {
61 return null;
62 }
63
64 /***
65 * @see javax.servlet.ServletRequest#getAttribute(java.lang.String)
66 */
67 public Object getAttribute(String anAttributeName)
68 {
69 return attributes.get(anAttributeName);
70 }
71
72 /***
73 * @see javax.servlet.ServletRequest#getAttributeNames()
74 */
75 public Enumeration getAttributeNames()
76 {
77 return new ItEnum(attributes.keySet().iterator());
78 }
79
80 /***
81 * @see javax.servlet.ServletRequest#removeAttribute(java.lang.String)
82 */
83 public void removeAttribute(String anAttributeToRemove)
84 {
85 attributes.remove(anAttributeToRemove);
86 }
87
88 /***
89 * @see javax.servlet.ServletRequest#setAttribute(java.lang.String, java.lang.Object)
90 */
91 public void setAttribute(String attributeName, Object attributeValue)
92 {
93 attributes.put(attributeName, attributeValue);
94 }
95
96 }
97
98 class ItEnum implements Enumeration
99 {
100 Iterator i = null;
101
102 public ItEnum(Iterator i)
103 {
104 this.i = i;
105 }
106
107 public boolean hasMoreElements()
108 {
109 return i.hasNext();
110 }
111
112 public Object nextElement()
113 {
114 return i.next();
115 }
116 }