use of org.springframework.http.client.reactive.JettyResourceFactory in project spring-boot by spring-projects.
the class ClientHttpConnectorConfigurationTests method jettyClientHttpConnectorAppliesJettyResourceFactory.
@Test
void jettyClientHttpConnectorAppliesJettyResourceFactory() {
Executor executor = mock(Executor.class);
ByteBufferPool byteBufferPool = mock(ByteBufferPool.class);
Scheduler scheduler = mock(Scheduler.class);
JettyResourceFactory jettyResourceFactory = new JettyResourceFactory();
jettyResourceFactory.setExecutor(executor);
jettyResourceFactory.setByteBufferPool(byteBufferPool);
jettyResourceFactory.setScheduler(scheduler);
JettyClientHttpConnector connector = getClientHttpConnector(jettyResourceFactory);
HttpClient httpClient = (HttpClient) ReflectionTestUtils.getField(connector, "httpClient");
assertThat(httpClient.getExecutor()).isSameAs(executor);
assertThat(httpClient.getByteBufferPool()).isSameAs(byteBufferPool);
assertThat(httpClient.getScheduler()).isSameAs(scheduler);
}
use of org.springframework.http.client.reactive.JettyResourceFactory in project spring-boot by spring-projects.
the class ClientHttpConnectorConfigurationTests method JettyResourceFactoryHasSslContextFactory.
@Test
void JettyResourceFactoryHasSslContextFactory() {
// gh-16810
JettyResourceFactory jettyResourceFactory = new JettyResourceFactory();
JettyClientHttpConnector connector = getClientHttpConnector(jettyResourceFactory);
HttpClient httpClient = (HttpClient) ReflectionTestUtils.getField(connector, "httpClient");
assertThat(httpClient.getSslContextFactory()).isNotNull();
}
use of org.springframework.http.client.reactive.JettyResourceFactory in project spring-boot by spring-projects.
the class JettyReactiveWebServerFactory method createConnector.
private AbstractConnector createConnector(InetSocketAddress address, Server server) {
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSendServerVersion(false);
List<ConnectionFactory> connectionFactories = new ArrayList<>();
connectionFactories.add(new HttpConnectionFactory(httpConfiguration));
if (getHttp2() != null && getHttp2().isEnabled()) {
connectionFactories.add(new HTTP2CServerConnectionFactory(httpConfiguration));
}
JettyResourceFactory resourceFactory = getResourceFactory();
ServerConnector connector;
if (resourceFactory != null) {
connector = new ServerConnector(server, resourceFactory.getExecutor(), resourceFactory.getScheduler(), resourceFactory.getByteBufferPool(), this.acceptors, this.selectors, connectionFactories.toArray(new ConnectionFactory[0]));
} else {
connector = new ServerConnector(server, this.acceptors, this.selectors, connectionFactories.toArray(new ConnectionFactory[0]));
}
connector.setHost(address.getHostString());
connector.setPort(address.getPort());
return connector;
}
use of org.springframework.http.client.reactive.JettyResourceFactory in project spring-boot by spring-projects.
the class JettyReactiveWebServerFactoryTests method useServerResources.
@Test
void useServerResources() throws Exception {
JettyResourceFactory resourceFactory = new JettyResourceFactory();
resourceFactory.afterPropertiesSet();
JettyReactiveWebServerFactory factory = getFactory();
factory.setResourceFactory(resourceFactory);
JettyWebServer webServer = (JettyWebServer) factory.getWebServer(new EchoHandler());
webServer.start();
Connector connector = webServer.getServer().getConnectors()[0];
assertThat(connector.getByteBufferPool()).isEqualTo(resourceFactory.getByteBufferPool());
assertThat(connector.getExecutor()).isEqualTo(resourceFactory.getExecutor());
assertThat(connector.getScheduler()).isEqualTo(resourceFactory.getScheduler());
}
Aggregations