diff --git a/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java index d834dafffe2..5c9df4818a6 100644 --- a/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java +++ b/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java @@ -13,6 +13,7 @@ import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.schema.TrieDateField; import org.apache.solr.util.AbstractSolrTestCase; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +26,7 @@ import java.util.*; * * @since solr 1.5 */ -public abstract class BaseDistributedSearchTestCase extends TestCase { +public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 { public static Random r = new Random(0); protected int shardCount = 4; @@ -493,6 +494,7 @@ public abstract class BaseDistributedSearchTestCase extends TestCase { } } + @Test public void testDistribSearch() throws Exception { if (fixShardCount) { createServers(shardCount); diff --git a/solr/src/test/org/apache/solr/TestDistributedSearch.java b/solr/src/test/org/apache/solr/TestDistributedSearch.java index dfc03acd72d..a995e45c8b4 100755 --- a/solr/src/test/org/apache/solr/TestDistributedSearch.java +++ b/solr/src/test/org/apache/solr/TestDistributedSearch.java @@ -17,6 +17,8 @@ package org.apache.solr; +import junit.framework.TestCase; + import org.apache.solr.client.solrj.SolrServerException; /** @@ -28,13 +30,6 @@ import org.apache.solr.client.solrj.SolrServerException; * @since solr 1.3 */ public class TestDistributedSearch extends BaseDistributedSearchTestCase { - public String getSchemaFile() { - return null; - } - - public String getSolrConfigFile() { - return null; - } String t1="a_t"; String i1="a_si"; @@ -183,7 +178,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase { try { // test error produced for field that is invalid for schema query("q","*:*", "rows",100, "facet","true", "facet.field",invalidField, "facet.mincount",2); - fail("SolrServerException expected for invalid field that is not in schema"); + TestCase.fail("SolrServerException expected for invalid field that is not in schema"); } catch (SolrServerException ex) { // expected } diff --git a/solr/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java b/solr/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java index b49d44a76b6..77a17b67ca3 100644 --- a/solr/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java +++ b/solr/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java @@ -1,7 +1,8 @@ package org.apache.solr.handler.component; import org.apache.solr.BaseDistributedSearchTestCase; -import org.apache.solr.util.AbstractSolrTestCase; +import org.apache.solr.client.solrj.SolrServer; +import org.apache.solr.common.params.ModifiableSolrParams; /** * Test for SpellCheckComponent's distributed querying @@ -30,6 +31,22 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTes System.setProperty("solr.directoryFactory", saveProp); } + private void q(Object... q) throws Exception { + final ModifiableSolrParams params = new ModifiableSolrParams(); + + for (int i = 0; i < q.length; i += 2) { + params.add(q[i].toString(), q[i + 1].toString()); + } + + controlClient.query(params); + + // query a random server + params.set("shards", shards); + int which = r.nextInt(clients.size()); + SolrServer client = clients.get(which); + client.query(params); + } + @Override public void doTest() throws Exception { index(id, "1", "lowerfilt", "toyota"); @@ -51,10 +68,11 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTes handle.put("maxScore", SKIPVAL); // we care only about the spellcheck results handle.put("response", SKIP); - - query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH"); - query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true"); - query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","bluo", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4"); - query("q", "The quick reb fox jumped over the lazy brown dogs", "fl", "id,lowerfilt", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4", SpellCheckComponent.SPELLCHECK_COLLATE, "true"); + q("q", "*:*", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH"); + + query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH"); + query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true"); + query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","bluo", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4"); + query("q", "The quick reb fox jumped over the lazy brown dogs", "fl", "id,lowerfilt", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4", SpellCheckComponent.SPELLCHECK_COLLATE, "true"); } }