Search in sources :

Example 1 with ForTestSslClientEngineFactory

use of org.webpieces.http2client.integ.ForTestSslClientEngineFactory in project webpieces by deanhiller.

the class TestC3InitialHttpsConnections method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    mockChannel.setIncomingFrameDefaultReturnValue(XFuture.completedFuture(null));
    Http2Config config = new Http2Config();
    // start with 1 max concurrent
    config.setInitialRemoteMaxConcurrent(1);
    config.setLocalSettings(localSettings);
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    InjectionConfig injConfig = new InjectionConfig(mockTime, config, metrics);
    Http2Client client = Http2ClientFactory.createHttpClient("test2Client", mockChanMgr, injConfig);
    mockChanMgr.addSSLChannelToReturn(mockChannel);
    InetSocketAddress addr = new InetSocketAddress("somehost.com", 555);
    String host = addr.getHostName();
    int port = addr.getPort();
    ForTestSslClientEngineFactory ssl = new ForTestSslClientEngineFactory();
    SSLEngine engine = ssl.createSslEngine(host, port);
    socket = client.createHttpsSocket(engine, new SocketListener());
    XFuture<Void> connect = socket.connect(addr);
    connect.get(2, TimeUnit.SECONDS);
    // verify settings on connect were sent
    // verify settings on connect were sent
    List<Http2Msg> frames = mockChannel.getFramesAndClear();
    Preface preface = (Preface) frames.get(0);
    preface.verify();
    Http2Msg settings1 = frames.get(1);
    Assert.assertEquals(HeaderSettings.createSettingsFrame(localSettings), settings1);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) SSLEngine(javax.net.ssl.SSLEngine) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) ForTestSslClientEngineFactory(org.webpieces.http2client.integ.ForTestSslClientEngineFactory) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg) Http2Config(com.webpieces.http2engine.api.client.Http2Config) Preface(org.webpieces.http2client.mock.Preface) Http2Client(org.webpieces.http2client.api.Http2Client) Before(org.junit.Before)

Aggregations

Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)1 Http2Config (com.webpieces.http2engine.api.client.Http2Config)1 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 InetSocketAddress (java.net.InetSocketAddress)1 SSLEngine (javax.net.ssl.SSLEngine)1 Before (org.junit.Before)1 Http2Client (org.webpieces.http2client.api.Http2Client)1 ForTestSslClientEngineFactory (org.webpieces.http2client.integ.ForTestSslClientEngineFactory)1 Preface (org.webpieces.http2client.mock.Preface)1