@Override public ContainerBuilder webappRoot(String webappRoot) { containerConfiguration.webappRoot(webappRoot); return this; }
@Override public ContainerBuilder webappRoot(File webappRoot) { containerConfiguration.webappRoot(webappRoot); return this; }
public ContainerConfiguration webappRoot(String webappRoot) { notNull(webappRoot, "Webapp root"); return webappRoot(new File(webappRoot)); }
public File webappRoot() { return settings().webappRoot(); }
private ContainerConfiguration() { port(DEFAULT_PORT); context(DEFAULT_CONTEXT_PATH); webappRoot(DEFAULT_WEBAPP_ROOT); }
public final void start() { if (!isRunning()) { verifyCanListenOnPort(port()); if (!settings().webappRoot().exists() || !settings().webappRoot().canRead()) throw new IllegalStateException("Cannot access webapp root " + settings().webappRoot()); logger.info("Starting container %s on port %s...", getClass().getName(), port()); start(server()); Runtime.getRuntime().addShutdownHook(shutdown); } }
public ContainerConfiguration set(TestatooProperties property, String value) { notNull(property, "Property name"); switch (property) { case CONTEXT: return context(value); case PORT: return port(Integer.parseInt(value)); case SERVER_CLASSPATH: return serverClassPath(value); case WEBAPP_CLASSPATH: return webappClassPath(value); case WEBAPP_ROOT: return webappRoot(value); } return this; }
@Test public void test_toString() throws Exception { System.out.println(ContainerConfiguration.create() .port(9999) .webappRoot("../core/src/test/webapp") .context("superApp")); System.out.println(ContainerConfiguration.create() .port(9999) .webappRoot("../core/src/test/webapp") .context("superApp") .buildContainer(TestatooContainer.JETTY)); }
@Test public void test_jndi() throws Exception { Container container = ContainerConfiguration.create() .port(9999) .webappRoot("../core/src/test/webapp") .context("superApp") .buildContainer(TestatooContainer.JETTY); container.start(); WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse("http://127.0.0.1:9999/superApp/jndi.jsp"); assertEquals(resp.getTitle(), "JNDI Test"); assertThat(resp.getText(), containsString("OK")); container.stop(); }
@Test public void test_jsp() throws Exception { Container container = ContainerConfiguration.create() .port(9999) .webappRoot("../core/src/test/webapp") .context("superApp") .buildContainer(TestatooContainer.JETTY); assertFalse(container.isRunning()); container.start(); assertTrue(container.isRunning()); WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse("http://127.0.0.1:9999/superApp/index.jsp"); assertEquals(resp.getTitle(), "JSP Test"); assertThat(resp.getText(), containsString("Languages")); container.stop(); assertFalse(container.isRunning()); }
@Test public void test_html() throws Exception { Container container = ContainerConfiguration.create() .port(9999) .webappRoot("../core/src/test/webapp") .context("superApp") .buildContainer(TestatooContainer.JETTY); assertFalse(container.isRunning()); container.start(); assertTrue(container.isRunning()); WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse("http://127.0.0.1:9999/superApp/index.xhtml"); assertEquals(resp.getTitle(), "HTML file"); assertThat(resp.getText(), containsString("HTML file")); container.stop(); assertFalse(container.isRunning()); }
@Test public void test_port() throws Exception { Container container = ContainerConfiguration.create() .port(9999) .webappRoot("../core/src/test/webapp") .context("superApp") .set("jetty.conf", "src/test/data/jetty-conf.xml") .set("jetty.trace", "true") .buildContainer(TestatooContainer.JETTY); assertEquals(container.port(), 6837); assertFalse(container.isRunning()); container.start(); assertTrue(container.isRunning()); WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse("http://127.0.0.1:6837/superApp/index.jsp"); assertEquals(resp.getTitle(), "JSP Test"); assertThat(resp.getText(), containsString("Languages")); container.stop(); assertFalse(container.isRunning()); }