Search in sources :

Example 6 with InjectionConfig

use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.

the class AbstractHttp1Test method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    MockTcpServerChannel svrChannel = new MockTcpServerChannel();
    mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
    mockChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockChannel));
    mockListener.setDefaultRetVal(mockStreamWriter);
    mockStreamWriter.setDefaultRetValToThis();
    Http2Config config = new Http2Config();
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    FrontendConfig frontendConfig = new FrontendConfig("http", new InetSocketAddress("me", 8080));
    HttpFrontendManager manager = HttpFrontendFactory.createFrontEnd(mockChanMgr, mockTimer, injConfig);
    HttpServer httpServer = manager.createHttpServer(frontendConfig, mockListener);
    httpServer.start();
    simulateClientConnecting();
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) HttpServer(org.webpieces.frontend2.api.HttpServer) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) MockTcpServerChannel(org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel) Before(org.junit.Before)

Example 7 with InjectionConfig

use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.

the class TestC3InitialHttpsConnections method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException {
    mockChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockChannel));
    Http2Config config = new Http2Config();
    //start with 1 max concurrent
    config.setInitialRemoteMaxConcurrent(1);
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    Http2Client client = Http2ClientFactory.createHttpClient(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("simple", engine);
    CompletableFuture<Http2Socket> connect = socket.connect(addr);
    Assert.assertTrue(connect.isDone());
    Assert.assertEquals(socket, connect.get());
    //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) ForTestSslClientEngineFactory(org.webpieces.http2client.integ.ForTestSslClientEngineFactory) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) Http2Msg(com.webpieces.http2parser.api.dto.lib.Http2Msg) Http2Config(com.webpieces.http2engine.api.client.Http2Config) Http2Socket(org.webpieces.http2client.api.Http2Socket) Preface(org.webpieces.http2client.mock.Preface) Http2Client(org.webpieces.http2client.api.Http2Client) Before(org.junit.Before)

Example 8 with InjectionConfig

use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.

the class TestC6_5SettingsFrameErrors method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException {
    mockChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockChannel));
    Http2Config config = new Http2Config();
    //start with 1 max concurrent
    config.setInitialRemoteMaxConcurrent(1);
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    Http2Client client = Http2ClientFactory.createHttpClient(mockChanMgr, injConfig);
    mockChanMgr.addTCPChannelToReturn(mockChannel);
    socket = client.createHttpSocket("simple");
    CompletableFuture<Http2Socket> connect = socket.connect(new InetSocketAddress(555));
    Assert.assertTrue(connect.isDone());
    Assert.assertEquals(socket, connect.get());
    //clear preface and settings frame from client
    mockChannel.getFramesAndClear();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) Http2Socket(org.webpieces.http2client.api.Http2Socket) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) Http2Client(org.webpieces.http2client.api.Http2Client) Before(org.junit.Before)

Example 9 with InjectionConfig

use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.

the class Http2ClientFactory method createHttpClient.

public static Http2Client createHttpClient(int numThreads) {
    Http2Config config = new Http2Config();
    Executor executor = Executors.newFixedThreadPool(numThreads, new NamedThreadFactory("httpclient"));
    BufferCreationPool pool = new BufferCreationPool();
    HpackParser hpackParser = HpackParserFactory.createParser(pool, false);
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, executor);
    InjectionConfig injConfig = new InjectionConfig(hpackParser, new TimeImpl(), config);
    return createHttpClient(mgr, injConfig);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) Http2Config(com.webpieces.http2engine.api.client.Http2Config) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) TimeImpl(com.webpieces.util.time.TimeImpl)

Example 10 with InjectionConfig

use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.

the class Http2ClientFactory method createHttpClient.

public static Http2Client createHttpClient(Http2Config config, ChannelManager mgr, Executor executor, Time time) {
    BufferCreationPool pool = new BufferCreationPool();
    HpackParser hpackParser = HpackParserFactory.createParser(pool, false);
    InjectionConfig injConfig = new InjectionConfig(hpackParser, time, config);
    return createHttpClient(mgr, injConfig);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) BufferCreationPool(org.webpieces.data.api.BufferCreationPool)

Aggregations

InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)12 Http2Config (com.webpieces.http2engine.api.client.Http2Config)9 InetSocketAddress (java.net.InetSocketAddress)7 Before (org.junit.Before)7 HpackParser (com.webpieces.hpack.api.HpackParser)5 Http2Client (org.webpieces.http2client.api.Http2Client)5 Http2Socket (org.webpieces.http2client.api.Http2Socket)5 Executor (java.util.concurrent.Executor)3 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)3 FrontendConfig (org.webpieces.frontend2.api.FrontendConfig)3 HttpFrontendManager (org.webpieces.frontend2.api.HttpFrontendManager)3 HttpServer (org.webpieces.frontend2.api.HttpServer)3 MockTcpServerChannel (org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel)3 ChannelManager (org.webpieces.nio.api.ChannelManager)3 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)3 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)3 TimeImpl (com.webpieces.util.time.TimeImpl)2 SSLEngine (javax.net.ssl.SSLEngine)2 HttpParser (org.webpieces.httpparser.api.HttpParser)2 Provides (com.google.inject.Provides)1