Search in sources :

Example 46 with LocalConnector

use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.

the class AsyncContextTest method setUp.

@Before
public void setUp() throws Exception {
    _server = new Server();
    _connector = new LocalConnector(_server);
    _connector.setIdleTimeout(5000);
    _connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setSendDateHeader(false);
    _server.addConnector(_connector);
    _contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    _contextHandler.setContextPath("/ctx");
    _contextHandler.addServlet(new ServletHolder(new TestServlet()), "/servletPath");
    _contextHandler.addServlet(new ServletHolder(new TestServlet()), "/path with spaces/servletPath");
    _contextHandler.addServlet(new ServletHolder(new TestServlet2()), "/servletPath2");
    _contextHandler.addServlet(new ServletHolder(new TestStartThrowServlet()), "/startthrow/*");
    _contextHandler.addServlet(new ServletHolder(new ForwardingServlet()), "/forward");
    _contextHandler.addServlet(new ServletHolder(new AsyncDispatchingServlet()), "/dispatchingServlet");
    _contextHandler.addServlet(new ServletHolder(new ExpireServlet()), "/expire/*");
    _contextHandler.addServlet(new ServletHolder(new BadExpireServlet()), "/badexpire/*");
    _contextHandler.addServlet(new ServletHolder(new ErrorServlet()), "/error/*");
    ErrorPageErrorHandler error_handler = new ErrorPageErrorHandler();
    _contextHandler.setErrorHandler(error_handler);
    error_handler.addErrorPage(500, "/error/500");
    error_handler.addErrorPage(IOException.class.getName(), "/error/IOE");
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { _contextHandler, new DefaultHandler() });
    _server.setHandler(handlers);
    _server.start();
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) Server(org.eclipse.jetty.server.Server) LocalConnector(org.eclipse.jetty.server.LocalConnector) IOException(java.io.IOException) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler) Before(org.junit.Before)

Example 47 with LocalConnector

use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.

the class PostServletTest method startServer.

@Before
public void startServer() throws Exception {
    complete = new CountDownLatch(1);
    ex0.set(null);
    ex1.set(null);
    posted.set(false);
    server = new Server();
    connector = new LocalConnector(server);
    server.addConnector(connector);
    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    context.addServlet(BasicReadPostServlet.class, "/post");
    server.setHandler(context);
    server.start();
}
Also used : Server(org.eclipse.jetty.server.Server) LocalConnector(org.eclipse.jetty.server.LocalConnector) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Aggregations

LocalConnector (org.eclipse.jetty.server.LocalConnector)47 Server (org.eclipse.jetty.server.Server)43 Before (org.junit.Before)20 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)13 Test (org.junit.Test)12 Matchers.containsString (org.hamcrest.Matchers.containsString)7 BeforeClass (org.junit.BeforeClass)7 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)6 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)5 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)4 SessionHandler (org.eclipse.jetty.server.session.SessionHandler)4 Password (org.eclipse.jetty.util.security.Password)4 File (java.io.File)3 IOException (java.io.IOException)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ServerConnector (org.eclipse.jetty.server.ServerConnector)3 HandlerList (org.eclipse.jetty.server.handler.HandlerList)3 Path (java.nio.file.Path)2 ServletException (javax.servlet.ServletException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2