Search in sources :

Example 1 with SocketConnector

use of org.mortbay.jetty.bio.SocketConnector in project hudson-2.x by hudson.

the class HudsonTestCase method createWebServer.

/**
     * Prepares a webapp hosting environment to get {@link ServletContext} implementation
     * that we need for testing.
     */
protected ServletContext createWebServer() throws Exception {
    server = new Server();
    WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
    context.setClassLoader(getClass().getClassLoader());
    context.setConfigurations(new Configuration[] { new WebXmlConfiguration(), new NoListenerConfiguration() });
    server.setHandler(context);
    context.setMimeTypes(MIME_TYPES);
    SocketConnector connector = new SocketConnector();
    server.addConnector(connector);
    server.addUserRealm(configureUserRealm());
    server.start();
    localPort = connector.getLocalPort();
    return context.getServletContext();
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) WebXmlConfiguration(org.mortbay.jetty.webapp.WebXmlConfiguration) Server(org.mortbay.jetty.Server) SocketConnector(org.mortbay.jetty.bio.SocketConnector)

Example 2 with SocketConnector

use of org.mortbay.jetty.bio.SocketConnector in project commons by twitter.

the class UrlResolverUtilTest method startServer.

private String startServer() throws Exception {
    final Server server = new Server();
    final SocketConnector connector = new SocketConnector();
    connector.setHost("127.0.0.1");
    connector.setPort(0);
    server.addConnector(connector);
    Context context = new Context(server, "/", Context.NO_SECURITY);
    context.addServlet(new ServletHolder(servlet), "/*");
    server.start();
    addTearDown(new TearDown() {

        @Override
        public void tearDown() throws Exception {
            server.stop();
        }
    });
    return "http://" + connector.getHost() + ":" + connector.getLocalPort() + "/";
}
Also used : Context(org.mortbay.jetty.servlet.Context) TearDown(com.google.common.testing.TearDown) Server(org.mortbay.jetty.Server) ServletHolder(org.mortbay.jetty.servlet.ServletHolder) SocketConnector(org.mortbay.jetty.bio.SocketConnector) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 3 with SocketConnector

use of org.mortbay.jetty.bio.SocketConnector in project nhin-d by DirectProject.

the class ConfigServiceRunner method startConfigService.

public static synchronized void startConfigService() throws Exception {
    if (server == null) {
        /*
			 * Setup the configuration service server
			 */
        server = new Server();
        SocketConnector connector = new SocketConnector();
        HTTPPort = AvailablePortFinder.getNextAvailable(8081);
        connector.setPort(HTTPPort);
        // certificate service
        WebAppContext context = new WebAppContext("src/main/webapp", "/config-service");
        server.setSendServerVersion(false);
        server.addConnector(connector);
        server.addHandler(context);
        server.start();
        serviceURL = "http://localhost:" + HTTPPort + "/";
    }
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server) SocketConnector(org.mortbay.jetty.bio.SocketConnector)

Example 4 with SocketConnector

use of org.mortbay.jetty.bio.SocketConnector in project nhin-d by DirectProject.

the class TxsServiceRunner method startTxsService.

public static synchronized void startTxsService() throws Exception {
    if (server == null) {
        /*
			 * Setup the configuration service server
			 */
        server = new Server();
        SocketConnector connector = new SocketConnector();
        HTTPPort = AvailablePortFinder.getNextAvailable(1024);
        connector.setPort(HTTPPort);
        WebAppContext context = new WebAppContext("src/test/resources/webapp", "/");
        server.setSendServerVersion(false);
        server.addConnector(connector);
        server.addHandler(context);
        server.start();
        txsServiceURL = "http://localhost:" + HTTPPort + "/";
    }
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server) SocketConnector(org.mortbay.jetty.bio.SocketConnector)

Example 5 with SocketConnector

use of org.mortbay.jetty.bio.SocketConnector in project nhin-d by DirectProject.

the class ConfigServiceRunner method startConfigService.

public static synchronized void startConfigService() throws Exception {
    if (server == null) {
        /*
			 * Setup the configuration service server
			 */
        server = new Server();
        SocketConnector connector = new SocketConnector();
        HTTPPort = AvailablePortFinder.getNextAvailable(1024);
        connector.setPort(HTTPPort);
        WebAppContext context = new WebAppContext("src/test/resources/webapp", "/");
        server.setSendServerVersion(false);
        server.addConnector(connector);
        server.addHandler(context);
        server.start();
        configServiceURL = "http://localhost:" + HTTPPort + "/ConfigurationService";
        restAPIBaseURL = "http://localhost:" + HTTPPort + "/api";
    }
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server) SocketConnector(org.mortbay.jetty.bio.SocketConnector)

Aggregations

SocketConnector (org.mortbay.jetty.bio.SocketConnector)15 Server (org.mortbay.jetty.Server)14 WebAppContext (org.mortbay.jetty.webapp.WebAppContext)11 Context (org.mortbay.jetty.servlet.Context)3 ServletHolder (org.mortbay.jetty.servlet.ServletHolder)3 File (java.io.File)2 IOException (java.io.IOException)2 Repository (javax.jcr.Repository)2 Connector (org.mortbay.jetty.Connector)2 TearDown (com.google.common.testing.TearDown)1 ThreadPoolExecutorAdapter (com.google.util.threads.ThreadPoolExecutorAdapter)1 BindException (java.net.BindException)1 ServerSocket (java.net.ServerSocket)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 RepositoryException (javax.jcr.RepositoryException)1 Session (javax.jcr.Session)1 ServletException (javax.servlet.ServletException)1