Search in sources :

Example 1 with JettyBootstrap

use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.

the class JettyBootstrapErrorsTest method missingServletWarFromClasspathTest.

@Test(expected = JettyBootstrapException.class)
public void missingServletWarFromClasspathTest() throws IllegalStateException, IOException, JettyBootstrapException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
    // will throw JettyBootstrapException because war is not in classpath
    JettyBootstrap jettyBootstrap = initServer(false);
    jettyBootstrap.addWarAppFromClasspath("/servlet-missing.war", "/servletWarFromClasspath-missing");
    jettyBootstrap.startServer();
}
Also used : JettyBootstrap(org.teknux.jettybootstrap.JettyBootstrap) Test(org.junit.Test)

Example 2 with JettyBootstrap

use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.

the class JettyBootstrapErrorsTest method missingStaticWarTest.

@Test(expected = JettyBootstrapException.class)
public void missingStaticWarTest() throws IllegalStateException, IOException, JettyBootstrapException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, URISyntaxException {
    JettyBootstrap jettyBootstrap = initServer(false);
    jettyBootstrap.addWarApp("Missing", "/staticWar");
    jettyBootstrap.startServer();
}
Also used : JettyBootstrap(org.teknux.jettybootstrap.JettyBootstrap) Test(org.junit.Test)

Example 3 with JettyBootstrap

use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.

the class AbstractJettyBootstrapTest method initServer.

protected JettyBootstrap initServer(boolean ssl) throws JettyBootstrapException, IOException {
    JettyConfiguration jettyConfiguration = new JettyConfiguration();
    jettyConfiguration.setStopAtShutdown(false);
    jettyConfiguration.setAutoJoinOnStart(false);
    jettyConfiguration.setTempDirectory(temporaryFolder.newFolder());
    jettyConfiguration.setCleanTempDir(true);
    jettyConfiguration.setPersistAppTempDirectories(false);
    jettyConfiguration.setHost(HOST);
    if (ssl) {
        jettyConfiguration.setJettyConnectors(JettyConnector.HTTPS);
        jettyConfiguration.setSslPort(SSL_PORT);
    } else {
        jettyConfiguration.setJettyConnectors(JettyConnector.HTTP);
        jettyConfiguration.setPort(PORT);
    }
    this.ssl = ssl;
    this.jettyBootstrap = new JettyBootstrap(jettyConfiguration);
    return this.jettyBootstrap;
}
Also used : JettyConfiguration(org.teknux.jettybootstrap.configuration.JettyConfiguration) JettyBootstrap(org.teknux.jettybootstrap.JettyBootstrap)

Example 4 with JettyBootstrap

use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.

the class JettyBootstrapTest method do06SslStaticWarFromClasspathTest.

@Test
public void do06SslStaticWarFromClasspathTest() throws IllegalStateException, IOException, JettyBootstrapException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
    JettyBootstrap jettyBootstrap = initServer(true);
    jettyBootstrap.addWarAppFromClasspath("/static.war", "/sslStaticWarFromClasspath");
    jettyBootstrap.startServer();
    Assert.assertEquals(new SimpleResponse(200, "test1content\n"), get("/sslStaticWarFromClasspath/test1.html"));
    Assert.assertEquals(new SimpleResponse(200, "test2content\n"), get("/sslStaticWarFromClasspath/test2.html"));
    Assert.assertEquals(new Integer(404), get("/test3.html").getStatusCode());
}
Also used : JettyBootstrap(org.teknux.jettybootstrap.JettyBootstrap) Test(org.junit.Test)

Example 5 with JettyBootstrap

use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.

the class JettyBootstrapTest method do08SslServletWarFromClasspathTest.

@Test
public void do08SslServletWarFromClasspathTest() throws IllegalStateException, IOException, JettyBootstrapException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
    JettyBootstrap jettyBootstrap = initServer(true);
    jettyBootstrap.addWarAppFromClasspath("/servlet.war", "/sslServletWarFromClasspath");
    jettyBootstrap.startServer();
    Assert.assertEquals(new SimpleResponse(200, "Value=value1" + LINE_SEPARATOR), get("/sslServletWarFromClasspath?value=value1"));
    Assert.assertEquals(new SimpleResponse(200, "Value=value2" + LINE_SEPARATOR), get("/sslServletWarFromClasspath?value=value2"));
}
Also used : JettyBootstrap(org.teknux.jettybootstrap.JettyBootstrap) Test(org.junit.Test)

Aggregations

JettyBootstrap (org.teknux.jettybootstrap.JettyBootstrap)24 Test (org.junit.Test)22 File (java.io.File)9 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 JettyConfiguration (org.teknux.jettybootstrap.configuration.JettyConfiguration)1