mirror of https://github.com/apache/lucene.git
tests: factor out common client creation code
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@927651 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb1537e7da
commit
88534cd9ad
|
@ -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 SolrTestCaseJ4
|
|||
|
||||
context = 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(), "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
@BeforeClass
|
||||
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.setRequestWriter(new BinaryRequestWriter());
|
||||
s.setConnectionTimeout(100); // 1/10th sec
|
||||
s.setDefaultMaxConnectionsPerHost(100);
|
||||
s.setMaxTotalConnections(100);
|
||||
return s;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SolrServer createNewSolrServer()
|
||||
{
|
||||
return new EmbeddedSolrServer( h.getCoreContainer(), "" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
@BeforeClass
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(), "" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadSetup()
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SolrExampleStreamingTest extends SolrExampleTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SolrServer createNewSolrServer()
|
||||
public SolrServer createNewSolrServer()
|
||||
{
|
||||
try {
|
||||
// setup the server...
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue