use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.
the class ConnectorFactoryTest method requireThatNoPreBoundChannelWorks.
@Test
public void requireThatNoPreBoundChannelWorks() throws Exception {
Server server = new Server();
try {
ConnectorConfig config = new ConnectorConfig(new ConnectorConfig.Builder());
ConnectorFactory factory = createConnectorFactory(config);
JDiscServerConnector connector = (JDiscServerConnector) factory.createConnector(new DummyMetric(), server, null);
server.addConnector(connector);
server.setHandler(new HelloWorldHandler());
server.start();
SimpleHttpClient client = new SimpleHttpClient(null, connector.getLocalPort(), false);
SimpleHttpClient.RequestExecutor ex = client.newGet("/blaasdfnb");
SimpleHttpClient.ResponseValidator val = ex.execute();
val.expectContent(equalTo("Hello world"));
} finally {
try {
server.stop();
} catch (Exception e) {
// ignore
}
}
}
use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.
the class ConnectorFactoryTest method requireThatPreBoundChannelWorks.
@Test
public void requireThatPreBoundChannelWorks() throws Exception {
Server server = new Server();
try {
ServerSocketChannel serverChannel = ServerSocketChannel.open();
serverChannel.socket().bind(new InetSocketAddress(0));
ConnectorConfig config = new ConnectorConfig(new ConnectorConfig.Builder());
ConnectorFactory factory = createConnectorFactory(config);
JDiscServerConnector connector = (JDiscServerConnector) factory.createConnector(new DummyMetric(), server, serverChannel);
server.addConnector(connector);
server.setHandler(new HelloWorldHandler());
server.start();
SimpleHttpClient client = new SimpleHttpClient(null, connector.getLocalPort(), false);
SimpleHttpClient.RequestExecutor ex = client.newGet("/blaasdfnb");
SimpleHttpClient.ResponseValidator val = ex.execute();
val.expectContent(equalTo("Hello world"));
} finally {
try {
server.stop();
} catch (Exception e) {
// ignore
}
}
}
use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.
the class ConnectorFactoryTest method ssl_jks_config_is_validated.
@Test(expectedExceptions = IllegalArgumentException.class)
public void ssl_jks_config_is_validated() {
ConnectorConfig config = new ConnectorConfig(new ConnectorConfig.Builder().ssl(new Ssl.Builder().enabled(true).keyStoreType(JKS).pemKeyStore(new Ssl.PemKeyStore.Builder().keyPath("nonEmpty"))));
ConnectorFactory willThrowException = createConnectorFactory(config);
}
use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.
the class JettyContainerModelBuilderTest method verify_that_overriding_connector_options_works.
@Test
public void verify_that_overriding_connector_options_works() throws Exception {
Element clusterElem = DomBuilderTest.parse("<jdisc id='default' version='1.0' jetty='true'>\n" + " <http>\n" + " <server id='bananarama' port='4321'>\n" + " <config name='jdisc.http.connector'>\n" + " <requestHeaderSize>300000</requestHeaderSize>\n" + " <headerCacheSize>300000</headerCacheSize>\n" + " </config>\n" + " </server>\n" + " </http>\n" + nodesXml + "</jdisc>\n");
createModel(root, clusterElem);
ConnectorConfig.Builder connectorConfigBuilder = new ConnectorConfig.Builder();
ConnectorConfig cfg = root.getConfig(ConnectorConfig.class, "default/http/jdisc-jetty/bananarama");
assertThat(cfg.requestHeaderSize(), is(300000));
assertThat(cfg.headerCacheSize(), is(300000));
}
use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.
the class JettyContainerModelBuilderTest method verify_that_old_http_config_override_inside_server_tag_works.
@Test
public void verify_that_old_http_config_override_inside_server_tag_works() throws Exception {
Element clusterElem = DomBuilderTest.parse("<jdisc id='default' version='1.0' jetty='true'>", " <http>", " <server port='9000' id='foo'>", " <config name=\"container.jdisc.config.http-server\">", " <tcpKeepAliveEnabled>true</tcpKeepAliveEnabled>", " <tcpNoDelayEnabled>false</tcpNoDelayEnabled>", " <tcpListenBacklogLength>2</tcpListenBacklogLength>", " <idleConnectionTimeout>34.1</idleConnectionTimeout>", " <soLinger>42.2</soLinger>", " <sendBufferSize>1234</sendBufferSize>", " <maxHeaderSize>4321</maxHeaderSize>", " <ssl>", " <enabled>true</enabled>", " <keyStoreType>JKS</keyStoreType>", " <keyStorePath>apple</keyStorePath>", " <trustStorePath>grape</trustStorePath>", " <keyDBKey>tomato</keyDBKey>", " <algorithm>onion</algorithm>", " <protocol>carrot</protocol>", " </ssl>", " </config>", " </server>", " </http>", nodesXml, "</jdisc>");
createModel(root, clusterElem);
ContainerCluster cluster = (ContainerCluster) root.getChildren().get("default");
List<JettyHttpServer> jettyServers = cluster.getChildrenByTypeRecursive(JettyHttpServer.class);
assertThat(jettyServers.size(), is(1));
JettyHttpServer server = jettyServers.get(0);
assertThat(server.model.bundleInstantiationSpec.classId.toString(), is(com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName()));
assertThat(server.model.bundleInstantiationSpec.bundle.toString(), is("jdisc_http_service"));
assertThat(server.getConnectorFactories().size(), is(1));
ConnectorConfig.Builder connectorConfigBuilder = new ConnectorConfig.Builder();
server.getConnectorFactories().get(0).getConfig(connectorConfigBuilder);
ConnectorConfig connector = new ConnectorConfig(connectorConfigBuilder);
assertThat(connector.name(), equalTo("foo"));
assertThat(connector.tcpKeepAliveEnabled(), equalTo(true));
assertThat(connector.tcpNoDelay(), equalTo(false));
assertThat(connector.acceptQueueSize(), equalTo(2));
assertThat(connector.idleTimeout(), equalTo(34.1));
assertThat(connector.soLingerTime(), equalTo(42.2));
assertThat(connector.outputBufferSize(), equalTo(1234));
assertThat(connector.headerCacheSize(), equalTo(4321));
assertThat(connector.ssl().enabled(), equalTo(true));
assertThat(connector.ssl().keyStoreType(), equalTo(KeyStoreType.Enum.JKS));
assertThat(connector.ssl().keyStorePath(), equalTo("apple"));
assertThat(connector.ssl().trustStorePath(), equalTo("grape"));
assertThat(connector.ssl().keyDbKey(), equalTo("tomato"));
assertThat(connector.ssl().sslKeyManagerFactoryAlgorithm(), equalTo("onion"));
assertThat(connector.ssl().protocol(), equalTo("carrot"));
assertThat(extractComponentByClassName(clusterComponentsConfig(), com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName()), is(not(nullValue())));
}
Aggregations