Search in sources :

Example 1 with RequestServlet

use of org.apache.deltaspike.cdise.servlet.test.content.RequestServlet in project deltaspike by apache.

the class JettyTest method createServer.

@Override
protected int createServer() throws Exception {
    int port = super.getPort();
    server = new Server(port);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);
    context.addEventListener(new CdiServletRequestListener());
    context.addServlet(new ServletHolder(new RequestServlet()), "/*");
    server.start();
    return port;
}
Also used : Server(org.eclipse.jetty.server.Server) CdiServletRequestListener(org.apache.deltaspike.cdise.servlet.CdiServletRequestListener) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) RequestServlet(org.apache.deltaspike.cdise.servlet.test.content.RequestServlet)

Example 2 with RequestServlet

use of org.apache.deltaspike.cdise.servlet.test.content.RequestServlet in project deltaspike by apache.

the class TomcatTest method createServer.

@Override
protected int createServer() throws Exception {
    String baseDir = "target/webapp-runner";
    tomcat = new Tomcat();
    int port = super.getPort();
    tomcat.setPort(port);
    File base = new File(baseDir);
    if (!base.exists()) {
        base.mkdirs();
    }
    tomcat.setBaseDir(baseDir);
    Context ctx = tomcat.addContext("/", base.getAbsolutePath());
    StandardContext standardContext = (StandardContext) ctx;
    standardContext.addApplicationListener(CdiServletContextListener.class.getName());
    Wrapper wrapper = Tomcat.addServlet(ctx, "RequestServlet", RequestServlet.class.getName());
    wrapper.addMapping("/*");
    tomcat.start();
    return port;
}
Also used : Context(org.apache.catalina.Context) StandardContext(org.apache.catalina.core.StandardContext) Wrapper(org.apache.catalina.Wrapper) Tomcat(org.apache.catalina.startup.Tomcat) CdiServletContextListener(org.apache.deltaspike.cdise.servlet.CdiServletContextListener) StandardContext(org.apache.catalina.core.StandardContext) File(java.io.File) RequestServlet(org.apache.deltaspike.cdise.servlet.test.content.RequestServlet)

Aggregations

RequestServlet (org.apache.deltaspike.cdise.servlet.test.content.RequestServlet)2 File (java.io.File)1 Context (org.apache.catalina.Context)1 Wrapper (org.apache.catalina.Wrapper)1 StandardContext (org.apache.catalina.core.StandardContext)1 Tomcat (org.apache.catalina.startup.Tomcat)1 CdiServletContextListener (org.apache.deltaspike.cdise.servlet.CdiServletContextListener)1 CdiServletRequestListener (org.apache.deltaspike.cdise.servlet.CdiServletRequestListener)1 Server (org.eclipse.jetty.server.Server)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1