|
|
|
@ -73,7 +73,6 @@ public class MockHttpSession implements HttpSession { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new MockHttpSession with a default {@link MockServletContext}. |
|
|
|
* Create a new MockHttpSession with a default {@link MockServletContext}. |
|
|
|
* |
|
|
|
|
|
|
|
* @see MockServletContext |
|
|
|
* @see MockServletContext |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public MockHttpSession() { |
|
|
|
public MockHttpSession() { |
|
|
|
@ -82,7 +81,6 @@ public class MockHttpSession implements HttpSession { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new MockHttpSession. |
|
|
|
* Create a new MockHttpSession. |
|
|
|
* |
|
|
|
|
|
|
|
* @param servletContext the ServletContext that the session runs in |
|
|
|
* @param servletContext the ServletContext that the session runs in |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public MockHttpSession(ServletContext servletContext) { |
|
|
|
public MockHttpSession(ServletContext servletContext) { |
|
|
|
@ -91,7 +89,6 @@ public class MockHttpSession implements HttpSession { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new MockHttpSession. |
|
|
|
* Create a new MockHttpSession. |
|
|
|
* |
|
|
|
|
|
|
|
* @param servletContext the ServletContext that the session runs in |
|
|
|
* @param servletContext the ServletContext that the session runs in |
|
|
|
* @param id a unique identifier for this session |
|
|
|
* @param id a unique identifier for this session |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -100,6 +97,7 @@ public class MockHttpSession implements HttpSession { |
|
|
|
this.id = (id != null ? id : Integer.toString(nextId++)); |
|
|
|
this.id = (id != null ? id : Integer.toString(nextId++)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public long getCreationTime() { |
|
|
|
public long getCreationTime() { |
|
|
|
assertIsValid(); |
|
|
|
assertIsValid(); |
|
|
|
@ -112,8 +110,8 @@ public class MockHttpSession implements HttpSession { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* As of Servlet 3.1 the id of a session can be changed. |
|
|
|
* As of Servlet 3.1, the id of a session can be changed. |
|
|
|
* @return the new session id. |
|
|
|
* @return the new session id |
|
|
|
* @since 4.0.3 |
|
|
|
* @since 4.0.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String changeSessionId() { |
|
|
|
public String changeSessionId() { |
|
|
|
@ -228,7 +226,6 @@ public class MockHttpSession implements HttpSession { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Invalidates this session then unbinds any objects bound to it. |
|
|
|
* Invalidates this session then unbinds any objects bound to it. |
|
|
|
* |
|
|
|
|
|
|
|
* @throws IllegalStateException if this method is called on an already invalidated session |
|
|
|
* @throws IllegalStateException if this method is called on an already invalidated session |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -245,13 +242,10 @@ public class MockHttpSession implements HttpSession { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Convenience method for asserting that this session has not been |
|
|
|
* Convenience method for asserting that this session has not been |
|
|
|
* {@linkplain #invalidate() invalidated}. |
|
|
|
* {@linkplain #invalidate() invalidated}. |
|
|
|
* |
|
|
|
|
|
|
|
* @throws IllegalStateException if this session has been invalidated |
|
|
|
* @throws IllegalStateException if this session has been invalidated |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void assertIsValid() { |
|
|
|
private void assertIsValid() { |
|
|
|
if (isInvalid()) { |
|
|
|
Assert.state(!isInvalid(), "The session has already been invalidated"); |
|
|
|
throw new IllegalStateException("The session has already been invalidated"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setNew(boolean value) { |
|
|
|
public void setNew(boolean value) { |
|
|
|
@ -267,7 +261,6 @@ public class MockHttpSession implements HttpSession { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Serialize the attributes of this session into an object that can be |
|
|
|
* Serialize the attributes of this session into an object that can be |
|
|
|
* turned into a byte array with standard Java serialization. |
|
|
|
* turned into a byte array with standard Java serialization. |
|
|
|
* |
|
|
|
|
|
|
|
* @return a representation of this session's serialized state |
|
|
|
* @return a representation of this session's serialized state |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Serializable serializeState() { |
|
|
|
public Serializable serializeState() { |
|
|
|
@ -294,7 +287,6 @@ public class MockHttpSession implements HttpSession { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Deserialize the attributes of this session from a state object created by |
|
|
|
* Deserialize the attributes of this session from a state object created by |
|
|
|
* {@link #serializeState()}. |
|
|
|
* {@link #serializeState()}. |
|
|
|
* |
|
|
|
|
|
|
|
* @param state a representation of this session's serialized state |
|
|
|
* @param state a representation of this session's serialized state |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|