play.test
Class FakeRequest

java.lang.Object
  extended by play.test.FakeRequest

public class FakeRequest
extends java.lang.Object

Fake HTTP request implementation.


Constructor Summary
FakeRequest()
          Constructs a new GET / fake request.
FakeRequest(java.lang.String method, java.lang.String path)
          Constructs a new request.
 
Method Summary
 play.api.mvc.Request<Http.RequestBody> getWrappedRequest()
           
 FakeRequest withAnyContent(play.api.mvc.AnyContent content, java.lang.String contentType, java.lang.String method)
          Set a AnyContent to this request.
<T> FakeRequest
withBody(T body)
          Set a any body to this request.
 FakeRequest withCookies(Http.Cookie... cookies)
          Add cookies to this request
 FakeRequest withFlash(java.lang.String name, java.lang.String value)
          Add addtional session to this request.
 FakeRequest withFormUrlEncodedBody(java.util.Map<java.lang.String,java.lang.String> data)
          Set a Form url encoded body to this request.
 FakeRequest withHeader(java.lang.String name, java.lang.String value)
          Add additional headers to this request.
 FakeRequest withJsonBody(com.fasterxml.jackson.databind.JsonNode node)
          Set a Json Body to this request.
 FakeRequest withJsonBody(com.fasterxml.jackson.databind.JsonNode node, java.lang.String method)
          Set a Json Body to this request.
 FakeRequest withJsonBody(play.api.libs.json.JsValue json)
          Set a Json Body to this request.
 FakeRequest withJsonBody(play.api.libs.json.JsValue json, java.lang.String method)
          Set a Json Body to this request.
 FakeRequest withRawBody(byte[] data)
          Set a Binary Data to this request.
 FakeRequest withSession(java.lang.String name, java.lang.String value)
          Add addtional session to this request.
 FakeRequest withTextBody(java.lang.String text)
          Set a Text to this request.
 FakeRequest withXmlBody(org.xml.sax.InputSource xml)
          Set a XML to this request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FakeRequest

public FakeRequest()
Constructs a new GET / fake request.


FakeRequest

public FakeRequest(java.lang.String method,
                   java.lang.String path)
Constructs a new request.

Method Detail

withHeader

public FakeRequest withHeader(java.lang.String name,
                              java.lang.String value)
Add additional headers to this request.


withAnyContent

public FakeRequest withAnyContent(play.api.mvc.AnyContent content,
                                  java.lang.String contentType,
                                  java.lang.String method)
Set a AnyContent to this request.

Parameters:
content - the AnyContent
contentType - Content-Type header value
method - The method to be set
Returns:
the Fake Request

withJsonBody

public FakeRequest withJsonBody(com.fasterxml.jackson.databind.JsonNode node)
Set a Json Body to this request. The Content-Type header of the request is set to application/json. The method is set to POST.

Parameters:
node - the Json Node
Returns:
the Fake Request

withJsonBody

public FakeRequest withJsonBody(play.api.libs.json.JsValue json)
Set a Json Body to this request. The Content-Type header of the request is set to application/json. The method is set to POST.

Parameters:
json - the JsValue
Returns:
the Fake Request

withJsonBody

public FakeRequest withJsonBody(com.fasterxml.jackson.databind.JsonNode node,
                                java.lang.String method)
Set a Json Body to this request. The Content-Type header of the request is set to application/json.

Parameters:
node - the Json Node
method - the HTTP method. POST if set to null
Returns:
the Fake Request

withJsonBody

public FakeRequest withJsonBody(play.api.libs.json.JsValue json,
                                java.lang.String method)
Set a Json Body to this request. The Content-Type header of the request is set to application/json.

Parameters:
json - the JsValue
method - the HTTP method. POST if set to null
Returns:
the Fake Request

withFlash

public FakeRequest withFlash(java.lang.String name,
                             java.lang.String value)
Add addtional session to this request.


withSession

public FakeRequest withSession(java.lang.String name,
                               java.lang.String value)
Add addtional session to this request.


withCookies

public FakeRequest withCookies(Http.Cookie... cookies)
Add cookies to this request


withFormUrlEncodedBody

public FakeRequest withFormUrlEncodedBody(java.util.Map<java.lang.String,java.lang.String> data)
Set a Form url encoded body to this request.


getWrappedRequest

public play.api.mvc.Request<Http.RequestBody> getWrappedRequest()

withRawBody

public FakeRequest withRawBody(byte[] data)
Set a Binary Data to this request. The Content-Type header of the request is set to application/octet-stream. The method is set to POST.

Parameters:
data - the Binary Data
Returns:
the Fake Request

withXmlBody

public FakeRequest withXmlBody(org.xml.sax.InputSource xml)
Set a XML to this request. The Content-Type header of the request is set to application/xml. The method is set to POST.

Parameters:
xml - the XML
Returns:
the Fake Request

withTextBody

public FakeRequest withTextBody(java.lang.String text)
Set a Text to this request. The Content-Type header of the request is set to text/plain. The method is set to POST.

Parameters:
text - the text
Returns:
the Fake Request

withBody

public <T> FakeRequest withBody(T body)
Set a any body to this request.

Parameters:
body - the Body
Returns:
the Fake Request