mirror of https://github.com/apache/lucene.git
speed up a few more tests with SolrTestCaseJ4
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/branches/newtrunk@925694 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
db59c17a36
commit
9a13563009
|
@ -43,6 +43,8 @@
|
|||
<pathelement path="${dest}/classes"/>
|
||||
<pathelement path="${dest}/test-classes"/>
|
||||
<pathelement path="${java.class.path}"/>
|
||||
<pathelement location="${common-solr.dir}/build/tests"/> <!-- include solr test code -->
|
||||
<pathelement location="${common-solr.dir}/../lucene/build/classes/test" /> <!-- include some lucene test code -->
|
||||
<path refid="common.classpath"/>
|
||||
</path>
|
||||
|
||||
|
@ -64,7 +66,7 @@
|
|||
<mkdir dir="${dest}/classes"/>
|
||||
<mkdir dir="${download.dir}" />
|
||||
<mkdir dir="${build.javadoc}"/>
|
||||
<ant dir="../../" inheritall="false" target="compile"/>
|
||||
<ant dir="../../" inheritall="false" target="compileTests"/> <!-- compiles src and tests -->
|
||||
<ant dir="../../" inheritall="false" target="make-manifest"/>
|
||||
</target>
|
||||
|
||||
|
|
|
@ -16,36 +16,30 @@ package org.apache.solr.handler.clustering;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AbstractClusteringTest extends AbstractSolrTestCase {
|
||||
protected int numberOfDocs = 0;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
public class AbstractClusteringTest extends SolrTestCaseJ4 {
|
||||
protected static int numberOfDocs = 0;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrConfig.xml", "schema.xml");
|
||||
numberOfDocs = 0;
|
||||
for (String[] doc : DOCUMENTS) {
|
||||
assertU("add failed", adoc("id", Integer.toString(numberOfDocs), "url", doc[0], "title", doc[1], "snippet", doc[2]));
|
||||
assertNull(h.validateUpdate(adoc("id", Integer.toString(numberOfDocs), "url", doc[0], "title", doc[1], "snippet", doc[2])));
|
||||
numberOfDocs++;
|
||||
}
|
||||
assertU("commit", commit());
|
||||
assertNull(h.validateUpdate(commit()));
|
||||
}
|
||||
|
||||
public String getSchemaFile() {
|
||||
return "schema.xml";
|
||||
}
|
||||
|
||||
public String getSolrConfigFile() {
|
||||
return "solrconfig.xml";
|
||||
}
|
||||
|
||||
final String[][] DOCUMENTS = new String[][]{
|
||||
final static String[][] DOCUMENTS = new String[][]{
|
||||
{"http://en.wikipedia.org/wiki/Data_mining",
|
||||
"Data Mining - Wikipedia",
|
||||
"Article about knowledge-discovery in databases (KDD), the practice of automatically searching large stores of data for patterns."},
|
||||
|
|
|
@ -26,7 +26,9 @@ import org.apache.solr.handler.component.SearchComponent;
|
|||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.request.SolrRequestHandler;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -34,6 +36,7 @@ import org.apache.solr.request.SolrRequestHandler;
|
|||
**/
|
||||
public class ClusteringComponentTest extends AbstractClusteringTest {
|
||||
|
||||
@Test
|
||||
public void testComponent() throws Exception {
|
||||
SolrCore core = h.getCore();
|
||||
|
||||
|
|
|
@ -32,19 +32,24 @@ import org.apache.solr.search.DocList;
|
|||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.util.RefCounted;
|
||||
import org.carrot2.util.attribute.AttributeUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class CarrotClusteringEngineTest extends AbstractClusteringTest {
|
||||
@Test
|
||||
public void testCarrotLingo() throws Exception {
|
||||
checkEngine(getClusteringEngine("default"), 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProduceSummary() throws Exception {
|
||||
ModifiableSolrParams solrParams = new ModifiableSolrParams();
|
||||
solrParams.add(CarrotParams.SNIPPET_FIELD_NAME, "snippet");
|
||||
|
@ -52,21 +57,25 @@ public class CarrotClusteringEngineTest extends AbstractClusteringTest {
|
|||
checkEngine(getClusteringEngine("default"), numberOfDocs -2 /*two don't have mining in the snippet*/, 15, new TermQuery(new Term("snippet", "mine")), solrParams);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCarrotStc() throws Exception {
|
||||
checkEngine(getClusteringEngine("stc"), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithoutSubclusters() throws Exception {
|
||||
checkClusters(checkEngine(getClusteringEngine("mock"), this.numberOfDocs),
|
||||
1, 1, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithSubclusters() throws Exception {
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(CarrotParams.OUTPUT_SUB_CLUSTERS, true);
|
||||
checkClusters(checkEngine(getClusteringEngine("mock"), this.numberOfDocs), 1, 1, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNumDescriptions() throws Exception {
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "labels"), 5);
|
||||
|
@ -75,6 +84,7 @@ public class CarrotClusteringEngineTest extends AbstractClusteringTest {
|
|||
params), 1, 3, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCarrotAttributePassing() throws Exception {
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "depth"), 1);
|
||||
|
|
|
@ -18,21 +18,25 @@
|
|||
package org.apache.solr.request;
|
||||
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.After;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TestFaceting extends AbstractSolrTestCase {
|
||||
|
||||
public String getSchemaFile() { return "schema11.xml"; }
|
||||
public String getSolrConfigFile() { return "solrconfig.xml"; }
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
public class TestFaceting extends SolrTestCaseJ4 {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig.xml","schema11.xml");
|
||||
}
|
||||
|
||||
@After
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
close();
|
||||
super.tearDown();
|
||||
|
@ -110,6 +114,7 @@ public class TestFaceting extends AbstractSolrTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTermEnum() throws Exception {
|
||||
doTermEnum(0);
|
||||
doTermEnum(1);
|
||||
|
@ -120,6 +125,7 @@ public class TestFaceting extends AbstractSolrTestCase {
|
|||
// doTermEnum(TermIndex.interval * 3 + 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFacets() throws Exception {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
@ -187,6 +193,7 @@ public class TestFaceting extends AbstractSolrTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegularBig() throws Exception {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
|
|
@ -17,29 +17,26 @@ package org.apache.solr.search.function.distance;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.spatial.geohash.GeoHashUtils;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
**/
|
||||
public class DistanceFunctionTest extends AbstractSolrTestCase {
|
||||
public String getSchemaFile() {
|
||||
return "schema11.xml";
|
||||
public class DistanceFunctionTest extends SolrTestCaseJ4 {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrConfig-functionquery.xml", "schema11.xml");
|
||||
}
|
||||
|
||||
public String getSolrConfigFile() {
|
||||
return "solrconfig-functionquery.xml";
|
||||
}
|
||||
|
||||
public String getCoreName() {
|
||||
return "basic";
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHaversine() throws Exception {
|
||||
clearIndex();
|
||||
assertU(adoc("id", "1", "x_td", "0", "y_td", "0", "gh_s", GeoHashUtils.encode(32.7693246, -79.9289094)));
|
||||
assertU(adoc("id", "2", "x_td", "0", "y_td", String.valueOf(Math.PI / 2), "gh_s", GeoHashUtils.encode(32.7693246, -78.9289094)));
|
||||
assertU(adoc("id", "3", "x_td", String.valueOf(Math.PI / 2), "y_td", String.valueOf(Math.PI / 2), "gh_s", GeoHashUtils.encode(32.7693246, -80.9289094)));
|
||||
|
@ -71,7 +68,9 @@ public class DistanceFunctionTest extends AbstractSolrTestCase {
|
|||
assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + Constants.EARTH_RADIUS_KM + ", gh_s, geohash(32, -79))", "fq", "id:1"), "//float[@name='score']='122.309006'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVector() throws Exception {
|
||||
clearIndex();
|
||||
assertU(adoc("id", "1", "x_td", "0", "y_td", "0", "z_td", "0", "w_td", "0"));
|
||||
assertU(adoc("id", "2", "x_td", "0", "y_td", "1", "z_td", "0", "w_td", "0"));
|
||||
assertU(adoc("id", "3", "x_td", "1", "y_td", "1", "z_td", "1", "w_td", "1"));
|
||||
|
|
|
@ -31,25 +31,34 @@ import java.util.Map;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.MultiMapSolrParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SolrRequestParserTest extends AbstractSolrTestCase {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public String getSchemaFile() { return "schema.xml"; }
|
||||
public String getSolrConfigFile() { return "solrconfig.xml"; }
|
||||
public class SolrRequestParserTest extends SolrTestCaseJ4 {
|
||||
|
||||
SolrRequestParsers parser;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrConfig.xml", "schema.xml");
|
||||
parser = new SolrRequestParsers( h.getCore().getSolrConfig() );
|
||||
}
|
||||
|
||||
static SolrRequestParsers parser;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
parser = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamBody() throws Exception
|
||||
{
|
||||
String body1 = "AMANAPLANPANAMA";
|
||||
|
@ -95,7 +104,7 @@ public class SolrRequestParserTest extends AbstractSolrTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStreamURL() throws Exception
|
||||
{
|
||||
boolean ok = false;
|
||||
|
@ -122,6 +131,7 @@ public class SolrRequestParserTest extends AbstractSolrTestCase {
|
|||
assertEquals( txt, IOUtils.toString( streams.get(0).getStream() ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrlParamParsing()
|
||||
{
|
||||
String[][] teststr = new String[][] {
|
||||
|
@ -138,6 +148,7 @@ public class SolrRequestParserTest extends AbstractSolrTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStandardParseParamsAndFillStreams() throws Exception
|
||||
{
|
||||
ArrayList<ContentStream> streams = new ArrayList<ContentStream>();
|
||||
|
|
Loading…
Reference in New Issue