Search in sources :

Example 16 with LocalConnector

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

the class AsyncListenerTest method startServer.

public void startServer(ServletContextHandler context) throws Exception {
    server = threadPool == null ? new Server() : new Server(threadPool);
    connector = new LocalConnector(server);
    connector.setIdleTimeout(20 * 60 * 1000L);
    server.addConnector(connector);
    server.setHandler(context);
    server.start();
}
Also used : Server(org.eclipse.jetty.server.Server) LocalConnector(org.eclipse.jetty.server.LocalConnector)

Example 17 with LocalConnector

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

the class InvokerTest method init.

@Before
public void init() throws Exception {
    _server = new Server();
    _connector = new LocalConnector(_server);
    _connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendServerVersion(false);
    _connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendDateHeader(false);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    _server.addConnector(_connector);
    _server.setHandler(context);
    context.setContextPath("/");
    ServletHolder holder = context.addServlet(Invoker.class, "/servlet/*");
    holder.setInitParameter("nonContextServlets", "true");
    _server.start();
}
Also used : Server(org.eclipse.jetty.server.Server) LocalConnector(org.eclipse.jetty.server.LocalConnector) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) Before(org.junit.Before)

Example 18 with LocalConnector

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

the class DispatcherTest method init.

@Before
public void init() throws Exception {
    _server = new Server();
    _connector = new LocalConnector(_server);
    _connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendServerVersion(false);
    _connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendDateHeader(false);
    _contextCollection = new ContextHandlerCollection();
    _contextHandler = new ServletContextHandler();
    _contextHandler.setContextPath("/context");
    _contextCollection.addHandler(_contextHandler);
    _resourceHandler = new ResourceHandler();
    _resourceHandler.setResourceBase(MavenTestingUtils.getTestResourceDir("dispatchResourceTest").getAbsolutePath());
    _resourceHandler.setPathInfoOnly(true);
    ContextHandler resourceContextHandler = new ContextHandler("/resource");
    resourceContextHandler.setHandler(_resourceHandler);
    _contextCollection.addHandler(resourceContextHandler);
    _server.setHandler(_contextCollection);
    _server.addConnector(_connector);
    _server.start();
}
Also used : ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Server(org.eclipse.jetty.server.Server) LocalConnector(org.eclipse.jetty.server.LocalConnector) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) ResourceHandler(org.eclipse.jetty.server.handler.ResourceHandler) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) Before(org.junit.Before)

Example 19 with LocalConnector

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

the class EncodedURITest method init.

@Before
public void init() throws Exception {
    _server = new Server();
    _connector = new LocalConnector(_server);
    _connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendServerVersion(false);
    _connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendDateHeader(false);
    _server.addConnector(_connector);
    _contextCollection = new ContextHandlerCollection();
    _server.setHandler(_contextCollection);
    _context0 = new ServletContextHandler();
    _context0.setContextPath("/context path");
    _contextCollection.addHandler(_context0);
    _context0.addFilter(AsyncFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    _context0.addServlet(TestServlet.class, "/test servlet/*");
    _context0.addServlet(AsyncServlet.class, "/async servlet/*");
    _context1 = new ServletContextHandler();
    _context1.setContextPath("/redirecting context");
    _contextCollection.addHandler(_context1);
    _server.start();
}
Also used : Server(org.eclipse.jetty.server.Server) LocalConnector(org.eclipse.jetty.server.LocalConnector) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) Before(org.junit.Before)

Example 20 with LocalConnector

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

the class GzipHandlerTest method init.

@Before
public void init() throws Exception {
    _server = new Server();
    _connector = new LocalConnector(_server);
    _server.addConnector(_connector);
    GzipHandler gzipHandler = new GzipHandler();
    gzipHandler.setExcludedAgentPatterns();
    gzipHandler.setMinGzipSize(16);
    gzipHandler.setInflateBufferSize(4096);
    ServletContextHandler context = new ServletContextHandler(gzipHandler, "/ctx");
    ServletHandler servlets = context.getServletHandler();
    _server.setHandler(gzipHandler);
    gzipHandler.setHandler(context);
    servlets.addServletWithMapping(MicroServlet.class, "/micro");
    servlets.addServletWithMapping(MicroChunkedServlet.class, "/microchunked");
    servlets.addServletWithMapping(TestServlet.class, "/content");
    servlets.addServletWithMapping(ForwardServlet.class, "/forward");
    servlets.addServletWithMapping(IncludeServlet.class, "/include");
    servlets.addServletWithMapping(EchoServlet.class, "/echo/*");
    _server.start();
}
Also used : Server(org.eclipse.jetty.server.Server) GzipHandler(org.eclipse.jetty.server.handler.gzip.GzipHandler) LocalConnector(org.eclipse.jetty.server.LocalConnector) 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