use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.
the class TestC3InitialHttpConnections 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());
}
use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.
the class IntegSingleRequest method createHttpClient.
public static Http2Socket createHttpClient(String id, boolean isHttp, InetSocketAddress addr) {
BufferPool pool2 = new BufferCreationPool();
HpackParser hpackParser = HpackParserFactory.createParser(pool2, false);
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, executor2);
InjectionConfig injConfig = new InjectionConfig(hpackParser);
String host = addr.getHostName();
int port = addr.getPort();
ForTestSslClientEngineFactory ssl = new ForTestSslClientEngineFactory();
SSLEngine engine = ssl.createSslEngine(host, port);
Http2Client client = Http2ClientFactory.createHttpClient(mgr, injConfig);
Http2Socket socket;
if (isHttp) {
socket = client.createHttpSocket(id);
} else {
socket = client.createHttpsSocket(id, engine);
}
return socket;
}
use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.
the class AbstractHttp2Test method setUp.
@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
MockTcpServerChannel svrChannel = new MockTcpServerChannel();
mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
mockTcpChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockTcpChannel));
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();
simulateClientSendingPrefaceAndSettings();
}
use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.
the class HttpFrontendFactory method createFrontEnd.
/**
*
* @param id Use for logging and also file recording names
* @param threadPoolSize The size of the threadpool, although all data comes in order as we
* use the SessionExecutorImpl found in webpieces
*
* @return
*/
public static HttpFrontendManager createFrontEnd(String id, int threadPoolSize, ScheduledExecutorService timer, BufferPool pool) {
Executor executor = Executors.newFixedThreadPool(threadPoolSize, new NamedThreadFactory(id));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager chanMgr = factory.createMultiThreadedChanMgr(id, pool, executor);
AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(chanMgr);
HttpParser httpParser = HttpParserFactory.createParser(pool);
HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
InjectionConfig injConfig = new InjectionConfig(http2Parser, new TimeImpl(), new Http2Config());
Http2ServerEngineFactory svrEngineFactory = new Http2ServerEngineFactory(injConfig);
return new FrontEndServerManagerImpl(svrMgr, timer, svrEngineFactory, httpParser);
}
use of com.webpieces.http2engine.api.client.InjectionConfig in project webpieces by deanhiller.
the class TestS3InitialHttpConnections method setUp.
@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
MockTcpServerChannel svrChannel = new MockTcpServerChannel();
mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
mockTcpChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockTcpChannel));
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();
ConnectionListener listener = mockChanMgr.getSingleConnectionListener();
CompletableFuture<DataListener> futureList = listener.connected(mockTcpChannel, true);
DataListener dataListener = futureList.get(3, TimeUnit.SECONDS);
mockChannel.setDataListener(dataListener);
}
Aggregations