Package org.apache.wicket.mock
Class MockPageContext
- java.lang.Object
-
- org.apache.wicket.mock.MockPageContext
-
- All Implemented Interfaces:
IPageContext
public class MockPageContext extends Object implements IPageContext
Mock implementation of a page context - suitable for a single session only.
-
-
Constructor Summary
Constructors Constructor Description MockPageContext()
MockPageContext(String sessionId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearRequest()
void
clearSession()
<T> T
getRequestData(MetaDataKey<T> key, Supplier<T> defaultValue)
Get data from the current request cycle.<T extends Serializable>
TgetSessionAttribute(String key, Supplier<T> defaultValue)
Get an attribute from the session.<T extends Serializable>
TgetSessionData(MetaDataKey<T> key, Supplier<T> defaultValue)
Get metadata from the session.String
getSessionId(boolean bind)
Get the identifier of the session.
-
-
-
Constructor Detail
-
MockPageContext
public MockPageContext()
-
MockPageContext
public MockPageContext(String sessionId)
-
-
Method Detail
-
getRequestData
public <T> T getRequestData(MetaDataKey<T> key, Supplier<T> defaultValue)
Description copied from interface:IPageContext
Get data from the current request cycle.- Specified by:
getRequestData
in interfaceIPageContext
- Parameters:
key
- keydefaultValue
- default value to use if not present- See Also:
RequestCycle.getMetaData(MetaDataKey)
-
getSessionAttribute
public <T extends Serializable> T getSessionAttribute(String key, Supplier<T> defaultValue)
Description copied from interface:IPageContext
Get an attribute from the session.
Binds the session if not already set and supplier is notnull
. Sets the session attribute if supplier is notnull
.- Specified by:
getSessionAttribute
in interfaceIPageContext
- Parameters:
key
- keydefaultValue
- default value to use if not present- Returns:
- value
- See Also:
Session.getAttribute(String)
-
getSessionData
public <T extends Serializable> T getSessionData(MetaDataKey<T> key, Supplier<T> defaultValue)
Description copied from interface:IPageContext
Get metadata from the session.
Binds the session if not already set and supplier is notnull
. Sets the session attribute if supplier is notnull
.- Specified by:
getSessionData
in interfaceIPageContext
- Parameters:
key
- keydefaultValue
- optional supplier of a default value to use if not present- Returns:
- value
- See Also:
Session.getMetaData(MetaDataKey)
-
getSessionId
public String getSessionId(boolean bind)
Description copied from interface:IPageContext
Get the identifier of the session.- Specified by:
getSessionId
in interfaceIPageContext
- Parameters:
bind
- should the session be bound- Returns:
- session id, might be
null
if not bound yet
-
clearRequest
public void clearRequest()
-
clearSession
public void clearSession()
-
-