play.test
Class Helpers

java.lang.Object
  extended by play.test.Helpers
All Implemented Interfaces:
Http.HeaderNames, Http.Status

public class Helpers
extends java.lang.Object
implements Http.Status, Http.HeaderNames

Helper functions to run tests.


Field Summary
static java.lang.String DELETE
           
static java.lang.Class<? extends org.openqa.selenium.WebDriver> FIREFOX
           
static java.lang.String GET
           
static java.lang.String HEAD
           
static java.lang.Class<? extends org.openqa.selenium.WebDriver> HTMLUNIT
           
static java.lang.String POST
           
static java.lang.String PUT
           
 
Fields inherited from interface play.mvc.Http.Status
ACCEPTED, BAD_GATEWAY, BAD_REQUEST, CONFLICT, CONTINUE, CREATED, EXPECTATION_FAILED, FORBIDDEN, FOUND, GATEWAY_TIMEOUT, GONE, HTTP_VERSION_NOT_SUPPORTED, INTERNAL_SERVER_ERROR, LENGTH_REQUIRED, METHOD_NOT_ALLOWED, MOVED_PERMANENTLY, MULTIPLE_CHOICES, NO_CONTENT, NON_AUTHORITATIVE_INFORMATION, NOT_ACCEPTABLE, NOT_FOUND, NOT_IMPLEMENTED, NOT_MODIFIED, OK, PARTIAL_CONTENT, PAYMENT_REQUIRED, PRECONDITION_FAILED, PROXY_AUTHENTICATION_REQUIRED, REQUEST_ENTITY_TOO_LARGE, REQUEST_TIMEOUT, REQUEST_URI_TOO_LONG, REQUESTED_RANGE_NOT_SATISFIABLE, RESET_CONTENT, SEE_OTHER, SERVICE_UNAVAILABLE, SWITCHING_PROTOCOLS, TEMPORARY_REDIRECT, UNAUTHORIZED, UNSUPPORTED_MEDIA_TYPE, USE_PROXY
 
Fields inherited from interface play.mvc.Http.HeaderNames
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_RANGES, ACCESS_CONTROL_ALLOW_CREDENTIALS, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_MAX_AGE, ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD, AGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_MD5, CONTENT_RANGE, CONTENT_TRANSFER_ENCODING, CONTENT_TYPE, COOKIE, DATE, ETAG, EXPECT, EXPIRES, FROM, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LOCATION, MAX_FORWARDS, ORIGIN, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, RANGE, REFERER, RETRY_AFTER, SERVER, SET_COOKIE, SET_COOKIE2, TE, TRAILER, TRANSFER_ENCODING, UPGRADE, USER_AGENT, VARY, VIA, WARNING, WWW_AUTHENTICATE
 
Constructor Summary
Helpers()
           
 
Method Summary
static Result callAction(HandlerRef actionReference)
          Call an action method while decorating it with the right @With interceptors.
static Result callAction(HandlerRef actionReference, FakeRequest fakeRequest)
          Call an action method while decorating it with the right @With interceptors.
static java.lang.String charset(Result result)
          Extracts the Charset of this Result value.
static byte[] contentAsBytes(Content content)
          Extracts the content as bytes.
static byte[] contentAsBytes(Result result)
          Extracts the content as bytes.
static java.lang.String contentAsString(Content content)
          Extracts the content as String.
static java.lang.String contentAsString(Result result)
          Extracts the content as String.
static java.lang.String contentType(Content content)
          Extracts the Content-Type of this Content value.
static java.lang.String contentType(Result result)
          Extracts the Content-Type of this Result value.
static Http.Cookie cookie(java.lang.String name, Result result)
          * Extracts a Cookie value from this Result value
static FakeApplication fakeApplication()
          Build a new fake application.
static FakeApplication fakeApplication(GlobalSettings global)
          Build a new fake application.
static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration)
          Build a new fake application.
static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration, GlobalSettings global)
          Build a new fake application.
static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration, java.util.List<java.lang.String> additionalPlugin)
          Build a new fake application.
static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration, java.util.List<java.lang.String> additionalPlugin, GlobalSettings global)
          Build a new fake application.
static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration, java.util.List<java.lang.String> additionalPlugins, java.util.List<java.lang.String> withoutPlugins)
          Build a new fake application.
static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration, java.util.List<java.lang.String> additionalPlugins, java.util.List<java.lang.String> withoutPlugins, GlobalSettings global)
          Build a new fake application.
static GlobalSettings fakeGlobal()
          A fake Global
static FakeRequest fakeRequest()
          Build a new GET / fake request.
static FakeRequest fakeRequest(java.lang.String method, java.lang.String uri)
          Build a new fake request.
static Http.Flash flash(Result result)
          Extracts the Flash values of this Result value.
