Apache Lucene open-source search software
tests: factor out common client creation code
Yonik Seeley88534cd9adeb
diff --git a/solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java b/solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.javaindex 5f7ca42eec3..9eac8e926e7 100755--- a/solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java+++ b/solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java@@ -1,6 +1,7 @@package org.apache.solr.client.solrj;import org.apache.solr.SolrTestCaseJ4;+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;import org.apache.solr.client.solrj.embedded.JettySolrRunner;import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;import org.junit.AfterClass;@@ -34,7 +35,7 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4context = context==null ? "/solr" : context;SolrJettyTestBase.context = context;- JettySolrRunner jetty = new JettySolrRunner( context, 0, configFile );+ jetty = new JettySolrRunner( context, 0, configFile );jetty.start();port = jetty.getLocalPort();@@ -62,7 +63,27 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4}/**- * Create a new solr server+ * Create a new solr server.+ * If createJetty was called, an http implementation will be created,+ * otherwise an embedded implementation will be created.+ * Subclasses should override for other options.*/- protected abstract SolrServer createNewSolrServer();+ public SolrServer createNewSolrServer() {+ if (jetty != null) {+ try {+ // setup the server...+ String url = "http://localhost:"+port+context;+ CommonsHttpSolrServer s = new CommonsHttpSolrServer( url );+ s.setConnectionTimeout(100); // 1/10th sec+ s.setDefaultMaxConnectionsPerHost(100);+ s.setMaxTotalConnections(100);+ return s;+ }+ catch( Exception ex ) {+ throw new RuntimeException( ex );+ }+ } else {+ return new EmbeddedSolrServer( h.getCoreContainer(), "" );+ }+ }}diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java b/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.javaindex 74e26ddba20..30d57c7b114 100644--- a/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java@@ -23,31 +23,12 @@ import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;import org.junit.BeforeClass;/**- * @version $Id$* @see org.apache.solr.client.solrj.impl.BinaryRequestWriter* @see org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec- * @since solr 1.4*/public class LargeVolumeBinaryJettyTest extends LargeVolumeTestBase {@BeforeClasspublic static void beforeTest() throws Exception {createJetty(EXAMPLE_HOME, null, null);}-- @Override- protected SolrServer createNewSolrServer() {- try {- // setup the server...- String url = "http://localhost:" + port + context;- CommonsHttpSolrServer s = new CommonsHttpSolrServer(url);- s.setRequestWriter(new BinaryRequestWriter());- s.setConnectionTimeout(100); // 1/10th sec- s.setDefaultMaxConnectionsPerHost(100);- s.setMaxTotalConnections(100);- return s;- }- catch (Exception ex) {- throw new RuntimeException(ex);- }- }}diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java b/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.javaindex 814c9d8dd29..add707d14b7 100644--- a/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java@@ -21,19 +21,9 @@ import org.apache.solr.client.solrj.LargeVolumeTestBase;import org.apache.solr.client.solrj.SolrServer;import org.junit.BeforeClass;-/**- * @version $Id$- * @since solr 1.3- */public class LargeVolumeEmbeddedTest extends LargeVolumeTestBase {@BeforeClasspublic static void beforeTest() throws Exception {initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);}-- @Override- protected SolrServer createNewSolrServer()- {- return new EmbeddedSolrServer( h.getCoreContainer(), "" );- }}diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java b/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.javaindex b0eff45a7f4..50da9a288ff 100644--- a/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java@@ -22,30 +22,9 @@ import org.apache.solr.client.solrj.SolrServer;import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;import org.junit.BeforeClass;-/**- * @version $Id$- * @since solr 1.3- */public class LargeVolumeJettyTest extends LargeVolumeTestBase {@BeforeClasspublic static void beforeTest() throws Exception {createJetty(EXAMPLE_HOME, null, null);}-- @Override- protected SolrServer createNewSolrServer()- {- try {- // setup the server...- String url = "http://localhost:"+port+context;- CommonsHttpSolrServer s = new CommonsHttpSolrServer( url );- s.setConnectionTimeout(100); // 1/10th sec- s.setDefaultMaxConnectionsPerHost(100);- s.setMaxTotalConnections(100);- return s;- }- catch( Exception ex ) {- throw new RuntimeException( ex );- }- }}diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java b/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.javaindex f0bf1e9554d..79743965720 100644--- a/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java@@ -33,10 +33,4 @@ public class SolrExampleEmbeddedTest extends SolrExampleTests {public static void beforeTest() throws Exception {initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);}-- @Override- protected SolrServer createNewSolrServer()- {- return new EmbeddedSolrServer( h.getCoreContainer(), "" );- }}diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java b/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.javaindex 32b2645cbd7..f22b62a4264 100644--- a/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java@@ -31,8 +31,6 @@ import org.junit.Test;* http://docs.codehaus.org/display/JETTY/ServletTester* rather then open a real connection?*- * @version $Id$- * @since solr 1.3*/public class SolrExampleJettyTest extends SolrExampleTests {@@ -40,23 +38,6 @@ public class SolrExampleJettyTest extends SolrExampleTests {public static void beforeTest() throws Exception {createJetty(EXAMPLE_HOME, null, null);}-- @Override- protected SolrServer createNewSolrServer()- {- try {- // setup the server...- String url = "http://localhost:"+port+context;- CommonsHttpSolrServer s = new CommonsHttpSolrServer( url );- s.setConnectionTimeout(100); // 1/10th sec- s.setDefaultMaxConnectionsPerHost(100);- s.setMaxTotalConnections(100);- return s;- }- catch( Exception ex ) {- throw new RuntimeException( ex );- }- }@Testpublic void testBadSetup()diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java b/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.javaindex 042099aad4d..5e96535d0f9 100644--- a/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java@@ -36,7 +36,7 @@ public class SolrExampleStreamingTest extends SolrExampleTests {}@Override- protected SolrServer createNewSolrServer()+ public SolrServer createNewSolrServer(){try {// setup the server...diff --git a/solr/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java b/solr/src/test/org/apache/solr/servlet/CacheHeaderTestBase.javaindex 365554af1ef..063798226df 100644--- a/solr/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java+++ b/solr/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java@@ -33,20 +33,6 @@ import static junit.framework.Assert.assertEquals;import static org.junit.Assert.assertTrue;public abstract class CacheHeaderTestBase extends SolrJettyTestBase {- @Override- protected CommonsHttpSolrServer createNewSolrServer() {- try {- // setup the server...- String url = "http://localhost:" + port + context;- CommonsHttpSolrServer s = new CommonsHttpSolrServer(url);- s.setConnectionTimeout(100); // 1/10th sec- s.setDefaultMaxConnectionsPerHost(100);- s.setMaxTotalConnections(100);- return s;- } catch (Exception ex) {- throw new RuntimeException(ex);- }- }protected HttpMethodBase getSelectMethod(String method) {CommonsHttpSolrServer httpserver = (CommonsHttpSolrServer)getSolrServer();