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));
}
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();
}
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();
}
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();
}
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();
}
Aggregations