use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.
the class JettyBootstrapTest method do02SslStaticWarTest.
@Test
public void do02SslStaticWarTest() throws IllegalStateException, IOException, JettyBootstrapException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, URISyntaxException {
File file = temporaryFolder.newFile();
copyResourceToFile("/static.war", file);
JettyBootstrap jettyBootstrap = initServer(true);
jettyBootstrap.addWarApp(file.getPath(), "/sslStaticWar");
jettyBootstrap.startServer();
Assert.assertEquals(new SimpleResponse(200, "test1content\n"), get("/sslStaticWar/test1.html"));
Assert.assertEquals(new SimpleResponse(200, "test2content\n"), get("/sslStaticWar/test2.html"));
Assert.assertEquals(new Integer(404), get("/test3.html").getStatusCode());
}
use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.
the class JettyBootstrapTest method do19HandlerTest.
@Test
public void do19HandlerTest() throws IllegalStateException, IOException, JettyBootstrapException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/handler");
context.addServlet(new ServletHolder(new TestServlet()), "/*");
JettyBootstrap jettyBootstrap = initServer(false);
jettyBootstrap.addHandler(context);
jettyBootstrap.startServer();
Assert.assertEquals(new SimpleResponse(200, "ServletTestContent" + LINE_SEPARATOR), get("/handler"));
}
use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.
the class Main method main.
/**
* @param args
* each argument is a web application (war file, directory).
* @throws JettyBootstrapException
* on failure
*/
public static void main(String[] args) throws JettyBootstrapException {
if (args.length == 0) {
LOG.warn("Nothing to deploy, Exiting...");
} else {
JettyBootstrap jettyBootstrap = new JettyBootstrap();
for (String arg : args) {
File file = new File(arg);
if (!file.exists()) {
LOG.warn("File [{}] doesn't exists. Ignore application", file);
} else {
String fileName;
if (file.isFile() && file.getName().toLowerCase().endsWith(WAR_FILE_SUFFIX)) {
fileName = file.getName().substring(0, file.getName().length() - WAR_FILE_SUFFIX.length());
} else {
fileName = file.getName();
}
String contextPath = "/";
if (!fileName.equals("ROOT")) {
contextPath += fileName;
}
if (file.isDirectory()) {
LOG.debug("[{}] exists and is a directory. Adding Exploded War Application...", file);
jettyBootstrap.addExplodedWarApp(file.getPath(), null, contextPath);
} else {
if (file.isFile() && file.getName().toLowerCase().endsWith(".war")) {
LOG.debug("[{}] exists and is a war file. Add War Application...", file);
jettyBootstrap.addWarApp(file.getPath(), contextPath);
} else {
LOG.warn("[{}] exists but is an unknown file. Ignore application", file);
}
}
}
}
jettyBootstrap.startServer();
}
}
use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.
the class JettyBootstrapTest method do01StaticWarTest.
@Test
public void do01StaticWarTest() throws IllegalStateException, IOException, JettyBootstrapException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, URISyntaxException {
File file = temporaryFolder.newFile();
copyResourceToFile("/static.war", file);
JettyBootstrap jettyBootstrap = initServer(false);
jettyBootstrap.addWarApp(file.getPath(), "/staticWar");
jettyBootstrap.startServer();
Assert.assertEquals(new SimpleResponse(200, "test1content\n"), get("/staticWar/test1.html"));
Assert.assertEquals(new SimpleResponse(200, "test2content\n"), get("/staticWar/test2.html"));
Assert.assertEquals(new Integer(404), get("/test3.html").getStatusCode());
}
use of org.teknux.jettybootstrap.JettyBootstrap in project jetty-bootstrap by teknux-org.
the class JettyBootstrapTest method do04SslServletWarTest.
@Test
public void do04SslServletWarTest() throws IllegalStateException, IOException, JettyBootstrapException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, URISyntaxException {
File file = temporaryFolder.newFile();
copyResourceToFile("/servlet.war", file);
JettyBootstrap jettyBootstrap = initServer(true);
jettyBootstrap.addWarApp(file.getPath(), "/sslServletWar");
jettyBootstrap.startServer();
Assert.assertEquals(new SimpleResponse(200, "Value=value1" + LINE_SEPARATOR), get("/sslServletWar?value=value1"));
Assert.assertEquals(new SimpleResponse(200, "Value=value2" + LINE_SEPARATOR), get("/sslServletWar?value=value2"));
}
Aggregations