/** * 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()); }
/** * Executes a block of code in a running server. * @param server the server to start. * @param block the block of code to run after the server starts. */ public static void running(TestServer server, final Runnable block) { Helpers$.MODULE$.running(server, asScala(() -> { block.run(); return null; })); }
@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); }
/** * Executes a block of code in a running server, with a test browser. */ public static void running(TestServer server, WebDriver webDriver, final Callback<TestBrowser> block) { synchronized (PlayRunners$.MODULE$.mutex()) { TestBrowser browser = null; TestServer startedServer = null; try { start(server); startedServer = server; browser = testBrowser(webDriver); block.invoke(browser); } catch (Error e) { throw e; } catch (RuntimeException re) { throw re; } catch (Throwable t) { throw new RuntimeException(t); } finally { if (browser != null) { browser.quit(); } if (startedServer != null) { stop(startedServer); } } } }
/** * Constructs a in-memory (h2) database configuration to add to a fake application. * * @param name the database name. * @param options the database options. * @return a map of String containing database config info. */ public static Map<String, String> inMemoryDatabase(String name, Map<String, String> options) { return Scala.asJava(play.api.test.Helpers.inMemoryDatabase(name, Scala.asScala(options))); }
/** * Executes a block of code in a running server. * @param server the server to start. * @param block the block of code to run after the server starts. */ public static void running(TestServer server, final Runnable block) { Helpers$.MODULE$.running(server, asScala(() -> { block.run(); return null; })); }
@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); }
/** * 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()); }
/** * Constructs a in-memory (h2) database configuration to add to a fake application. * * @param name the database name. * @param options the database options. * @return a map of String containing database config info. */ public static Map<String, String> inMemoryDatabase(String name, Map<String, String> options) { return Scala.asJava(play.api.test.Helpers.inMemoryDatabase(name, Scala.asScala(options))); }
/** * 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 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); }
/** * 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()); }
/** * 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 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); }
/** * 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()); }
/** * 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()); }