|
24 | 24 | import org.springframework.util.Assert; |
25 | 25 | import org.springframework.util.StringUtils; |
26 | 26 |
|
27 | | -import java.io.Serializable; |
28 | 27 | import java.util.*; |
29 | 28 |
|
30 | 29 | /** |
|
42 | 41 | @SuppressWarnings("deprecation") |
43 | 42 | public class MockHttpSession implements HttpSession { |
44 | 43 |
|
45 | | - /** |
46 | | - * The session cookie name. |
47 | | - */ |
48 | | - public static final String SESSION_COOKIE_NAME = "JSESSION"; |
49 | | - |
50 | | - |
51 | 44 | private static int nextId = 1; |
52 | 45 |
|
53 | 46 | private String id; |
@@ -258,42 +251,4 @@ public boolean isNew() { |
258 | 251 | assertIsValid(); |
259 | 252 | return this.isNew; |
260 | 253 | } |
261 | | - |
262 | | - /** |
263 | | - * Serialize the attributes of this session into an object that can be |
264 | | - * turned into a byte array with standard Java serialization. |
265 | | - * @return a representation of this session's serialized state |
266 | | - */ |
267 | | - public Serializable serializeState() { |
268 | | - HashMap<String, Serializable> state = new HashMap<>(); |
269 | | - for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext();) { |
270 | | - Map.Entry<String, Object> entry = it.next(); |
271 | | - String name = entry.getKey(); |
272 | | - Object value = entry.getValue(); |
273 | | - it.remove(); |
274 | | - if (value instanceof Serializable) { |
275 | | - state.put(name, (Serializable) value); |
276 | | - } |
277 | | - else { |
278 | | - // Not serializable... Servlet containers usually automatically |
279 | | - // unbind the attribute in this case. |
280 | | - if (value instanceof HttpSessionBindingListener) { |
281 | | - ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value)); |
282 | | - } |
283 | | - } |
284 | | - } |
285 | | - return state; |
286 | | - } |
287 | | - |
288 | | - /** |
289 | | - * Deserialize the attributes of this session from a state object created by |
290 | | - * {@link #serializeState()}. |
291 | | - * @param state a representation of this session's serialized state |
292 | | - */ |
293 | | - @SuppressWarnings("unchecked") |
294 | | - public void deserializeState(Serializable state) { |
295 | | - Assert.isTrue(state instanceof Map, "Serialized state needs to be of type [java.util.Map]"); |
296 | | - this.attributes.putAll((Map<String, Object>) state); |
297 | | - } |
298 | | - |
299 | 254 | } |
0 commit comments