/** * Starts a new application. * * @param application the application to start. */ public static void start(Application application) { play.api.Play.start(application.asScala()); }
/** * Stops an application. * * @param application the application to stop. */ public static void stop(Application application) { play.api.Play.stop(application.asScala()); }
/** * Stops an application. * * @param application the application to stop. */ public static void stop(Application application) { play.api.Play.stop(application.asScala()); }
/** * Starts a new application. * * @param application the application to start. */ public static void start(Application application) { play.api.Play.start(application.asScala()); }
/** * A test 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(createServerConfig(Optional.of(port), Optional.empty()), application.asScala(), play.libs.Scala.None()); }
/** * A test 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(createServerConfig(Optional.of(port), Optional.of(sslPort)), application.asScala(), play.libs.Scala.None()); }
/** * A test 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(createServerConfig(Optional.of(port), Optional.of(sslPort)), application.asScala(), play.libs.Scala.None()); }
/** * A test 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(createServerConfig(Optional.of(port), Optional.empty()), application.asScala(), play.libs.Scala.None()); }
/** * Executes a block of code in a running application. * * @param application the application context. * @param block the block to run after the Play app is started. */ public static void running(Application application, final Runnable block) { Helpers$.MODULE$.running(application.asScala(), asScala(() -> { block.run(); return null; })); }
/** * Executes a block of code in a running application. * * @param application the application context. * @param block the block to run after the Play app is started. */ public static void running(Application application, final Runnable block) { Helpers$.MODULE$.running(application.asScala(), asScala(() -> { block.run(); return null; })); }
/** * Route and call the request, respecting the given timeout. * * @param app The application used while routing and executing the request * @param router The router type * @param requestBuilder The request builder * @param timeout The amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ public static Result routeAndCall(Application app, Class<? extends Router> router, RequestBuilder requestBuilder, long timeout) { try { Request request = requestBuilder.build(); Router routes = (Router) router.getClassLoader().loadClass(router.getName() + "$").getDeclaredField("MODULE$").get(null); return routes.route(request).map(handler -> invokeHandler(app.asScala(), handler, request, timeout) ).orElse(null); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
/** * Route and call the request, respecting the given timeout. * * @param app The application used while routing and executing the request * @param router The router type * @param requestBuilder The request builder * @param timeout The amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ public static Result routeAndCall(Application app, Class<? extends Router> router, RequestBuilder requestBuilder, long timeout) { try { Request request = requestBuilder.build(); Router routes = (Router) router.getClassLoader().loadClass(router.getName() + "$").getDeclaredField("MODULE$").get(null); return routes.route(request).map(handler -> invokeHandler(app.asScala(), handler, request, timeout) ).orElse(null); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
/** * Route and call the request, respecting the given timeout. * * @param app The application used while routing and executing the request * @param router The router * @param requestBuilder The request builder * @param timeout The amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ public static Result routeAndCall(Application app, Router router, RequestBuilder requestBuilder, long timeout) { try { Request request = requestBuilder.build(); return router.route(request).map(handler -> invokeHandler(app.asScala(), handler, request, timeout) ).orElse(null); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
/** * Route and call the request, respecting the given timeout. * * @param app The application used while routing and executing the request * @param router The router * @param requestBuilder The request builder * @param timeout The amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ public static Result routeAndCall(Application app, Router router, RequestBuilder requestBuilder, long timeout) { try { Request request = requestBuilder.build(); return router.route(request).map(handler -> invokeHandler(app.asScala(), handler, request, timeout) ).orElse(null); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
@Before public void startPlay() { app = provideApplication(); Helpers.start(app); mat = app.asScala().materializer(); }
@Before public void startPlay() { app = provideApplication(); Helpers.start(app); mat = app.asScala().materializer(); }
/** * Route the request considering the given timeout. * * @param app The application used while routing and executing the request * @param requestBuilder the request builder * @param timeout the amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ @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.asScala(), requestBuilder.build().asScala(), requestBuilder.body() ); return wrapScalaResult(Scala.orNull(opt), timeout); }
/** * Route the request considering the given timeout. * * @param app The application used while routing and executing the request * @param requestBuilder the request builder * @param timeout the amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ @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.asScala(), requestBuilder.build().asScala(), requestBuilder.body() ); return wrapScalaResult(Scala.orNull(opt), timeout); }
/** * Check whether the application is in {@link Mode#DEV} mode. * * @return true if the application is in DEV mode */ default boolean isDev() { return asScala().isDev(); }
/** * Check whether the application is in {@link Mode#TEST} mode. * * @return true if the application is in TEST mode */ default boolean isTest() { return asScala().isTest(); }