Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An example of using Play 2.1 managed controller class instantiation. This allows us to inject stub implementations of services in tests
branch: master

Initial version

latest commit 0f0642a1e2
Benjamin Parker authored
Failed to load latest commit information.
app Initial version
conf Initial version
project Initial version
public Initial version
test Initial version
.gitignore Initial version
README ReadMe formatting


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.
Something went wrong with that request. Please try again.