SOLR-6625: Set HttpClientImpl in SolrTestCaseJ4 for tests

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1693483 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Anshum Gupta 2015-07-30 19:29:20 +00:00
parent a3cff55407
commit 9cb8523c59
2 changed files with 8 additions and 3 deletions

View File

@ -395,10 +395,10 @@ public class HttpClientUtil {
} }
public static DefaultHttpClient createHttpClient(ClientConnectionManager cm) { public static DefaultHttpClient createHttpClient(ClientConnectionManager cm) {
Constructor<? extends DefaultHttpClient> productConstructor; Constructor<? extends DefaultHttpClient> constructor;
try { try {
productConstructor = defaultHttpClientClass.getDeclaredConstructor(new Class[]{ClientConnectionManager.class}); constructor = defaultHttpClientClass.getDeclaredConstructor(new Class[]{ClientConnectionManager.class});
return productConstructor.newInstance(new Object[]{cm}); return constructor.newInstance(new Object[]{cm});
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to create HttpClient instance, registered class is: " + defaultHttpClientClass, e); throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to create HttpClient instance, registered class is: " + defaultHttpClientClass, e);
} }

View File

@ -100,6 +100,7 @@ import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.DateFormatUtil; import org.apache.solr.util.DateFormatUtil;
import org.apache.solr.util.RevertDefaultThreadHandlerRule; import org.apache.solr.util.RevertDefaultThreadHandlerRule;
import org.apache.solr.util.SSLTestConfig; import org.apache.solr.util.SSLTestConfig;
import org.apache.solr.util.SolrHttpClient;
import org.apache.solr.util.TestHarness; import org.apache.solr.util.TestHarness;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.AfterClass; import org.junit.AfterClass;
@ -140,6 +141,10 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
public static int DEFAULT_CONNECTION_TIMEOUT = 60000; // default socket connection timeout in ms public static int DEFAULT_CONNECTION_TIMEOUT = 60000; // default socket connection timeout in ms
static {
HttpClientUtil.HttpClientFactory.setHttpClientImpl(SolrHttpClient.SolrDefaultHttpClient.class, SolrHttpClient.SolrSystemDefaultHttpClient.class);
}
protected void writeCoreProperties(Path coreDirectory, String corename) throws IOException { protected void writeCoreProperties(Path coreDirectory, String corename) throws IOException {
Properties props = new Properties(); Properties props = new Properties();
props.setProperty("name", corename); props.setProperty("name", corename);