1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.test.mock; |
16 |
| |
17 |
| import javax.servlet.ServletContext; |
18 |
| import javax.servlet.http.HttpSession; |
19 |
| import javax.servlet.http.HttpSessionBindingEvent; |
20 |
| import javax.servlet.http.HttpSessionBindingListener; |
21 |
| import javax.servlet.http.HttpSessionContext; |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| public class MockSession extends AttributeHolder implements HttpSession |
32 |
| { |
33 |
| private MockContext _context; |
34 |
| private String _id; |
35 |
| |
36 |
10
| public MockSession(MockContext context, String id)
|
37 |
| { |
38 |
10
| _context = context;
|
39 |
10
| _id = id;
|
40 |
| } |
41 |
| |
42 |
5
| public long getCreationTime()
|
43 |
| { |
44 |
5
| return 0;
|
45 |
| } |
46 |
| |
47 |
5
| public String getId()
|
48 |
| { |
49 |
5
| return _id;
|
50 |
| } |
51 |
| |
52 |
5
| public long getLastAccessedTime()
|
53 |
| { |
54 |
5
| return 0;
|
55 |
| } |
56 |
| |
57 |
0
| public ServletContext getServletContext()
|
58 |
| { |
59 |
0
| return _context;
|
60 |
| } |
61 |
| |
62 |
0
| public void setMaxInactiveInterval(int arg0)
|
63 |
| { |
64 |
| } |
65 |
| |
66 |
5
| public int getMaxInactiveInterval()
|
67 |
| { |
68 |
5
| return 0;
|
69 |
| } |
70 |
| |
71 |
0
| public HttpSessionContext getSessionContext()
|
72 |
| { |
73 |
0
| return null;
|
74 |
| } |
75 |
| |
76 |
0
| public Object getValue(String name)
|
77 |
| { |
78 |
0
| return getAttribute(name);
|
79 |
| } |
80 |
| |
81 |
0
| public String[] getValueNames()
|
82 |
| { |
83 |
0
| return getAttributeNamesArray();
|
84 |
| } |
85 |
| |
86 |
0
| public void putValue(String name, Object value)
|
87 |
| { |
88 |
0
| setAttribute(name, value);
|
89 |
| } |
90 |
| |
91 |
0
| public void removeValue(String name)
|
92 |
| { |
93 |
0
| removeAttribute(name);
|
94 |
| } |
95 |
| |
96 |
0
| public void invalidate()
|
97 |
| { |
98 |
| } |
99 |
| |
100 |
14
| public boolean isNew()
|
101 |
| { |
102 |
14
| return false;
|
103 |
| } |
104 |
| |
105 |
20
| public void setAttribute(String name, Object value)
|
106 |
| { |
107 |
20
| super.setAttribute(name, value);
|
108 |
| |
109 |
20
| if (value instanceof HttpSessionBindingListener)
|
110 |
| { |
111 |
0
| HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
|
112 |
0
| HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, name);
|
113 |
| |
114 |
0
| listener.valueBound(event);
|
115 |
| } |
116 |
| } |
117 |
| |
118 |
| } |