How to change play.http.router parameter in playframework java

referernce : http://stackoverflow.com/questions/31509026/play-2-4-how-do-i-disable-routes-file-loading-during-unit-tests

ex: javauides.tests.routes files map to javaguide.tests.Routes class

Play's route compiler task compiles all files in conf folder ending with .routes as well as the default routes file. Generated class name is always Routes, but the package name depends on the file name. If the file name is routes (the default routes file), compiled class is placed in router package, so the fully qualified class name is router.Routes (which is the default value for play.http.router).
For all other route files, RouteCompiler derives the package name by dropping the .routes from the file name. So for my.test.routesplay.http.router value should be my.test.Routes.
Here is the base class for my tests, with custom router and db configuration elements.
public class MyTestBase extends WithApplication {
    @Override
    protected Application provideApplication() {
        Application application = new GuiceApplicationBuilder()
                .configure("db.default.driver", "org.h2.Driver")
                .configure("db.default.url", "jdbc:h2:mem:play")
                .configure("play.http.router", "my.test.Routes")
                .build();
        return application;
    }
}

No comments:

Post a Comment