Search in sources :

Example 11 with Http2Client

use of org.webpieces.http2client.api.Http2Client 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

Http2Client (org.webpieces.http2client.api.Http2Client)11 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)7 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)7 Http2Config (com.webpieces.http2engine.api.client.Http2Config)5 InetSocketAddress (java.net.InetSocketAddress)5 Before (org.junit.Before)5 SSLEngine (javax.net.ssl.SSLEngine)3 TwoPools (org.webpieces.data.api.TwoPools)3 Http2Socket (org.webpieces.http2client.api.Http2Socket)3 BackpressureConfig (org.webpieces.nio.api.BackpressureConfig)3 ChannelManager (org.webpieces.nio.api.ChannelManager)3 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)3 HpackParser (com.webpieces.hpack.api.HpackParser)2 Executor (java.util.concurrent.Executor)2 BufferPool (org.webpieces.data.api.BufferPool)2 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)2 Injector (com.google.inject.Injector)1 Provides (com.google.inject.Provides)1 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)1 IOException (java.io.IOException)1