Package org.jboss.resteasy.mock
Class MockHttpRequest
- java.lang.Object
-
- org.jboss.resteasy.plugins.server.BaseHttpRequest
-
- org.jboss.resteasy.mock.MockHttpRequest
-
- All Implemented Interfaces:
HttpRequest
public class MockHttpRequest extends BaseHttpRequest
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
-
Field Summary
Fields Modifier and Type Field Description protected ResteasyAsynchronousContext
asynchronousContext
protected Map<String,Object>
attributes
protected static URI
EMPTY_URI
protected ResteasyHttpHeaders
httpHeaders
protected String
httpMethod
protected InputStream
inputStream
-
Fields inherited from class org.jboss.resteasy.plugins.server.BaseHttpRequest
decodedFormParameters, formParameters, uri
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MockHttpRequest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MockHttpRequest
accept(jakarta.ws.rs.core.MediaType accept)
MockHttpRequest
accept(String type)
MockHttpRequest
accept(List<jakarta.ws.rs.core.MediaType> accepts)
MockHttpRequest
addFormHeader(String name, String value)
Set CONTENT-TYPE to ""application/x-www-form-urlencoded"MockHttpRequest
content(byte[] bytes)
MockHttpRequest
content(InputStream stream)
MockHttpRequest
contentType(jakarta.ws.rs.core.MediaType type)
MockHttpRequest
contentType(String type)
MockHttpRequest
cookie(String name, String value)
static MockHttpRequest
create(String httpMethod, String uri)
static MockHttpRequest
create(String httpMethod, String absolute, String query, String contextPath)
static MockHttpRequest
create(String httpMethod, URI uriObj, URI baseUri)
static MockHttpRequest
deepCopy(HttpRequest request)
static MockHttpRequest
delete(String uri)
void
forward(String path)
static MockHttpRequest
get(String uri)
ResteasyAsynchronousContext
getAsyncContext()
ResteasyAsynchronousContext
getAsynchronousContext()
Object
getAttribute(String attribute)
Map of contextual data.Enumeration<String>
getAttributeNames()
jakarta.ws.rs.core.HttpHeaders
getHttpHeaders()
String
getHttpMethod()
InputStream
getInputStream()
jakarta.ws.rs.core.MultivaluedMap<String,String>
getMutableHeaders()
String
getRemoteAddress()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.String
getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request.ResteasyUriInfo
getUri()
This method *MUST* always return the same instance.static MockHttpRequest
head(String uri)
MockHttpRequest
header(String name, String value)
void
initialRequestThreadFinished()
protected static MockHttpRequest
initWithUri(String uri)
MockHttpRequest
language(String language)
static MockHttpRequest
options(String uri)
static MockHttpRequest
patch(String uri)
static MockHttpRequest
post(String uri)
static MockHttpRequest
put(String uri)
void
removeAttribute(String name)
void
setAsynchronousContext(ResteasyAsynchronousContext asynchronousContext)
void
setAttribute(String name, Object value)
void
setHttpMethod(String method)
void
setInputStream(InputStream stream)
If you are using a servlet container, this will *NOT* override the HttpServletRequest.getInputStream().boolean
wasForwarded()
-
Methods inherited from class org.jboss.resteasy.plugins.server.BaseHttpRequest
formParametersRead, getDecodedFormParameters, getFormParameters, isInitial, setRequestUri, setRequestUri
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.resteasy.spi.HttpRequest
getFormEntityPart, getFormEntityParts
-
-
-
-
Field Detail
-
httpHeaders
protected ResteasyHttpHeaders httpHeaders
-
inputStream
protected InputStream inputStream
-
httpMethod
protected String httpMethod
-
asynchronousContext
protected ResteasyAsynchronousContext asynchronousContext
-
EMPTY_URI
protected static final URI EMPTY_URI
-
-
Method Detail
-
initWithUri
protected static MockHttpRequest initWithUri(String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
create
public static MockHttpRequest create(String httpMethod, String absolute, String query, String contextPath)
-
create
public static MockHttpRequest create(String httpMethod, String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
create
public static MockHttpRequest create(String httpMethod, URI uriObj, URI baseUri)
-
options
public static MockHttpRequest options(String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
get
public static MockHttpRequest get(String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
post
public static MockHttpRequest post(String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
put
public static MockHttpRequest put(String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
patch
public static MockHttpRequest patch(String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
delete
public static MockHttpRequest delete(String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
head
public static MockHttpRequest head(String uri) throws URISyntaxException
- Throws:
URISyntaxException
-
deepCopy
public static MockHttpRequest deepCopy(HttpRequest request) throws IOException
- Throws:
IOException
-
setHttpMethod
public void setHttpMethod(String method)
-
getAsynchronousContext
public ResteasyAsynchronousContext getAsynchronousContext()
-
setAsynchronousContext
public void setAsynchronousContext(ResteasyAsynchronousContext asynchronousContext)
-
header
public MockHttpRequest header(String name, String value)
-
accept
public MockHttpRequest accept(List<jakarta.ws.rs.core.MediaType> accepts)
-
accept
public MockHttpRequest accept(jakarta.ws.rs.core.MediaType accept)
-
accept
public MockHttpRequest accept(String type)
-
language
public MockHttpRequest language(String language)
-
cookie
public MockHttpRequest cookie(String name, String value)
-
contentType
public MockHttpRequest contentType(String type)
-
contentType
public MockHttpRequest contentType(jakarta.ws.rs.core.MediaType type)
-
content
public MockHttpRequest content(byte[] bytes)
-
content
public MockHttpRequest content(InputStream stream)
-
addFormHeader
public MockHttpRequest addFormHeader(String name, String value)
Set CONTENT-TYPE to ""application/x-www-form-urlencoded"- Parameters:
name
- form param namevalue
- form param value- Returns:
MockHttpRequest
-
getHttpHeaders
public jakarta.ws.rs.core.HttpHeaders getHttpHeaders()
-
getInputStream
public InputStream getInputStream()
-
setInputStream
public void setInputStream(InputStream stream)
Description copied from interface:HttpRequest
If you are using a servlet container, this will *NOT* override the HttpServletRequest.getInputStream(). It will only override it for the resteasy HttpRequest- Parameters:
stream
- input stream
-
getUri
public ResteasyUriInfo getUri()
Description copied from interface:HttpRequest
This method *MUST* always return the same instance.- Specified by:
getUri
in interfaceHttpRequest
- Overrides:
getUri
in classBaseHttpRequest
- Returns:
- uri info
-
getHttpMethod
public String getHttpMethod()
-
initialRequestThreadFinished
public void initialRequestThreadFinished()
-
getAttribute
public Object getAttribute(String attribute)
Description copied from interface:HttpRequest
Map of contextual data. Similar to HttpServletRequest attributes- Parameters:
attribute
- attribute name- Returns:
- attribute
-
removeAttribute
public void removeAttribute(String name)
-
getAttributeNames
public Enumeration<String> getAttributeNames()
-
getAsyncContext
public ResteasyAsynchronousContext getAsyncContext()
-
forward
public void forward(String path)
-
wasForwarded
public boolean wasForwarded()
-
getRemoteHost
public String getRemoteHost()
Description copied from interface:HttpRequest
Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.- Returns:
- a
String
containing the fully qualified name of the client
-
getRemoteAddress
public String getRemoteAddress()
Description copied from interface:HttpRequest
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.- Returns:
- a
String
containing the IP address of the client that sent the request
-
-