/** * The HTTP port that the server is running on. */ @SuppressWarnings("unchecked") public OptionalInt getRunningHttpPort() { Option scalaPortOption = runningHttpPort(); return OptionConverters.specializer_OptionalInt().fromScala(scalaPortOption); }
@SuppressWarnings("unchecked") private static ServerConfig createServerConfig(Optional<Integer> port, Optional<Integer> sslPort) { return ServerConfig.apply(TestServer.class.getClassLoader(), new File("."), (Option) OptionConverters.toScala(port), (Option) OptionConverters.toScala(sslPort), "0.0.0.0", Mode.TEST.asScala(), System.getProperties()); }
private static Result wrapScalaResult(scala.concurrent.Future<play.api.mvc.Result> result, long timeout) { if (result == null) { return null; } else { try { final play.api.mvc.Result scalaResult = FutureConverters.toJava(result).toCompletableFuture().get(timeout, TimeUnit.MILLISECONDS); return scalaResult.asJava(); } catch (ExecutionException e) { if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { throw new RuntimeException(e.getCause()); } } catch (InterruptedException | TimeoutException e) { throw new RuntimeException(e); } } }
/** * Executes a block of code in a running server, with a test browser. * * @param server the test server. * @param webDriver the web driver instance. * @param block the block of code to execute. */ public static void running(TestServer server, WebDriver webDriver, final Consumer<TestBrowser> block) { Helpers$.MODULE$.runSynchronized(server.application(), asScala(() -> { TestBrowser browser = null; TestServer startedServer = null; try { start(server); startedServer = server; browser = testBrowser(webDriver, (Integer) OptionConverters.toJava(server.config().port()).get()); block.accept(browser); } finally { if (browser != null) { browser.quit(); } if (startedServer != null) { stop(startedServer); } } return null; })); }
/** * Executes a block of code in a running server, with a test browser. * * @param server the test server. * @param webDriver the web driver instance. * @param block the block of code to execute. */ public static void running(TestServer server, WebDriver webDriver, final Consumer<TestBrowser> block) { Helpers$.MODULE$.runSynchronized(server.application(), asScala(() -> { TestBrowser browser = null; TestServer startedServer = null; try { start(server); startedServer = server; browser = testBrowser(webDriver, (Integer) OptionConverters.toJava(server.config().port()).get()); block.accept(browser); } finally { if (browser != null) { browser.quit(); } if (startedServer != null) { stop(startedServer); } } return null; })); }
private static Result wrapScalaResult(scala.concurrent.Future<play.api.mvc.Result> result, long timeout) { if (result == null) { return null; } else { try { final play.api.mvc.Result scalaResult = FutureConverters.toJava(result).toCompletableFuture().get(timeout, TimeUnit.MILLISECONDS); return scalaResult.asJava(); } catch (ExecutionException e) { if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { throw new RuntimeException(e.getCause()); } } catch (InterruptedException | TimeoutException e) { throw new RuntimeException(e); } } }
@SuppressWarnings("unchecked") private static ServerConfig createServerConfig(Optional<Integer> port, Optional<Integer> sslPort) { return ServerConfig.apply(TestServer.class.getClassLoader(), new File("."), (Option) OptionConverters.toScala(port), (Option) OptionConverters.toScala(sslPort), "0.0.0.0", Mode.TEST.asScala(), System.getProperties()); }
/** * The HTTPS port that the server is running on. */ @SuppressWarnings("unchecked") public OptionalInt getRunningHttpsPort() { Option scalaPortOption = runningHttpsPort(); return OptionConverters.specializer_OptionalInt().fromScala(scalaPortOption); } }
/** * Retrieves a file relative to the application root path. * This method returns an Optional, using empty if the file was not found. * * @param relativePath relative path of the file to fetch * @return an existing file */ public Optional<File> getExistingFile(String relativePath) { return OptionConverters.toJava(env.getExistingFile(relativePath)); }
@Override public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Strict(data, OptionConverters.toScala(contentType)); } }
/** * The HTTPS port that the server is running on. */ @SuppressWarnings("unchecked") public OptionalInt getRunningHttpsPort() { Option scalaPortOption = runningHttpsPort(); return OptionConverters.specializer_OptionalInt().fromScala(scalaPortOption); } }
/** * If an application is loaded in dev mode then this additional context is available. * * @return optional with the value if the application is running in dev mode or empty otherwise. */ public Optional<play.api.ApplicationLoader.DevContext> devContext() { return OptionConverters.toJava(underlying.devContext()); }
@Override public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Strict(data, OptionConverters.toScala(contentType)); } }
/** * The HTTP port that the server is running on. */ @SuppressWarnings("unchecked") public OptionalInt getRunningHttpPort() { Option scalaPortOption = runningHttpPort(); return OptionConverters.specializer_OptionalInt().fromScala(scalaPortOption); }
/** * Retrieves a file relative to the application root path. * This method returns an Optional, using empty if the file was not found. * * @param relativePath relative path of the file to fetch * @return an existing file */ public Optional<File> getExistingFile(String relativePath) { return OptionConverters.toJava(env.getExistingFile(relativePath)); }
@Override public play.api.http.HttpEntity asScala() { return new play.api.http.HttpEntity.Strict(data, OptionConverters.toScala(contentType)); } }
/** * Retrieves a file relative to the application root path. * This method returns an Optional, using empty if the file was not found. * * @param relativePath relative path of the file to fetch * @return an existing file */ public Optional<File> getExistingFile(String relativePath) { return OptionConverters.toJava(env.getExistingFile(relativePath)); }
/** * If an application is loaded in dev mode then this additional context is available. * * @return optional with the value if the application is running in dev mode or empty otherwise. */ public Optional<play.api.ApplicationLoader.DevContext> devContext() { return OptionConverters.toJava(underlying.devContext()); }
/** * If an application is loaded in dev mode then this additional context is available. * * @return optional with the value if the application is running in dev mode or empty otherwise. */ public Optional<play.api.ApplicationLoader.DevContext> devContext() { return OptionConverters.toJava(underlying.devContext()); }
public Optional<String> forFileName(String name) { return OptionConverters.toJava(fileMimeTypes.forFileName(name)); }