NinjaJetty extends AbstractStandalone<NinjaJetty> { public NinjaJetty jettyConfiguration(String jettyConfiguration) { this.jettyConfiguration = jettyConfiguration; return this; } NinjaJetty(); static void main(String [] args); @Override void doStart(); @Override void doJoin(); @Override void doShutdown(); String getJettyConfigureation(); NinjaJetty jettyConfiguration(String jettyConfiguration); @Override Injector getInjector(); static final public String KEY_NINJA_JETTY_CONFIGURATION; static final public String DEFAULT_JETTY_CONFIGURATION; }
@Test public void jettyConfiguration() throws Exception { String jettyConfiguration = createJettyConfiguration("jetty.xml", RANDOM_PORT); NinjaJetty standalone = new NinjaJetty() .externalConfigurationPath("conf/jetty.com.example.conf") .jettyConfiguration(jettyConfiguration); try { standalone.start(); assertThat(standalone.ninjaServletListener, is(not(nullValue()))); assertThat(standalone.contextHandler.isAvailable(), is(true)); assertThat(standalone.contextHandler.isStarted(), is(true)); assertThat(standalone.jetty.isStarted(), is(true)); String page = get("http: assertThat(page, containsString("Hello World!")); } finally { standalone.shutdown(); } }
@Test public void jettyConfigurationWithContext() throws Exception { String jettyConfiguration = createJettyConfiguration("jetty.xml", RANDOM_PORT); NinjaJetty standalone = new NinjaJetty() .externalConfigurationPath("conf/jetty.com.example.conf") .contextPath("/mycontext") .jettyConfiguration(jettyConfiguration); try { standalone.start(); assertThat(standalone.ninjaServletListener, is(not(nullValue()))); assertThat(standalone.contextHandler.isAvailable(), is(true)); assertThat(standalone.contextHandler.isStarted(), is(true)); assertThat(standalone.jetty.isStarted(), is(true)); String page; page = get("http: assertThat(page, containsString("Hello World!")); page = get("http: assertThat(page, containsString("/mycontext")); page = get("http: assertThat(page, containsString("/request_path")); assertThat(standalone.getPort(), is(RANDOM_PORT)); } finally { standalone.shutdown(); } }