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);
}
Aggregations