@Test public void shouldAddSSLSocketConnector() throws Exception { ArgumentCaptor<Connector> captor = ArgumentCaptor.forClass(Connector.class); jetty9Server.configure(); verify(server, times(2)).addConnector(captor.capture()); List<Connector> connectors = captor.getAllValues(); Connector sslConnector = connectors.get(1); assertThat(sslConnector instanceof ServerConnector, is(true)); ServerConnector connector = (ServerConnector) sslConnector; assertThat(connector.getServer(), is(server)); assertThat(connector.getConnectionFactories().size(), is(2)); Iterator<ConnectionFactory> iterator = connector.getConnectionFactories().iterator(); ConnectionFactory first = iterator.next(); ConnectionFactory second = iterator.next(); assertThat(first instanceof SslConnectionFactory, is(true)); SslConnectionFactory sslConnectionFactory = (SslConnectionFactory) first; assertThat(sslConnectionFactory.getProtocol(), is("SSL")); assertThat(sslConnectionFactory.getNextProtocol(), is("HTTP/1.1")); assertThat(second instanceof HttpConnectionFactory, is(true)); }
@Override protected void doStart() throws Exception { _shutdown.cancel(); if(_defaultProtocol==null) throw new IllegalStateException("No default protocol for "+this); _defaultConnectionFactory = getConnectionFactory(_defaultProtocol); if(_defaultConnectionFactory==null) throw new IllegalStateException("No protocol factory for default protocol '"+_defaultProtocol+"' in "+this); SslConnectionFactory ssl = getConnectionFactory(SslConnectionFactory.class); if (ssl != null) { String next = ssl.getNextProtocol(); ConnectionFactory cf = getConnectionFactory(next); if (cf == null) throw new IllegalStateException("No protocol factory for SSL next protocol: '" + next + "' in " + this); } _lease = ThreadPoolBudget.leaseFrom(getExecutor(),this,_acceptors.length); super.doStart(); _stopping=new CountDownLatch(_acceptors.length); for (int i = 0; i < _acceptors.length; i++) { Acceptor a = new Acceptor(i); addBean(a); getExecutor().execute(a); } LOG.info("Started {}", this); }