|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
MockSession.java | 50% | 50% | 46.7% | 48.6% |
|
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
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 | * Mock implementation of {@link javax.servlet.http.HttpSession}. | |
25 | * | |
26 | * | |
27 | * @author Howard Lewis Ship | |
28 | * @since 4.0 | |
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 | } |
|