java.lang.Object
io.jooby.test.MockContext
- All Implemented Interfaces:
io.jooby.Context,io.jooby.DefaultContext,io.jooby.Registry
Unit test friendly context implementation. Allows to set context properties.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jooby.Context
io.jooby.Context.Selector -
Field Summary
Fields inherited from interface io.jooby.Context
ACCEPT, GMT, PORT, RFC1123, RFC1123_PATTERN, SECURE_PORT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.jooby.Bodybody()<T> T<T> T<T> Tio.jooby.MessageDecoderdecoder(io.jooby.MediaType contentType) io.jooby.FileUploadList<io.jooby.FileUpload> files()List<io.jooby.FileUpload> io.jooby.FlashMapflash()io.jooby.Formdataform()getHost()io.jooby.output.OutputFactoryintgetPort()booleanMock response generated from route execution.io.jooby.StatusCode@Nullable StringgetResponseHeader(String name) longio.jooby.MediaTypeio.jooby.RoutegetRoute()io.jooby.Routerio.jooby.value.ValueFactoryio.jooby.value.Valueheader()booleanbooleanio.jooby.ContextonComplete(io.jooby.Route.Complete task) pathMap()io.jooby.QueryStringquery()removeResponseHeader(String name) io.jooby.Contextio.jooby.SenderresponseWriter(io.jooby.MediaType type) send(byte[] data) send(byte[]... data) io.jooby.Contextsend(io.jooby.FileDownload file) io.jooby.Contextsend(io.jooby.output.Output output) send(io.jooby.StatusCode statusCode) send(InputStream input) send(ByteBuffer data) io.jooby.Contextsend(ByteBuffer[] data) send(FileChannel file) send(ReadableByteChannel channel) io.jooby.Contextio.jooby.Sessionsession()@Nullable io.jooby.SessionsetBody(byte[] body) Set request body.setBody(io.jooby.Body body) Set request body.Set request body.setBodyObject(Object body) Set request body.setCookieMap(Map<String, String> cookies) Set cookie map.setDefaultResponseType(io.jooby.MediaType contentType) Set mock files.setFlashAttribute(String name, String value) Set request flash attribute.setFlashMap(io.jooby.FlashMap flashMap) Set flash map.setForm(io.jooby.Formdata formdata) Set form data.setHeaders(Map<String, Collection<String>> headers) Set request headers.io.jooby.ContextSet HTTP method.setPathMap(Map<String, String> pathMap) io.jooby.ContextsetPort(int port) setQueryString(String queryString) Set query string value.io.jooby.ContextsetRemoteAddress(String remoteAddress) setRequestHeader(String name, String value) Set request headers.setRequestPath(String pathString) Set requestPath.setResetHeadersOnError(boolean resetHeadersOnError) setResponseCode(int statusCode) setResponseCode(io.jooby.StatusCode statusCode) setResponseCookie(io.jooby.Cookie cookie) setResponseHeader(String name, String value) setResponseLength(long length) setResponseType(io.jooby.MediaType contentType) setResponseType(String contentType) setRoute(io.jooby.Route route) setRouter(io.jooby.Router router) Set a mock router.io.jooby.ContextsetSession(MockSession session) Set mock session.voidsetValueFactory(io.jooby.value.ValueFactory valueFactory) Set/Override value factory.toString()io.jooby.Contextupgrade(io.jooby.ServerSentEmitter.Handler handler) upgrade(io.jooby.WebSocket.Initializer handler) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.jooby.Context
getContextPath, isPreflight, locale, locale, locales, locales, lookupMethods inherited from interface io.jooby.DefaultContext
accept, accept, cookie, cookie, flash, flash, flashOrNull, form, form, form, formMap, getAttribute, getHostAndPort, getRequestLength, getRequestType, getRequestType, getRequestURL, getRequestURL, getServerHost, getServerPort, getUser, header, header, headerMap, isSecure, lookup, lookup, matches, path, path, path, query, query, query, queryMap, require, require, require, require, require, responseStream, responseStream, responseStream, responseWriter, responseWriter, responseWriter, send, sendRedirect, sendRedirect, session, session, setAttribute, setResponseHeader, setResponseHeader, setResponseHeader, setUser
-
Constructor Details
-
MockContext
public MockContext()Default constructor.
-
-
Method Details
-
getMethod
- Specified by:
getMethodin interfaceio.jooby.Context
-
setPort
public io.jooby.Context setPort(int port) - Specified by:
setPortin interfaceio.jooby.Context
-
getPort
public int getPort()- Specified by:
getPortin interfaceio.jooby.Context- Specified by:
getPortin interfaceio.jooby.DefaultContext
-
getOutputFactory
public io.jooby.output.OutputFactory getOutputFactory()- Specified by:
getOutputFactoryin interfaceio.jooby.Context- Specified by:
getOutputFactoryin interfaceio.jooby.DefaultContext
-
setMethod
Set HTTP method.- Specified by:
setMethodin interfaceio.jooby.Context- Parameters:
method- HTTP method.- Returns:
- This context.
-
session
public io.jooby.Session session()- Specified by:
sessionin interfaceio.jooby.Context- Specified by:
sessionin interfaceio.jooby.DefaultContext
-
setSession
Set mock session.- Parameters:
session- Mock session.- Returns:
- This context.
-
sessionOrNull
public @Nullable io.jooby.Session sessionOrNull()- Specified by:
sessionOrNullin interfaceio.jooby.Context- Specified by:
sessionOrNullin interfaceio.jooby.DefaultContext
-
cookieMap
- Specified by:
cookieMapin interfaceio.jooby.Context
-
forward
- Specified by:
forwardin interfaceio.jooby.Context- Specified by:
forwardin interfaceio.jooby.DefaultContext
-
setCookieMap
Set cookie map.- Parameters:
cookies- Cookie map.- Returns:
- This context.
-
flash
public io.jooby.FlashMap flash()- Specified by:
flashin interfaceio.jooby.Context- Specified by:
flashin interfaceio.jooby.DefaultContext
-
setFlashMap
Set flash map.- Parameters:
flashMap- Flash map.- Returns:
- This context.
-
setFlashAttribute
Set request flash attribute.- Parameters:
name- Flash name.value- Flash value.- Returns:
- This context.
-
getRoute
public io.jooby.Route getRoute()- Specified by:
getRoutein interfaceio.jooby.Context
-
setRoute
- Specified by:
setRoutein interfaceio.jooby.Context
-
getRequestPath
- Specified by:
getRequestPathin interfaceio.jooby.Context
-
setRequestPath
Set requestPath.- Specified by:
setRequestPathin interfaceio.jooby.Context- Parameters:
pathString- Path string.- Returns:
- This context.
-
pathMap
- Specified by:
pathMapin interfaceio.jooby.Context
-
setPathMap
- Specified by:
setPathMapin interfaceio.jooby.Context
-
query
public io.jooby.QueryString query()- Specified by:
queryin interfaceio.jooby.Context
-
queryString
- Specified by:
queryStringin interfaceio.jooby.Context- Specified by:
queryStringin interfaceio.jooby.DefaultContext
-
setQueryString
Set query string value.- Parameters:
queryString- Query string (starting with?).- Returns:
- This context.
-
header
public io.jooby.value.Value header()- Specified by:
headerin interfaceio.jooby.Context
-
setHeaders
Set request headers.- Parameters:
headers- Request headers.- Returns:
- This context.
-
setRequestHeader
Set request headers.- Parameters:
name- Request header.value- Request value.- Returns:
- This context.
-
form
public io.jooby.Formdata form()- Specified by:
formin interfaceio.jooby.Context
-
files
- Specified by:
filesin interfaceio.jooby.Context- Specified by:
filesin interfaceio.jooby.DefaultContext
-
setFile
Set mock files.- Parameters:
name- HTTP name.file- Mock files.- Returns:
- This context.
-
files
- Specified by:
filesin interfaceio.jooby.Context- Specified by:
filesin interfaceio.jooby.DefaultContext
-
file
- Specified by:
filein interfaceio.jooby.Context- Specified by:
filein interfaceio.jooby.DefaultContext
-
setForm
Set form data.- Parameters:
formdata- Form.- Returns:
- This context.
-
body
public io.jooby.Body body()- Specified by:
bodyin interfaceio.jooby.Context
-
body
- Specified by:
bodyin interfaceio.jooby.Context- Specified by:
bodyin interfaceio.jooby.DefaultContext
-
body
- Specified by:
bodyin interfaceio.jooby.Context- Specified by:
bodyin interfaceio.jooby.DefaultContext
-
decode
- Specified by:
decodein interfaceio.jooby.Context- Specified by:
decodein interfaceio.jooby.DefaultContext
-
setBody
Set request body.- Parameters:
body- Request body.- Returns:
- This context.
-
setBodyObject
Set request body.- Parameters:
body- Request body.- Returns:
- This context.
-
setBody
Set request body.- Parameters:
body- Request body.- Returns:
- This context.
-
setBody
Set request body.- Parameters:
body- Request body.- Returns:
- This context.
-
decoder
public io.jooby.MessageDecoder decoder(io.jooby.MediaType contentType) - Specified by:
decoderin interfaceio.jooby.Context- Specified by:
decoderin interfaceio.jooby.DefaultContext
-
isInIoThread
public boolean isInIoThread()- Specified by:
isInIoThreadin interfaceio.jooby.Context
-
dispatch
- Specified by:
dispatchin interfaceio.jooby.Context
-
dispatch
- Specified by:
dispatchin interfaceio.jooby.Context
-
getAttributes
- Specified by:
getAttributesin interfaceio.jooby.Context
-
removeResponseHeader
- Specified by:
removeResponseHeaderin interfaceio.jooby.Context
-
getResponseHeader
- Specified by:
getResponseHeaderin interfaceio.jooby.Context
-
setResponseHeader
- Specified by:
setResponseHeaderin interfaceio.jooby.Context
-
setResponseLength
- Specified by:
setResponseLengthin interfaceio.jooby.Context
-
getResponseLength
public long getResponseLength()- Specified by:
getResponseLengthin interfaceio.jooby.Context
-
setResponseType
- Specified by:
setResponseTypein interfaceio.jooby.Context
-
setResponseType
- Specified by:
setResponseTypein interfaceio.jooby.Context
-
setResponseCode
- Specified by:
setResponseCodein interfaceio.jooby.Context
-
getResponseCode
public io.jooby.StatusCode getResponseCode()- Specified by:
getResponseCodein interfaceio.jooby.Context
-
render
- Specified by:
renderin interfaceio.jooby.Context- Specified by:
renderin interfaceio.jooby.DefaultContext
-
getResponse
Mock response generated from route execution.- Returns:
- Mock response.
-
responseStream
- Specified by:
responseStreamin interfaceio.jooby.Context
-
responseSender
public io.jooby.Sender responseSender()- Specified by:
responseSenderin interfaceio.jooby.Context
-
getHost
- Specified by:
getHostin interfaceio.jooby.Context- Specified by:
getHostin interfaceio.jooby.DefaultContext
-
setHost
- Specified by:
setHostin interfaceio.jooby.Context
-
getRemoteAddress
- Specified by:
getRemoteAddressin interfaceio.jooby.Context
-
setRemoteAddress
- Specified by:
setRemoteAddressin interfaceio.jooby.Context
-
getProtocol
- Specified by:
getProtocolin interfaceio.jooby.Context
-
getClientCertificates
- Specified by:
getClientCertificatesin interfaceio.jooby.Context
-
getScheme
- Specified by:
getSchemein interfaceio.jooby.Context
-
setScheme
- Specified by:
setSchemein interfaceio.jooby.Context
-
responseWriter
- Specified by:
responseWriterin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context- Specified by:
sendin interfaceio.jooby.DefaultContext
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
public io.jooby.Context send(io.jooby.output.Output output) - Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
public io.jooby.Context send(io.jooby.FileDownload file) - Specified by:
sendin interfaceio.jooby.Context- Specified by:
sendin interfaceio.jooby.DefaultContext
-
send
- Specified by:
sendin interfaceio.jooby.Context- Specified by:
sendin interfaceio.jooby.DefaultContext
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
sendError
- Specified by:
sendErrorin interfaceio.jooby.Context- Specified by:
sendErrorin interfaceio.jooby.DefaultContext
-
sendError
- Specified by:
sendErrorin interfaceio.jooby.Context- Specified by:
sendErrorin interfaceio.jooby.DefaultContext
-
setDefaultResponseType
- Specified by:
setDefaultResponseTypein interfaceio.jooby.Context
-
setResponseCookie
- Specified by:
setResponseCookiein interfaceio.jooby.Context
-
getResponseType
public io.jooby.MediaType getResponseType()- Specified by:
getResponseTypein interfaceio.jooby.Context
-
setResponseCode
- Specified by:
setResponseCodein interfaceio.jooby.Context- Specified by:
setResponseCodein interfaceio.jooby.DefaultContext
-
isResponseStarted
public boolean isResponseStarted()- Specified by:
isResponseStartedin interfaceio.jooby.Context
-
getResetHeadersOnError
public boolean getResetHeadersOnError()- Specified by:
getResetHeadersOnErrorin interfaceio.jooby.Context
-
setResetHeadersOnError
- Specified by:
setResetHeadersOnErrorin interfaceio.jooby.Context
-
removeResponseHeaders
public io.jooby.Context removeResponseHeaders()- Specified by:
removeResponseHeadersin interfaceio.jooby.Context
-
getRouter
public io.jooby.Router getRouter()- Specified by:
getRouterin interfaceio.jooby.Context
-
setRouter
Set a mock router.- Parameters:
router- Mock router.- Returns:
- This context.
-
upgrade
- Specified by:
upgradein interfaceio.jooby.Context
-
upgrade
public io.jooby.Context upgrade(io.jooby.ServerSentEmitter.Handler handler) - Specified by:
upgradein interfaceio.jooby.Context
-
onComplete
public io.jooby.Context onComplete(io.jooby.Route.Complete task) - Specified by:
onCompletein interfaceio.jooby.Context
-
toString
-
getValueFactory
public io.jooby.value.ValueFactory getValueFactory()- Specified by:
getValueFactoryin interfaceio.jooby.Context- Specified by:
getValueFactoryin interfaceio.jooby.DefaultContext
-
setValueFactory
public void setValueFactory(io.jooby.value.ValueFactory valueFactory) Set/Override value factory.- Parameters:
valueFactory- Value Factory.
-