Search in sources :

Example 11 with ContextHandler

use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.

the class ConstraintTest method startServer.

@Before
public void startServer() {
    _server = new Server();
    _connector = new LocalConnector(_server);
    _config = _connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
    _server.setConnectors(new Connector[] { _connector });
    ContextHandler _context = new ContextHandler();
    SessionHandler _session = new SessionHandler();
    TestLoginService _loginService = new TestLoginService(TEST_REALM);
    _loginService.putUser("user0", new Password("password"), new String[] {});
    _loginService.putUser("user", new Password("password"), new String[] { "user" });
    _loginService.putUser("user2", new Password("password"), new String[] { "user" });
    _loginService.putUser("admin", new Password("password"), new String[] { "user", "administrator" });
    _loginService.putUser("user3", new Password("password"), new String[] { "foo" });
    _context.setContextPath("/ctx");
    _server.setHandler(_context);
    _context.setHandler(_session);
    _server.addBean(_loginService);
    _security = new ConstraintSecurityHandler();
    _session.setHandler(_security);
    RequestHandler _handler = new RequestHandler();
    _security.setHandler(_handler);
    _security.setConstraintMappings(getConstraintMappings(), getKnownRoles());
}
Also used : ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) SessionHandler(org.eclipse.jetty.server.session.SessionHandler) Server(org.eclipse.jetty.server.Server) LocalConnector(org.eclipse.jetty.server.LocalConnector) Password(org.eclipse.jetty.util.security.Password) Before(org.junit.Before)

Example 12 with ContextHandler

use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.

the class CookiesTest method startServer.

protected void startServer(Handler handler) throws Exception {
    server = new Server();
    connector = new ServerConnector(server);
    server.addConnector(connector);
    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setHandler(handler);
    server.setHandler(context);
    server.start();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Server(org.eclipse.jetty.server.Server)

Example 13 with ContextHandler

use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.

the class MisbehavingClassTest method startServer.

@SuppressWarnings("Duplicates")
@BeforeClass
public static void startServer() throws Exception {
    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    server.addConnector(connector);
    handler = new EchoHandler();
    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setHandler(handler);
    server.setHandler(context);
    // Start Server
    server.start();
    String host = connector.getHost();
    if (host == null) {
        host = "localhost";
    }
    int port = connector.getLocalPort();
    serverUri = new URI(String.format("ws://%s:%d/", host, port));
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Server(org.eclipse.jetty.server.Server) EchoHandler(org.eclipse.jetty.websocket.jsr356.EchoHandler) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Example 14 with ContextHandler

use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.

the class AnnotatedEchoTest method startServer.

@SuppressWarnings("Duplicates")
@BeforeClass
public static void startServer() throws Exception {
    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    server.addConnector(connector);
    handler = new EchoHandler();
    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setHandler(handler);
    server.setHandler(context);
    // Start Server
    server.start();
    String host = connector.getHost();
    if (host == null) {
        host = "localhost";
    }
    int port = connector.getLocalPort();
    serverUri = new URI(String.format("ws://%s:%d/", host, port));
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Server(org.eclipse.jetty.server.Server) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Example 15 with ContextHandler

use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.

the class ConfiguratorTest method startServer.

@BeforeClass
public static void startServer() throws Exception {
    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    server.addConnector(connector);
    handler = new EchoHandler();
    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setHandler(handler);
    server.setHandler(context);
    // Start Server
    server.start();
    String host = connector.getHost();
    if (host == null) {
        host = "localhost";
    }
    int port = connector.getLocalPort();
    serverUri = new URI(String.format("ws://%s:%d/", host, port));
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Server(org.eclipse.jetty.server.Server) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Aggregations

ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)127 Server (org.eclipse.jetty.server.Server)47 ServerConnector (org.eclipse.jetty.server.ServerConnector)27 URI (java.net.URI)21 ResourceHandler (org.eclipse.jetty.server.handler.ResourceHandler)20 Test (org.junit.Test)20 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)19 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)19 IOException (java.io.IOException)18 Handler (org.eclipse.jetty.server.Handler)14 HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)14 SessionHandler (org.eclipse.jetty.server.session.SessionHandler)14 File (java.io.File)13 ServletException (javax.servlet.ServletException)13 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)13 BeforeClass (org.junit.BeforeClass)11 BaseIntegrationTest (com.ctrip.framework.apollo.BaseIntegrationTest)10 Config (com.ctrip.framework.apollo.Config)10 ApolloConfig (com.ctrip.framework.apollo.core.dto.ApolloConfig)10 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)10