private PoolingClientConnectionManager configureConnectionManager( WebClientConfiguration wconfig){ logger.debug("User-Agent is '" + wconfig.getUserAgent() + "'"); logger.debug("Max total connections is " + wconfig.getMaxTotalConn()); logger.debug("Max connections per host is " + wconfig.getMaxConnPerHost()); logger.debug("Connection timeout is " + wconfig.getTimeoutSecs()); logger.debug("Socket Connection timeout is " + wconfig.getSockTimeoutSecs()); logger.debug("Follow redirects? " + wconfig.getFollowRedirects()); logger.debug("Max number of redirects to follow is " + wconfig.getMaxRedirects()); PoolingClientConnectionManager cManager = new PoolingClientConnectionManager(); cManager.setDefaultMaxPerRoute(wconfig.getMaxConnPerHost()); cManager.setMaxTotal(wconfig.getMaxTotalConn()); //TODO pick the ports up from configuration cManager.getSchemeRegistry().register( new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); cManager.getSchemeRegistry().register( new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); return cManager; }
private PoolingClientConnectionManager configureConnectionManager( WebClientConfiguration wconfig){ logger.debug("User-Agent is '" + wconfig.getUserAgent() + "'"); logger.debug("Max total connections is " + wconfig.getMaxTotalConn()); logger.debug("Max connections per host is " + wconfig.getMaxConnPerHost()); logger.debug("Connection timeout is " + wconfig.getTimeoutSecs()); logger.debug("Socket Connection timeout is " + wconfig.getSockTimeoutSecs()); logger.debug("Follow redirects? " + wconfig.getFollowRedirects()); logger.debug("Max number of redirects to follow is " + wconfig.getMaxRedirects()); PoolingClientConnectionManager cManager = new PoolingClientConnectionManager(); cManager.setDefaultMaxPerRoute(wconfig.getMaxConnPerHost()); cManager.setMaxTotal(wconfig.getMaxTotalConn()); //TODO pick the ports up from configuration cManager.getSchemeRegistry().register( new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); cManager.getSchemeRegistry().register( new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); return cManager; }
@Test public void testInit() throws ModuleInitializationException { when(mockClientConfig.getMaxConnPerHost()).thenReturn(5); when(mockClientConfig.getMaxTotalConn()).thenReturn(5); testObj.initModule(); }