An example of using Play 2.1 managed controller class instantiation. This allows us to inject stub implementations of services in tests
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
conf
project
public
test
.gitignore
README

README

An example of managed controller instantiation in Play 2.1
==========================================================

Using the @ symbol before the controller in the routes file and a custom Global object specified in application.conf we are able to have control over the instantiation of controller instances.

This is achieved by overriding the getControllerInstance function of GlobalSettings trait.  I use a map in this example but you could easily defer this to your dependency injection framework of choice.

Then we can switch our services for stub versions by simply overriding the controller instance in the test version of our Global object.

This allows for easy switching of real for fake services in integration tests.