public class FakeContext extends Object implements org.wisdom.api.http.Context
| Modifier and Type | Field and Description |
|---|---|
private Object |
body
The payload.
|
private FakeCookies |
cookies
The cookies.
|
private static AtomicLong |
counter
The context id.
|
private HashMap<String,org.wisdom.api.http.FileItem> |
files
The upload files.
|
private org.wisdom.api.cookies.FlashCookie |
flash
The flash cookie.
|
private Map<String,List<String>> |
form
The form data.
|
private Map<String,List<String>> |
headers
The headers of the request.
|
private Long |
id
The context's id.
|
private Map<String,List<String>> |
parameters
The parameters from path and query.
|
private String |
path
The path of the request.
|
private FakeRequest |
request
The fake request.
|
private org.wisdom.api.cookies.SessionCookie |
session
The session cookie.
|
| Constructor and Description |
|---|
FakeContext() |
| Modifier and Type | Method and Description |
|---|---|
FakeContext |
addToFlash(String key,
String value)
Adds data to the (incoming) flash scope.
|
FakeContext |
addToSession(String key,
String value)
Adds data to the session.
|
Map<String,List<String>> |
attributes()
Deprecated.
|
String |
body() |
<T> T |
body(Class<T> classOfT)
Gets the body.
|
String |
contextPath() |
org.wisdom.api.cookies.Cookie |
cookie(String cookieName)
Gets a specific cookie.
|
org.wisdom.api.cookies.Cookies |
cookies() |
String |
cookieValue(String name)
A method getting the value stored in a cookie.
|
org.wisdom.api.http.FileItem |
file(String name)
Gets a file item.
|
Collection<? extends org.wisdom.api.http.FileItem> |
files() |
org.wisdom.api.cookies.FlashCookie |
flash() |
Map<String,List<String>> |
form() |
boolean |
hasCookie(String cookieName)
Checks whether the cookie is set.
|
String |
header(String name)
Gets the value of the header.
|
Map<String,List<String>> |
headers() |
List<String> |
headers(String name)
Gets all values of the header.
|
Long |
id() |
boolean |
isMultipart() |
String |
parameter(String name)
Gets the value of the given parameter.
|
String |
parameter(String name,
String defaultValue)
Gets the value of the given parameter.
|
Boolean |
parameterAsBoolean(String name)
Gets the value of the given parameter.
|
Boolean |
parameterAsBoolean(String name,
boolean defaultValue)
Gets the value of the given parameter.
|
Integer |
parameterAsInteger(String name)
Gets the value of the given parameter.
|
Integer |
parameterAsInteger(String name,
Integer defaultValue)
Gets the value of the given parameter.
|
String |
parameterFromPath(String name)
Gets the value of the given parameter.
|
Integer |
parameterFromPathAsInteger(String name)
Gets the value of the given parameter.
|
String |
parameterFromPathEncoded(String name)
Gets the value of the given parameter.
|
List<String> |
parameterMultipleValues(String name)
Gets all the values of the given parameter.
|
Map<String,List<String>> |
parameters() |
String |
path() |
BufferedReader |
reader() |
org.wisdom.api.http.Request |
request() |
org.wisdom.api.router.Route |
route()
Not supported in tests.
|
void |
route(org.wisdom.api.router.Route route)
Not supported in tests.
|
org.wisdom.api.cookies.SessionCookie |
session() |
FakeContext |
setAttribute(String name,
File file)
Deprecated.
use
setFormField(String, java.io.File) instead. |
FakeContext |
setAttribute(String name,
String value)
Deprecated.
use
setFormField(String, String) instead. |
FakeContext |
setBody(Object body)
Sets the body.
|
FakeContext |
setCookie(org.wisdom.api.cookies.Cookie cookie)
Adds a cookie.
|
FakeContext |
setCookie(String name,
String value)
Adds a cookie.
|
FakeContext |
setFormField(String name,
File file)
Adds an uploaded files.
|
FakeContext |
setFormField(String name,
String value)
Sets the value of a form field.
|
FakeContext |
setHeader(String name,
String... values)
Sets a header.
|
FakeContext |
setHeader(String name,
String value)
Sets a header.
|
FakeContext |
setParameter(String name,
List<String> values)
Sets a parameter values.
|
FakeContext |
setParameter(String name,
String value)
Sets a parameter.
|
FakeContext |
setPath(String path)
Sets the context's path.
|
private static AtomicLong counter
private Long id
private org.wisdom.api.cookies.SessionCookie session
private org.wisdom.api.cookies.FlashCookie flash
private Object body
private String path
private FakeCookies cookies
private FakeRequest request
public Long id()
id in interface org.wisdom.api.http.Contextpublic org.wisdom.api.http.Request request()
request in interface org.wisdom.api.http.Contextpublic String path()
path in interface org.wisdom.api.http.Contextpublic org.wisdom.api.cookies.FlashCookie flash()
flash in interface org.wisdom.api.http.Contextpublic org.wisdom.api.cookies.SessionCookie session()
session in interface org.wisdom.api.http.Contextpublic org.wisdom.api.cookies.Cookie cookie(String cookieName)
cookie in interface org.wisdom.api.http.ContextcookieName - Name of the cookie to retrievepublic boolean hasCookie(String cookieName)
hasCookie in interface org.wisdom.api.http.ContextcookieName - Name of the cookie to check forpublic org.wisdom.api.cookies.Cookies cookies()
cookies in interface org.wisdom.api.http.Contextpublic FakeContext setCookie(String name, String value)
name - the name, must not be nullvalue - the valuepublic FakeContext setCookie(org.wisdom.api.cookies.Cookie cookie)
cookie - the cookie, must not be nullpublic String contextPath()
contextPath in interface org.wisdom.api.http.Contextpublic String parameter(String name)
parameter in interface org.wisdom.api.http.Contextname - The key of the parameterpublic List<String> parameterMultipleValues(String name)
parameterMultipleValues in interface org.wisdom.api.http.Contextname - The key of the parameterpublic String parameter(String name, String defaultValue)
parameter in interface org.wisdom.api.http.Contextname - The key of the parameterdefaultValue - the default value, if the parameter is not setpublic Integer parameterAsInteger(String name)
parameterAsInteger in interface org.wisdom.api.http.Contextname - The key of the parameterpublic Integer parameterAsInteger(String name, Integer defaultValue)
parameterAsInteger in interface org.wisdom.api.http.Contextname - The key of the parameterdefaultValue - the default value, if the parameter is not setpublic Boolean parameterAsBoolean(String name)
parameterAsBoolean in interface org.wisdom.api.http.Contextname - The key of the parameterpublic Boolean parameterAsBoolean(String name, boolean defaultValue)
parameterAsBoolean in interface org.wisdom.api.http.Contextname - The key of the parameterdefaultValue - the default value, if the parameter is not setpublic String parameterFromPath(String name)
parameterFromPath in interface org.wisdom.api.http.Contextname - The key of the parameterpublic String parameterFromPathEncoded(String name)
parameterFromPathEncoded in interface org.wisdom.api.http.Contextname - The key of the parameterpublic Integer parameterFromPathAsInteger(String name)
parameterFromPathAsInteger in interface org.wisdom.api.http.Contextname - The key of the parameterpublic Map<String,List<String>> parameters()
parameters in interface org.wisdom.api.http.Contextpublic String header(String name)
header in interface org.wisdom.api.http.Contextname - the header's namepublic List<String> headers(String name)
headers in interface org.wisdom.api.http.Contextname - the header's namepublic Map<String,List<String>> headers()
headers in interface org.wisdom.api.http.Contextpublic String cookieValue(String name)
cookieValue in interface org.wisdom.api.http.Contextname - The name of the cookiepublic <T> T body(Class<T> classOfT)
body in interface org.wisdom.api.http.ContextT - the body's classclassOfT - The class of the result.public String body()
body in interface org.wisdom.api.http.Contextpublic BufferedReader reader() throws IOException
reader in interface org.wisdom.api.http.ContextIOException - if the body cannot be read.public org.wisdom.api.router.Route route()
route in interface org.wisdom.api.http.Contextpublic void route(org.wisdom.api.router.Route route)
route in interface org.wisdom.api.http.Contextroute - the route ignoredpublic FakeContext setPath(String path)
path - the pathpublic boolean isMultipart()
isMultipart in interface org.wisdom.api.http.Contextpublic Collection<? extends org.wisdom.api.http.FileItem> files()
files in interface org.wisdom.api.http.Contextpublic org.wisdom.api.http.FileItem file(String name)
file in interface org.wisdom.api.http.Contextname - the file name@Deprecated public Map<String,List<String>> attributes()
attributes in interface org.wisdom.api.http.Contextpublic Map<String,List<String>> form()
form in interface org.wisdom.api.http.Context@Deprecated public FakeContext setAttribute(String name, String value)
setFormField(String, String) instead.name - the namevalue - the valuepublic FakeContext setFormField(String name, String value)
name - the namevalue - the valuepublic FakeContext setParameter(String name, String value)
name - the namevalue - the valuepublic FakeContext setParameter(String name, List<String> values)
name - the namevalues - the valuespublic FakeContext setBody(Object body)
body - the bodypublic FakeContext setHeader(String name, String value)
name - the namevalue - the valuepublic FakeContext setHeader(String name, String... values)
name - the namevalues - the values@Deprecated public FakeContext setAttribute(String name, File file)
setFormField(String, java.io.File) instead.name - the name of the field in the form uploading the file.file - the file objectpublic FakeContext setFormField(String name, File file)
name - the name of the field in the form uploading the file.file - the file objectpublic FakeContext addToSession(String key, String value)
key - the keyvalue - the valuepublic FakeContext addToFlash(String key, String value)
key - the keyvalue - the valueCopyright © 2013–2014 Wisdom Framework. All rights reserved.