Search in sources :

Example 56 with Connector

use of org.apache.catalina.connector.Connector in project spring-boot by spring-projects.

the class TomcatServletWebServerFactoryTests method tomcatAdditionalConnectors.

@Test
public void tomcatAdditionalConnectors() throws Exception {
    TomcatServletWebServerFactory factory = getFactory();
    Connector[] listeners = new Connector[4];
    for (int i = 0; i < listeners.length; i++) {
        Connector connector = mock(Connector.class);
        given(connector.getState()).willReturn(LifecycleState.STOPPED);
        listeners[i] = connector;
    }
    factory.addAdditionalTomcatConnectors(listeners);
    this.webServer = factory.getWebServer();
    Map<Service, Connector[]> connectors = ((TomcatWebServer) this.webServer).getServiceConnectors();
    assertThat(connectors.values().iterator().next().length).isEqualTo(listeners.length + 1);
}
Also used : Connector(org.apache.catalina.connector.Connector) Service(org.apache.catalina.Service) Test(org.junit.Test)

Example 57 with Connector

use of org.apache.catalina.connector.Connector in project spring-boot by spring-projects.

the class TomcatServletWebServerFactoryTests method sslEnabledMultipleProtocolsConfiguration.

@Test
public void sslEnabledMultipleProtocolsConfiguration() throws Exception {
    Ssl ssl = getSsl(null, "password", "src/test/resources/test.jks");
    ssl.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
    ssl.setCiphers(new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "BRAVO" });
    TomcatServletWebServerFactory factory = getFactory();
    factory.setSsl(ssl);
    this.webServer = factory.getWebServer(sessionServletRegistration());
    this.webServer.start();
    Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat();
    Connector connector = tomcat.getConnector();
    SSLHostConfig sslHostConfig = connector.getProtocolHandler().findSslHostConfigs()[0];
    assertThat(sslHostConfig.getSslProtocol()).isEqualTo("TLS");
    assertThat(sslHostConfig.getEnabledProtocols()).containsExactlyInAnyOrder("TLSv1.1", "TLSv1.2");
}
Also used : Connector(org.apache.catalina.connector.Connector) Tomcat(org.apache.catalina.startup.Tomcat) Ssl(org.springframework.boot.web.server.Ssl) SSLHostConfig(org.apache.tomcat.util.net.SSLHostConfig) Test(org.junit.Test)

Example 58 with Connector

use of org.apache.catalina.connector.Connector in project spring-boot by spring-projects.

the class TomcatWebServer method getPortsDescription.

private String getPortsDescription(boolean localPort) {
    StringBuilder ports = new StringBuilder();
    for (Connector connector : this.tomcat.getService().findConnectors()) {
        ports.append(ports.length() == 0 ? "" : " ");
        int port = (localPort ? connector.getLocalPort() : connector.getPort());
        ports.append(port + " (" + connector.getScheme() + ")");
    }
    return ports.toString();
}
Also used : Connector(org.apache.catalina.connector.Connector)

Example 59 with Connector

use of org.apache.catalina.connector.Connector in project async-http-client by AsyncHttpClient.

the class WebDavBasicTest method setUpGlobal.

@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
    embedded = new Embedded();
    String path = new File(".").getAbsolutePath();
    embedded.setCatalinaHome(path);
    Engine engine = embedded.createEngine();
    engine.setDefaultHost("localhost");
    Host host = embedded.createHost("localhost", path);
    engine.addChild(host);
    Context c = embedded.createContext("/", path);
    c.setReloadable(false);
    Wrapper w = c.createWrapper();
    w.addMapping("/*");
    w.setServletClass(org.apache.catalina.servlets.WebdavServlet.class.getName());
    w.addInitParameter("readonly", "false");
    w.addInitParameter("listings", "true");
    w.setLoadOnStartup(0);
    c.addChild(w);
    host.addChild(c);
    Connector connector = embedded.createConnector("localhost", 0, Http11NioProtocol.class.getName());
    connector.setContainer(host);
    embedded.addEngine(engine);
    embedded.addConnector(connector);
    embedded.start();
    port1 = connector.getLocalPort();
}
Also used : Context(org.apache.catalina.Context) Wrapper(org.apache.catalina.Wrapper) Connector(org.apache.catalina.connector.Connector) Http11NioProtocol(org.apache.coyote.http11.Http11NioProtocol) Host(org.apache.catalina.Host) Embedded(org.apache.catalina.startup.Embedded) File(java.io.File) Engine(org.apache.catalina.Engine) BeforeClass(org.testng.annotations.BeforeClass)

Example 60 with Connector

use of org.apache.catalina.connector.Connector in project tomee by apache.

the class TomcatRsRegistry method address.

private static String address(final Collection<Connector> connectors, final String host, final String path) {
    final List<String> addresses = new ArrayList<>();
    for (final Connector connector : connectors) {
        final URI address;
        try {
            address = new URI(connector.getScheme(), null, host, connector.getPort(), path, null, null);
        } catch (final Exception e) {
            // just an URI problem normally...shouldn't occur
            LOGGER.error("can't add container for path " + path, e);
            continue;
        }
        addresses.add(address.toString());
    }
    return HttpUtil.selectSingleAddress(addresses);
}
Also used : Connector(org.apache.catalina.connector.Connector) ArrayList(java.util.ArrayList) URI(java.net.URI)

Aggregations

Connector (org.apache.catalina.connector.Connector)66 Test (org.junit.Test)16 Service (org.apache.catalina.Service)14 File (java.io.File)10 Tomcat (org.apache.catalina.startup.Tomcat)10 Context (org.apache.catalina.Context)6 Engine (org.apache.catalina.Engine)6 Properties (java.util.Properties)5 StandardService (org.apache.catalina.core.StandardService)5 SSLHostConfig (org.apache.tomcat.util.net.SSLHostConfig)5 IOException (java.io.IOException)4 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 Executor (org.apache.catalina.Executor)4 HashMap (java.util.HashMap)3 ObjectName (javax.management.ObjectName)3 Container (org.apache.catalina.Container)3 LifecycleException (org.apache.catalina.LifecycleException)3 Wrapper (org.apache.catalina.Wrapper)3 InetAddress (java.net.InetAddress)2