diff --git a/solr/contrib/clustering/build.xml b/solr/contrib/clustering/build.xml index 8d654c6de56..3709caca5ec 100644 --- a/solr/contrib/clustering/build.xml +++ b/solr/contrib/clustering/build.xml @@ -43,6 +43,8 @@ + + @@ -64,7 +66,7 @@ - + diff --git a/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java b/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java index 422d2a44031..fd3502a12bb 100644 --- a/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java +++ b/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java @@ -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."}, diff --git a/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java b/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java index 096710c3b9d..3e338b257f7 100644 --- a/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java +++ b/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java @@ -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(); diff --git a/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java b/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java index 395cf01775d..bec4da10476 100644 --- a/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java +++ b/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java @@ -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); diff --git a/solr/src/test/org/apache/solr/request/TestFaceting.java b/solr/src/test/org/apache/solr/request/TestFaceting.java index 9cf77a09fa3..fae70fa40fe 100755 --- a/solr/src/test/org/apache/solr/request/TestFaceting.java +++ b/solr/src/test/org/apache/solr/request/TestFaceting.java @@ -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(); diff --git a/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java b/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java index 6b379dedeee..a95c57ffe9e 100644 --- a/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java +++ b/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java @@ -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")); diff --git a/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java b/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java index ad9bc47d221..af62192c04a 100644 --- a/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java +++ b/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java @@ -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"; } - - SolrRequestParsers parser; +public class SolrRequestParserTest extends SolrTestCaseJ4 { - 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 streams = new ArrayList();