static java.lang.String header(java.lang.String header, Result result)
          Extracts an Header value of this Result value.
static java.util.Map<java.lang.String,java.lang.String> headers(Result result)
          Extracts all Headers of this Result value.
static java.util.Map<java.lang.String,java.lang.String> inMemoryDatabase()
          Constructs a in-memory (h2) database configuration to add to a FakeApplication.
static java.util.Map<java.lang.String,java.lang.String> inMemoryDatabase(java.lang.String name)
          Constructs a in-memory (h2) database configuration to add to a FakeApplication.
static java.util.Map<java.lang.String,java.lang.String> inMemoryDatabase(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> options)
          Constructs a in-memory (h2) database configuration to add to a FakeApplication.
static java.lang.String redirectLocation(Result result)
          Extracts the Location header of this Result value if this Result is a Redirect.
static Result route(Application app, FakeRequest fakeRequest)
           
static Result route(Application app, FakeRequest fakeRequest, byte[] body)
           
static Result route(FakeRequest fakeRequest)
           
static Result route(FakeRequest fakeRequest, byte[] body)
           
static Result routeAndCall(java.lang.Class<? extends play.core.Router.Routes> router, FakeRequest fakeRequest)
          Deprecated.  
static Result routeAndCall(FakeRequest fakeRequest)
          Deprecated.  
static void running(FakeApplication fakeApplication, java.lang.Runnable block)
          Executes a block of code in a running application.
static void running(TestServer server, java.lang.Class<? extends org.openqa.selenium.WebDriver> webDriver, F.Callback<TestBrowser> block)
          Executes a block of code in a running server, with a test browser.
static void running(TestServer server, java.lang.Runnable block)
          Executes a block of code in a running server.
static Http.Session session(Result result)
          Extracts the Session of this Result value.
static void start(FakeApplication fakeApplication)
          Starts a new application.
static void start(TestServer server)
          Starts a Test server.
static int status(Result result)
          Extracts the Status code of this Result value.
static void stop(FakeApplication fakeApplication)
          Stops an application.
static void stop(TestServer server)
          Stops a Test server.
static TestBrowser testBrowser()
          Creates a Test Browser.
static TestBrowser testBrowser(java.lang.Class<? extends org.openqa.selenium.WebDriver> webDriver)
          Creates a Test Browser.
static TestBrowser testBrowser(java.lang.Class<? extends org.openqa.selenium.WebDriver> webDriver, int port)
          Creates a Test Browser.
static TestBrowser testBrowser(int port)
          Creates a Test Browser.
static TestBrowser testBrowser(org.openqa.selenium.WebDriver of)
          Creates a Test Browser.
static TestBrowser testBrowser(org.openqa.selenium.WebDriver of, int port)
          Creates a Test Browser.
static TestServer testServer(int port)
          Creates a new Test server.
static TestServer testServer(int port, FakeApplication app)
          Creates a new Test server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET

public static java.lang.String GET

POST

public static java.lang.String POST

PUT

public static java.lang.String PUT

DELETE

public static java.lang.String DELETE

HEAD

public static java.lang.String HEAD

HTMLUNIT

public static java.lang.Class<? extends org.openqa.selenium.WebDriver> HTMLUNIT

FIREFOX

public static java.lang.Class<? extends org.openqa.selenium.WebDriver> FIREFOX
Constructor Detail

Helpers

public Helpers()
Method Detail

callAction

public static Result callAction(HandlerRef actionReference)
Call an action method while decorating it with the right @With interceptors.


callAction

public static Result callAction(HandlerRef actionReference,
                                FakeRequest fakeRequest)
Call an action method while decorating it with the right @With interceptors.


fakeRequest

public static FakeRequest fakeRequest()
Build a new GET / fake request.


fakeRequest

public static FakeRequest fakeRequest(java.lang.String method,
                                      java.lang.String uri)
Build a new fake request.


fakeApplication

public static FakeApplication fakeApplication()
Build a new fake application.


fakeApplication

public static FakeApplication fakeApplication(GlobalSettings global)
Build a new fake application.


fakeGlobal

public static GlobalSettings fakeGlobal()
A fake Global


inMemoryDatabase

public static java.util.Map<java.lang.String,java.lang.String> inMemoryDatabase()
Constructs a in-memory (h2) database configuration to add to a FakeApplication.


inMemoryDatabase

public static java.util.Map<java.lang.String,java.lang.String> inMemoryDatabase(java.lang.String name)
Constructs a in-memory (h2) database configuration to add to a FakeApplication.


inMemoryDatabase

public static java.util.Map<java.lang.String,java.lang.String> inMemoryDatabase(java.lang.String name,
                                                                                java.util.Map<java.lang.String,java.lang.String> options)
