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 ResteasyAsynchronousContextasynchronousContextprotected Map<String,Object>attributesprotected static URIEMPTY_URIprotected ResteasyHttpHeadershttpHeadersprotected StringhttpMethodprotected InputStreaminputStream-
Fields inherited from class org.jboss.resteasy.plugins.server.BaseHttpRequest
decodedFormParameters, formParameters, uri
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMockHttpRequest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MockHttpRequestaccept(String type)MockHttpRequestaccept(List<javax.ws.rs.core.MediaType> accepts)MockHttpRequestaccept(javax.ws.rs.core.MediaType accept)MockHttpRequestaddFormHeader(String name, String value)Set CONTENT-TYPE to ""application/x-www-form-urlencoded"MockHttpRequestcontent(byte[] bytes)MockHttpRequestcontent(InputStream stream)MockHttpRequestcontentType(String type)MockHttpRequestcontentType(javax.ws.rs.core.MediaType type)MockHttpRequestcookie(String name, String value)static MockHttpRequestcreate(String httpMethod, String uri)static MockHttpRequestcreate(String httpMethod, String absolute, String query, String contextPath)static MockHttpRequestcreate(String httpMethod, URI uriObj, URI baseUri)static MockHttpRequestdeepCopy(HttpRequest request)static MockHttpRequestdelete(String uri)voidforward(String path)static MockHttpRequestget(String uri)ResteasyAsynchronousContextgetAsyncContext()ResteasyAsynchronousContextgetAsynchronousContext()ObjectgetAttribute(String attribute)Map of contextual data.Enumeration<String>getAttributeNames()javax.ws.rs.core.HttpHeadersgetHttpHeaders()StringgetHttpMethod()InputStreamgetInputStream()javax.ws.rs.core.MultivaluedMap<String,String>getMutableHeaders()StringgetRemoteAddress()Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.StringgetRemoteHost()Returns the fully qualified name of the client or the last proxy that sent the request.ResteasyUriInfogetUri()This method *MUST* always return the same instance.static MockHttpRequesthead(String uri)MockHttpRequestheader(String name, String value)voidinitialRequestThreadFinished()protected static MockHttpRequestinitWithUri(String uri)MockHttpRequestlanguage(String language)static MockHttpRequestoptions(String uri)static MockHttpRequestpatch(String uri)static MockHttpRequestpost(String uri)static MockHttpRequestput(String uri)voidremoveAttribute(String name)voidsetAsynchronousContext(ResteasyAsynchronousContext asynchronousContext)voidsetAttribute(String name, Object value)voidsetHttpMethod(String method)voidsetInputStream(InputStream stream)If you are using a servlet container, this will *NOT* override the HttpServletRequest.getInputStream().booleanwasForwarded()-
Methods inherited from class org.jboss.resteasy.plugins.server.BaseHttpRequest
formParametersRead, getDecodedFormParameters, getFormParameters, isInitial, setRequestUri, setRequestUri
-
-
-
-
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<javax.ws.rs.core.MediaType> accepts)
-
accept
public MockHttpRequest accept(javax.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(javax.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 javax.ws.rs.core.HttpHeaders getHttpHeaders()
-
getInputStream
public InputStream getInputStream()
-
setInputStream
public void setInputStream(InputStream stream)
Description copied from interface:HttpRequestIf 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:HttpRequestThis method *MUST* always return the same instance.- Specified by:
getUriin interfaceHttpRequest- Overrides:
getUriin classBaseHttpRequest- Returns:
- uri info
-
getHttpMethod
public String getHttpMethod()
-
initialRequestThreadFinished
public void initialRequestThreadFinished()
-
getAttribute
public Object getAttribute(String attribute)
Description copied from interface:HttpRequestMap 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:HttpRequestReturns 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
Stringcontaining the fully qualified name of the client
-
getRemoteAddress
public String getRemoteAddress()
Description copied from interface:HttpRequestReturns the Internet Protocol (IP) address of the client or last proxy that sent the request.- Returns:
- a
Stringcontaining the IP address of the client that sent the request
-
-