public NiftyClient(NettyClientConfig nettyClientConfig, boolean local) { this.nettyClientConfig = nettyClientConfig; if (local) { log.warn("Using local client"); this.channelFactory = new DefaultLocalClientChannelFactory(); this.timer = null; this.bossExecutor = null; this.workerExecutor = null; this.defaultSocksProxyAddress = null; } else { this.timer = nettyClientConfig.getTimer(); this.bossExecutor = nettyClientConfig.getBossExecutor(); this.workerExecutor = nettyClientConfig.getWorkerExecutor(); this.defaultSocksProxyAddress = nettyClientConfig.getDefaultSocksProxyAddress(); int bossThreadCount = nettyClientConfig.getBossThreadCount(); int workerThreadCount = nettyClientConfig.getWorkerThreadCount(); NioWorkerPool workerPool = new NioWorkerPool(workerExecutor, workerThreadCount, ThreadNameDeterminer.CURRENT); NioClientBossPool bossPool = new NioClientBossPool(bossExecutor, bossThreadCount, timer, ThreadNameDeterminer.CURRENT); this.channelFactory = new NioClientSocketChannelFactory(bossPool, workerPool); } }
@Test public void addChunkHandlesNonExistingChunkList() { DefaultLocalClientChannelFactory channelFactory = new DefaultLocalClientChannelFactory(); DefaultChannelPipeline pipeline = new DefaultChannelPipeline(); Channel channel = channelFactory.newChannel(pipeline); chunkedRequestAssembler.addChunk(channel, EMPTY_CHUNK); }
@Test public void addChunkHandlesNullChunk() { DefaultLocalClientChannelFactory channelFactory = new DefaultLocalClientChannelFactory(); DefaultChannelPipeline pipeline = new DefaultChannelPipeline(); Channel channel = channelFactory.newChannel(pipeline); chunkedRequestAssembler.addChunk(channel, null); }
@Test public void addChunkHandlesExistingChunkList() { DefaultLocalClientChannelFactory channelFactory = new DefaultLocalClientChannelFactory(); DefaultChannelPipeline pipeline = new DefaultChannelPipeline(); Channel channel = channelFactory.newChannel(pipeline); HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, ""); chunkedRequestAssembler.setup(channel, httpRequest); chunkedRequestAssembler.addChunk(channel, EMPTY_CHUNK); }