Constructs a in-memory (h2) database configuration to add to a FakeApplication.


fakeApplication

public static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration)
Build a new fake application.


fakeApplication

public static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration,
                                              GlobalSettings global)
Build a new fake application.


fakeApplication

public static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration,
                                              java.util.List<java.lang.String> additionalPlugin)
Build a new fake application.


fakeApplication

public static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration,
                                              java.util.List<java.lang.String> additionalPlugin,
                                              GlobalSettings global)
Build a new fake application.


fakeApplication

public static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration,
                                              java.util.List<java.lang.String> additionalPlugins,
                                              java.util.List<java.lang.String> withoutPlugins)
Build a new fake application.


fakeApplication

public static FakeApplication fakeApplication(java.util.Map<java.lang.String,? extends java.lang.Object> additionalConfiguration,
                                              java.util.List<java.lang.String> additionalPlugins,
                                              java.util.List<java.lang.String> withoutPlugins,
                                              GlobalSettings global)
Build a new fake application.


status

public static int status(Result result)
Extracts the Status code of this Result value.


redirectLocation

public static java.lang.String redirectLocation(Result result)
Extracts the Location header of this Result value if this Result is a Redirect.


flash

public static Http.Flash flash(Result result)
Extracts the Flash values of this Result value.


session

public static Http.Session session(Result result)
Extracts the Session of this Result value.


cookie

public static Http.Cookie cookie(java.lang.String name,
                                 Result result)
* Extracts a Cookie value from this Result value


header

public static java.lang.String header(java.lang.String header,
                                      Result result)
Extracts an Header value of this Result value.


headers

public static java.util.Map<java.lang.String,java.lang.String> headers(Result result)
Extracts all Headers of this Result value.


contentType

public static java.lang.String contentType(Content content)
Extracts the Content-Type of this Content value.


contentType

public static java.lang.String contentType(Result result)
Extracts the Content-Type of this Result value.


charset

public static java.lang.String charset(Result result)
Extracts the Charset of this Result value.


contentAsBytes

public static byte[] contentAsBytes(Result result)
Extracts the content as bytes.


contentAsBytes

public static byte[] contentAsBytes(Content content)
Extracts the content as bytes.


contentAsString

public static java.lang.String contentAsString(Content content)
Extracts the content as String.


contentAsString

public static java.lang.String contentAsString(Result result)
Extracts the content as String.


routeAndCall

public static Result routeAndCall(FakeRequest fakeRequest)
Deprecated. 

Use the Router to determine the Action to call for this request and executes it.

See Also:
instead

routeAndCall

public static Result routeAndCall(java.lang.Class<? extends play.core.Router.Routes> router,
                                  FakeRequest fakeRequest)
Deprecated. 

Use the Router to determine the Action to call for this request and executes it.

See Also:
instead

route

public static Result route(FakeRequest fakeRequest)

route

public static Result route(Application app,
                           FakeRequest fakeRequest)

route

public static Result route(Application app,
                           FakeRequest fakeRequest,
                           byte[] body)

route

public static Result route(FakeRequest fakeRequest,
                           byte[] body)

start

public static void start(FakeApplication fakeApplication)
Starts a new application.


stop

public static void stop(FakeApplication fakeApplication)
Stops an application.


running

public static void running(FakeApplication fakeApplication,
                           java.lang.Runnable block)
Executes a block of code in a running application.


testServer

public static TestServer testServer(int port)
Creates a new Test server.


testServer

public static TestServer testServer(int port,
                                    FakeApplication app)
Creates a new Test server.


start

public static void start(TestServer server)
Starts a Test server.


stop

public static void stop(TestServer server)
Stops a Test server.


running

public static void running(TestServer server,
                           java.lang.Runnable block)
Executes a block of code in a running server.


running

public static void running(TestServer server,
                           java.lang.Class<? extends org.openqa.selenium.WebDriver> webDriver,
                           F.Callback<TestBrowser> block)
Executes a block of code in a running server, with a test browser.


testBrowser

public static TestBrowser testBrowser()
Creates a Test Browser.


testBrowser

public static TestBrowser testBrowser(int port)
Creates a Test Browser.


testBrowser

public static TestBrowser testBrowser(java.lang.Class<? extends org.openqa.selenium.WebDriver> webDriver)
Creates a Test Browser.


testBrowser

public static TestBrowser testBrowser(java.lang.Class<? extends org.openqa.selenium.WebDriver> webDriver,
                                      int port)
Creates a Test Browser.


testBrowser

public static TestBrowser testBrowser(org.openqa.selenium.WebDriver of,
                                      int port)
Creates a Test Browser.


testBrowser

public static TestBrowser testBrowser(org.openqa.selenium.WebDriver of)
Creates a Test Browser.