[Play 2.4] [Java] How to specify a test-database with GuiceApplicationBuilder?

146 views
Skip to first unread message

Carsten D.

unread,
Jul 4, 2015, 4:22:02 PM7/4/15
to play-fr...@googlegroups.com
I have been using this before for functional tests using a live application:

running(fakeApplication(inMemoryDatabase()), () -> { // test here });

Since I am using Guice, I now want to utilize the GuiceApplicationBuilder as stated in the documentation, no real need for the fake application:

Application application = new GuiceApplicationBuilder()
   
.overrides(bind(Component.class).to(MockComponent.class))
   
.build();
running
(application, () -> { // test here });

My question is: how can I specify the database to be used with this application? I almost always want to use a new in-memory test-database like before, but I might sometimes need other ones, like it is described here: https://playframework.com/documentation/2.4.x/JavaTestingWithDatabases

I'm a little lost here how to not use fakeApplication() anymore since I need to override bindings, but still be able to specify a database. Thanks!
Reply all
Reply to author
Forward
0 new messages