Package play.test
Class FunctionalTest
- java.lang.Object
-
- org.junit.Assert
-
- play.test.BaseTest
-
- play.test.FunctionalTest
-
public abstract class FunctionalTest extends BaseTest
Application tests support
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFunctionalTest._ByteArrayOutputStreamstatic classFunctionalTest.URL
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAPPLICATION_X_WWW_FORM_URLENCODEDstatic java.lang.StringMULTIPART_FORM_DATA-
Fields inherited from class play.test.BaseTest
startPlayBeforeTests
-
-
Constructor Summary
Constructors Constructor Description FunctionalTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidassertCharset(java.lang.String charset, Http.Response response)Verify response charset encoding, as returned by the server in the Content-Type header.static voidassertContentEquals(java.lang.String content, Http.Response response)Exact equality assertion on response bodystatic voidassertContentMatch(java.lang.String pattern, Http.Response response)Asserts response body matched a pattern or contains some text.static voidassertContentType(java.lang.String contentType, Http.Response response)Verify the response content-typestatic voidassertHeaderEquals(java.lang.String headerName, java.lang.String value, Http.Response response)Exact equality assertion on a response header valuestatic voidassertIsNotFound(Http.Response response)Asserts a 404 (not found) responsestatic voidassertIsOk(Http.Response response)Asserts a 2OO Success responsestatic voidassertIsStaticFile(Http.Response response, java.lang.String filePath)static voidassertStatus(int status, Http.Response response)Asserts response status codevoidclearCookies()static Http.ResponseDELETE(java.lang.String url)static Http.ResponseDELETE(Http.Request request, java.lang.Object url)Sends a DELETE request to the application under tests.static Http.ResponseGET(java.lang.Object url)static Http.ResponseGET(java.lang.Object url, boolean followRedirect)sends a GET request to the application under tests.static Http.ResponseGET(Http.Request request, java.lang.Object url)Sends a GET request to the application under tests.static java.lang.StringgetContent(Http.Response response)obtains the response body as a stringstatic Http.ResponsemakeRequest(Http.Request request)static voidmakeRequest(Http.Request request, Http.Response response)static Http.RequestnewRequest()static Http.ResponsenewResponse()static Http.ResponsePOST(java.lang.Object url)static Http.ResponsePOST(java.lang.Object url, java.lang.String contenttype, java.io.InputStream body)static Http.ResponsePOST(java.lang.Object url, java.lang.String contenttype, java.lang.String body)static Http.ResponsePOST(java.lang.Object url, java.util.Map<java.lang.String,java.lang.String> parameters)static Http.ResponsePOST(java.lang.Object url, java.util.Map<java.lang.String,java.lang.String> parameters, java.util.Map<java.lang.String,java.io.File> files)Sends a POST request to the application under tests as a multipart form.static Http.ResponsePOST(Http.Request request, java.lang.Object url)static Http.ResponsePOST(Http.Request request, java.lang.Object url, java.lang.String contenttype, java.io.InputStream body)Sends a POST request to the application under tests.static Http.ResponsePOST(Http.Request request, java.lang.Object url, java.lang.String contenttype, java.lang.String body)static Http.ResponsePOST(Http.Request request, java.lang.Object url, java.util.Map<java.lang.String,java.lang.String> parameters, java.util.Map<java.lang.String,java.io.File> files)static Http.ResponsePUT(java.lang.Object url, java.lang.String contenttype, java.lang.String body)static Http.ResponsePUT(Http.Request request, java.lang.Object url, java.lang.String contenttype, java.lang.String body)Sends a PUT request to the application under tests.static java.lang.ObjectrenderArgs(java.lang.String name)protected static FunctionalTest.URLreverse()voidsleep(int seconds)-
Methods inherited from class play.test.BaseTest
clearJPASession, pause
-
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
-
-
-
-
Field Detail
-
APPLICATION_X_WWW_FORM_URLENCODED
public static final java.lang.String APPLICATION_X_WWW_FORM_URLENCODED
- See Also:
- Constant Field Values
-
MULTIPART_FORM_DATA
public static final java.lang.String MULTIPART_FORM_DATA
- See Also:
- Constant Field Values
-
-
Method Detail
-
clearCookies
public void clearCookies()
-
GET
public static Http.Response GET(java.lang.Object url)
-
GET
public static Http.Response GET(java.lang.Object url, boolean followRedirect)
sends a GET request to the application under tests.- Parameters:
url- relative url such as "/products/1234"followRedirect- indicates if request have to follow redirection (status 302)- Returns:
- the response
-
GET
public static Http.Response GET(Http.Request request, java.lang.Object url)
Sends a GET request to the application under tests.- Parameters:
request- The given requesturl- relative url such as "/products/1234"- Returns:
- the response
-
POST
public static Http.Response POST(java.lang.Object url)
-
POST
public static Http.Response POST(Http.Request request, java.lang.Object url)
-
POST
public static Http.Response POST(java.lang.Object url, java.lang.String contenttype, java.lang.String body)
-
POST
public static Http.Response POST(Http.Request request, java.lang.Object url, java.lang.String contenttype, java.lang.String body)
-
POST
public static Http.Response POST(java.lang.Object url, java.lang.String contenttype, java.io.InputStream body)
-
POST
public static Http.Response POST(Http.Request request, java.lang.Object url, java.lang.String contenttype, java.io.InputStream body)
Sends a POST request to the application under tests.- Parameters:
request- The given requesturl- relative url such as "/products/1234"contenttype- content-type of the requestbody- posted data- Returns:
- the response
-
POST
public static Http.Response POST(java.lang.Object url, java.util.Map<java.lang.String,java.lang.String> parameters, java.util.Map<java.lang.String,java.io.File> files)
Sends a POST request to the application under tests as a multipart form. Designed for file upload testing.- Parameters:
url- relative url such as "/products/1234"parameters- map of parameters to be postedfiles- map containing files to be uploaded- Returns:
- the response
-
POST
public static Http.Response POST(java.lang.Object url, java.util.Map<java.lang.String,java.lang.String> parameters)
-
POST
public static Http.Response POST(Http.Request request, java.lang.Object url, java.util.Map<java.lang.String,java.lang.String> parameters, java.util.Map<java.lang.String,java.io.File> files)
-
PUT
public static Http.Response PUT(java.lang.Object url, java.lang.String contenttype, java.lang.String body)
-
PUT
public static Http.Response PUT(Http.Request request, java.lang.Object url, java.lang.String contenttype, java.lang.String body)
Sends a PUT request to the application under tests.- Parameters:
request- The given requesturl- relative url such as "/products/1234"contenttype- content-type of the requestbody- data to send- Returns:
- the response
-
DELETE
public static Http.Response DELETE(java.lang.String url)
-
DELETE
public static Http.Response DELETE(Http.Request request, java.lang.Object url)
Sends a DELETE request to the application under tests.- Parameters:
request- The given requesturl- relative url eg. "/products/1234"- Returns:
- the response
-
makeRequest
public static void makeRequest(Http.Request request, Http.Response response)
-
makeRequest
public static Http.Response makeRequest(Http.Request request)
-
newResponse
public static Http.Response newResponse()
-
newRequest
public static Http.Request newRequest()
-
assertIsOk
public static void assertIsOk(Http.Response response)
Asserts a 2OO Success response- Parameters:
response- server response
-
assertIsNotFound
public static void assertIsNotFound(Http.Response response)
Asserts a 404 (not found) response- Parameters:
response- server response
-
assertStatus
public static void assertStatus(int status, Http.Response response)Asserts response status code- Parameters:
status- expected HTTP response coderesponse- server response
-
assertIsStaticFile
public static void assertIsStaticFile(Http.Response response, java.lang.String filePath)
-
assertContentEquals
public static void assertContentEquals(java.lang.String content, Http.Response response)Exact equality assertion on response body- Parameters:
content- expected body contentresponse- server response
-
assertContentMatch
public static void assertContentMatch(java.lang.String pattern, Http.Response response)Asserts response body matched a pattern or contains some text.- Parameters:
pattern- a regular expression pattern or a regular text, ( which must be escaped using Pattern.quote)response- server response
-
assertCharset
public static void assertCharset(java.lang.String charset, Http.Response response)Verify response charset encoding, as returned by the server in the Content-Type header. Be aware that if no charset is returned, assertion will fail.- Parameters:
charset- expected charset encoding such as "utf-8" or "iso8859-1".response- server response
-
assertContentType
public static void assertContentType(java.lang.String contentType, Http.Response response)Verify the response content-type- Parameters:
contentType- expected content-type without any charset extension, such as "text/html"response- server response
-
assertHeaderEquals
public static void assertHeaderEquals(java.lang.String headerName, java.lang.String value, Http.Response response)Exact equality assertion on a response header value- Parameters:
headerName- header to verify. case-insensitivevalue- expected header valueresponse- server response
-
getContent
public static java.lang.String getContent(Http.Response response)
obtains the response body as a string- Parameters:
response- server response- Returns:
- the response body as an utf-8 string
-
renderArgs
public static java.lang.Object renderArgs(java.lang.String name)
-
sleep
public void sleep(int seconds)
-
reverse
protected static FunctionalTest.URL reverse()
-
-