/** * Starts a new application. */ public static void start(Application application) { play.api.Play.start(application.getWrappedApplication()); }
/** * Stops an application. */ public static void stop(Application application) { play.api.Play.stop(application.getWrappedApplication()); }
/** * A test Netty web server with HTTPS support * @param port HTTP port to bind on * @param application The Application to load in this server * @param sslPort HTTPS port to bind on */ public TestServer(int port, Application application, int sslPort) { super(port, application.getWrappedApplication(), Option.<Object>apply(sslPort), play.libs.Scala.<ServerProvider>None()); }
/** * A test Netty web server. * * @param port HTTP port to bind on. * @param application The Application to load in this server. */ public TestServer(int port, Application application) { super(port, application.getWrappedApplication(), play.libs.Scala.<Object>None(), play.libs.Scala.<ServerProvider>None()); }
@Deprecated public static Result route(Application app, RequestBuilder requestBuilder, byte[] body, long timeout) { return wrapScalaResult(Scala.orNull(play.api.test.Helpers.jRoute(app.getWrappedApplication(), requestBuilder.build()._underlyingRequest(), body)), timeout); }
@SuppressWarnings("unchecked") public static Result route(Application app, RequestBuilder requestBuilder, long timeout) { final scala.Option<scala.concurrent.Future<play.api.mvc.Result>> opt = play.api.test.Helpers.jRoute( app.getWrappedApplication(), requestBuilder.build()._underlyingRequest(), requestBuilder.bodyAsAnyContent()); return wrapScalaResult(Scala.orNull(opt), timeout); }
/** * Get a file relative to the application root path. * * @param relativePath relative path of the file to fetch * @return a file instance - it is not guaranteed that the file exists */ default File getFile(String relativePath) { return getWrappedApplication().getFile(relativePath); }
/** * Get the application path. * * @return the application path */ default File path() { return getWrappedApplication().path(); }
/** * Check whether the application is in {@link Mode#DEV} mode. * * @return true if the application is in DEV mode */ default boolean isDev() { return play.api.Play.isDev(getWrappedApplication()); }
/** * Check whether the application is in {@link Mode#PROD} mode. * * @return true if the application is in PROD mode */ default boolean isProd() { return play.api.Play.isProd(getWrappedApplication()); }
/** * Get the application classloader. * * @return the application classloader */ default ClassLoader classloader() { return getWrappedApplication().classloader(); }
/** * Check whether the application is in {@link Mode#TEST} mode. * * @return true if the application is in TEST mode */ default boolean isTest() { return play.api.Play.isTest(getWrappedApplication()); }
/** * Get a resource from the classpath. * * @param relativePath relative path of the resource to fetch * @return URL to the resource (may be null) */ default URL resource(String relativePath) { return Scala.orNull(getWrappedApplication().resource(relativePath)); }
/** * Get the {@link play.Plugin} instance for the given class. * * @param pluginClass the Class of the plugin * @return an instance of the plugin (if found, otherwise null) */ default <T> T plugin(Class<T> pluginClass) { return Scala.orNull(getWrappedApplication().plugin(pluginClass)); }
/** * Get a resource stream from the classpath. * * @param relativePath relative path of the resource to fetch * @return InputStream to the resource (may be null) */ default InputStream resourceAsStream(String relativePath) { return Scala.orNull(getWrappedApplication().resourceAsStream(relativePath)); }
default void onStop(play.Application app) { onStop(app.getWrappedApplication()); }
default void onStart(play.Application app) { onStart(app.getWrappedApplication()); }
public static Result route(Application app, FakeRequest fakeRequest) { final scala.Option<play.api.mvc.Result> opt = play.api.test.Helpers.jRoute(app.getWrappedApplication(), fakeRequest.fake); final play.api.mvc.Result r = opt.getOrElse(null); if(r != null){ return new Result() { public play.api.mvc.Result getWrappedResult(){ return r; } }; } return null; }
@Override public void onStop(Application app) { super.onStop(app); if (graphiteConfig != null) { graphiteConfig.onStop(app.getWrappedApplication()); } }
public static <T> Result route(Application app, FakeRequest fakeRequest, byte[] body) { final play.api.mvc.Result r = play.api.test.Helpers.jRoute(app.getWrappedApplication(), fakeRequest.getWrappedRequest(), body).getOrElse(null); if(r != null){ return new Result() { public play.api.mvc.Result getWrappedResult(){ return r; } }; } return null; }