Author: rmuir
Date: Sat Mar 20 22:09:25 2010
New Revision: 925694
URL: http://svn.apache.org/viewvc?rev=925694&view=rev
Log:
speed up a few more tests with SolrTestCaseJ4
Modified:
lucene/solr/branches/newtrunk/solr/contrib/clustering/build.xml
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/TestFaceting.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
Modified: lucene/solr/branches/newtrunk/solr/contrib/clustering/build.xml
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/contrib/clustering/build.xml?rev=925694&r1=925693&r2=925694&view=diff
==============================================================================
--- lucene/solr/branches/newtrunk/solr/contrib/clustering/build.xml (original)
+++ lucene/solr/branches/newtrunk/solr/contrib/clustering/build.xml Sat Mar 20
22:09:25 2010
@@ -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>
Modified:
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java?rev=925694&r1=925693&r2=925694&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/AbstractClusteringTest.java
Sat Mar 20 22:09:25 2010
@@ -16,36 +16,30 @@ package org.apache.solr.handler.clusteri
* 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());
- }
-
- public String getSchemaFile() {
- return "schema.xml";
- }
-
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ assertNull(h.validateUpdate(commit()));
}
- 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."},
Modified:
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java?rev=925694&r1=925693&r2=925694&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/ClusteringComponentTest.java
Sat Mar 20 22:09:25 2010
@@ -26,7 +26,9 @@ import org.apache.solr.handler.component
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.SolrReque
**/
public class ClusteringComponentTest extends AbstractClusteringTest {
+ @Test
public void testComponent() throws Exception {
SolrCore core = h.getCore();
Modified:
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java?rev=925694&r1=925693&r2=925694&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/contrib/clustering/src/test/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngineTest.java
Sat Mar 20 22:09:25 2010
@@ -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
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
params), 1, 3, 0);
}
+ @Test
public void testCarrotAttributePassing() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "depth"),
1);
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/TestFaceting.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/TestFaceting.java?rev=925694&r1=925693&r2=925694&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/TestFaceting.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/TestFaceting.java
Sat Mar 20 22:09:25 2010
@@ -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 Abstra
}
}
+ @Test
public void testTermEnum() throws Exception {
doTermEnum(0);
doTermEnum(1);
@@ -120,6 +125,7 @@ public class TestFaceting extends Abstra
// doTermEnum(TermIndex.interval * 3 + 3);
}
+ @Test
public void testFacets() throws Exception {
StringBuilder sb = new StringBuilder();
@@ -187,6 +193,7 @@ public class TestFaceting extends Abstra
);
}
+ @Test
public void testRegularBig() throws Exception {
StringBuilder sb = new StringBuilder();
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java?rev=925694&r1=925693&r2=925694&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
Sat Mar 20 22:09:25 2010
@@ -17,29 +17,26 @@ package org.apache.solr.search.function.
*/
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 extend
assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" +
Constants.EARTH_RADIUS_KM + ", gh_s, geohash(32, -79))", "fq", "id:1"),
"//flo...@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"));
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java?rev=925694&r1=925693&r2=925694&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
Sat Mar 20 22:09:25 2010
@@ -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 exten
}
}
-
+ @Test
public void testStreamURL() throws Exception
{
boolean ok = false;
@@ -122,6 +131,7 @@ public class SolrRequestParserTest exten
assertEquals( txt, IOUtils.toString( streams.get(0).getStream() ) );
}
+ @Test
public void testUrlParamParsing()
{
String[][] teststr = new String[][] {
@@ -138,6 +148,7 @@ public class SolrRequestParserTest exten
}
}
+ @Test
public void testStandardParseParamsAndFillStreams() throws Exception
{
ArrayList<ContentStream> streams = new ArrayList<ContentStream>();