Search in sources :

Example 91 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class HttpChannelAssociationTest method testIdleTimeoutJustBeforeAssociation.

@Test
public void testIdleTimeoutJustBeforeAssociation() throws Exception {
    startServer(new EmptyServerHandler());
    long idleTimeout = 1000;
    client = new HttpClient(newHttpClientTransport(transport, exchange -> {
        sleep(2 * idleTimeout);
        return true;
    }), sslContextFactory);
    QueuedThreadPool clientThreads = new QueuedThreadPool();
    clientThreads.setName("client");
    client.setExecutor(clientThreads);
    client.setIdleTimeout(idleTimeout);
    client.start();
    CountDownLatch latch = new CountDownLatch(1);
    client.newRequest(newURI()).send(result -> {
        if (result.isSucceeded())
            latch.countDown();
    });
    Assert.assertTrue(latch.await(5 * idleTimeout, TimeUnit.MILLISECONDS));
}
Also used : QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) HttpClient(org.eclipse.jetty.client.HttpClient) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 92 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class HttpClientTest method testClientCannotValidateServerCertificate.

@Test(expected = ExecutionException.class)
public void testClientCannotValidateServerCertificate() throws Exception {
    // Only run this test for transports over TLS.
    Assume.assumeTrue(EnumSet.of(Transport.HTTPS, Transport.H2).contains(transport));
    startServer(new EmptyServerHandler());
    // Use a default SslContextFactory, requests should fail because the server certificate is unknown.
    client = newHttpClient(provideClientTransport(transport), new SslContextFactory());
    QueuedThreadPool clientThreads = new QueuedThreadPool();
    clientThreads.setName("client");
    client.setExecutor(clientThreads);
    client.start();
    client.newRequest(newURI()).timeout(5, TimeUnit.SECONDS).send();
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) Test(org.junit.Test)

Example 93 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class AbstractTest method startServer.

protected void startServer(Handler handler) throws Exception {
    sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath("src/test/resources/keystore.jks");
    sslContextFactory.setKeyStorePassword("storepwd");
    sslContextFactory.setTrustStorePath("src/test/resources/truststore.jks");
    sslContextFactory.setTrustStorePassword("storepwd");
    sslContextFactory.setUseCipherSuitesOrder(true);
    sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
    QueuedThreadPool serverThreads = new QueuedThreadPool();
    serverThreads.setName("server");
    server = new Server(serverThreads);
    connector = newServerConnector(server);
    server.addConnector(connector);
    server.setHandler(handler);
    server.start();
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool)

Example 94 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class FlowControlStalledTest method start.

protected void start(FlowControlStrategy.Factory flowControlFactory, ServerSessionListener listener) throws Exception {
    QueuedThreadPool serverExecutor = new QueuedThreadPool();
    serverExecutor.setName("server");
    server = new Server(serverExecutor);
    RawHTTP2ServerConnectionFactory connectionFactory = new RawHTTP2ServerConnectionFactory(new HttpConfiguration(), listener);
    connectionFactory.setFlowControlStrategyFactory(flowControlFactory);
    connector = new ServerConnector(server, connectionFactory);
    server.addConnector(connector);
    server.start();
    client = new HTTP2Client();
    QueuedThreadPool clientExecutor = new QueuedThreadPool();
    clientExecutor.setName("client");
    client.setExecutor(clientExecutor);
    client.setFlowControlStrategyFactory(flowControlFactory);
    client.start();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) RawHTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 95 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class FlowControlStrategyTest method start.

protected void start(ServerSessionListener listener) throws Exception {
    QueuedThreadPool serverExecutor = new QueuedThreadPool();
    serverExecutor.setName("server");
    server = new Server(serverExecutor);
    RawHTTP2ServerConnectionFactory connectionFactory = new RawHTTP2ServerConnectionFactory(new HttpConfiguration(), listener);
    connectionFactory.setFlowControlStrategyFactory(FlowControlStrategyTest.this::newFlowControlStrategy);
    connector = new ServerConnector(server, connectionFactory);
    server.addConnector(connector);
    server.start();
    client = new HTTP2Client();
    QueuedThreadPool clientExecutor = new QueuedThreadPool();
    clientExecutor.setName("client");
    client.setExecutor(clientExecutor);
    client.setFlowControlStrategyFactory(FlowControlStrategyTest.this::newFlowControlStrategy);
    client.start();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) RawHTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Aggregations

QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)126 Server (org.eclipse.jetty.server.Server)65 ServerConnector (org.eclipse.jetty.server.ServerConnector)51 Test (org.junit.Test)30 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)26 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)23 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)22 HttpClient (org.eclipse.jetty.client.HttpClient)18 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)18 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)18 IOException (java.io.IOException)17 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)11 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)11 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)10 File (java.io.File)9 CountDownLatch (java.util.concurrent.CountDownLatch)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 InputStream (java.io.InputStream)8 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)8