Package net.officefloor.server.http.mock
Interface MockHttpResponse
-
- All Known Subinterfaces:
MockWoofResponse
- All Known Implementing Classes:
MockHttpServer.MockHttpResponseImpl
,MockWoofServer.MockWoofResponseImpl
public interface MockHttpResponse
MockHttpResponse
.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
assertCookie(HttpResponseCookie cookie)
Asserts contains theWritableHttpCookie
.void
assertHeader(java.lang.String name, java.lang.String value)
Asserts contains theHttpHeader
.void
assertResponse(int statusCode, java.lang.String entity, java.lang.String... headerNameValuePairs)
Asserts the contents of theHttpResponse
.void
assertStatus(int statusCode)
Assets the status of theHttpResponse
.void
assertStatus(HttpStatus status)
Assets theHttpStatus
of theHttpResponse
.WritableHttpCookie
getCookie(java.lang.String name)
Obtains theWritableHttpCookie
by the name.java.util.List<WritableHttpCookie>
getCookies()
Obtains the responseWritableHttpCookie
instances.java.io.InputStream
getEntity()
ObtainsInputStream
to the response HTTP entity.java.lang.String
getEntity(java.nio.charset.Charset charset)
Obtains the HTTP entity as text.WritableHttpHeader
getHeader(java.lang.String name)
Obtains the firstWritableHttpHeader
by the name.java.util.List<WritableHttpHeader>
getHeaders()
Obtains the responseWritableHttpHeader
instances.HttpStatus
getStatus()
Obtains theHttpStatus
.HttpVersion
getVersion()
Obtains theHttpVersion
.
-
-
-
Method Detail
-
getVersion
HttpVersion getVersion()
Obtains theHttpVersion
.- Returns:
HttpVersion
.
-
getStatus
HttpStatus getStatus()
Obtains theHttpStatus
.- Returns:
HttpStatus
.
-
getHeader
WritableHttpHeader getHeader(java.lang.String name)
Obtains the firstWritableHttpHeader
by the name.- Parameters:
name
- Name of theWritableHttpHeader
.- Returns:
- First
WritableHttpHeader
by the name, ornull
if noWritableHttpHeader
by the name.
-
assertStatus
void assertStatus(int statusCode)
Assets the status of theHttpResponse
.- Parameters:
statusCode
- Status code.
-
assertStatus
void assertStatus(HttpStatus status)
Assets theHttpStatus
of theHttpResponse
.- Parameters:
status
-HttpStatus
.
-
getHeaders
java.util.List<WritableHttpHeader> getHeaders()
Obtains the responseWritableHttpHeader
instances.- Returns:
WritableHttpHeader
instances.
-
assertResponse
void assertResponse(int statusCode, java.lang.String entity, java.lang.String... headerNameValuePairs)
Asserts the contents of theHttpResponse
.- Parameters:
statusCode
- Expected status code.entity
- Expected entity.headerNameValuePairs
- ExpectedHttpHeader
name/value pairs. This only confirms they exist on theHttpResponse
. It is not inclusive to check if these are the onlyHttpHeader
instances.
-
assertHeader
void assertHeader(java.lang.String name, java.lang.String value)
Asserts contains theHttpHeader
.- Parameters:
name
- Expected name.value
- Expected value.
-
getCookie
WritableHttpCookie getCookie(java.lang.String name)
Obtains theWritableHttpCookie
by the name.- Parameters:
name
- Name of theWritableHttpCookie
.- Returns:
WritableHttpCookie
by the name, ornull
if noWritableHttpCookie
by the name.
-
getCookies
java.util.List<WritableHttpCookie> getCookies()
Obtains the responseWritableHttpCookie
instances.- Returns:
WritableHttpCookie
instances.
-
assertCookie
void assertCookie(HttpResponseCookie cookie)
Asserts contains theWritableHttpCookie
.- Parameters:
cookie
- ExpectedWritableHttpCookie
.- See Also:
MockHttpServer.mockResponseCookie(String, String)
-
getEntity
java.io.InputStream getEntity()
ObtainsInputStream
to the response HTTP entity.- Returns:
InputStream
to the response HTTP entity.
-
getEntity
java.lang.String getEntity(java.nio.charset.Charset charset)
Obtains the HTTP entity as text.- Parameters:
charset
-Charset
for HTTP entity. May benull
to use defaultCharset
.- Returns:
- Text of the HTTP entity.
-
-