You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2010/07/19 02:06:18 UTC
svn commit: r965330 - in /lucene/dev/trunk/solr:
contrib/extraction/src/test/java/org/apache/solr/handler/
src/test/org/apache/solr/handler/ src/test/org/apache/solr/search/
src/test/org/apache/solr/update/ src/test/org/apache/solr/update/processor/
Author: rmuir
Date: Mon Jul 19 00:06:18 2010
New Revision: 965330
URL: http://svn.apache.org/viewvc?rev=965330&view=rev
Log:
convert some more tests to junit4
Modified:
lucene/dev/trunk/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java
lucene/dev/trunk/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java
lucene/dev/trunk/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java
lucene/dev/trunk/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
lucene/dev/trunk/solr/src/test/org/apache/solr/search/TestRangeQuery.java
lucene/dev/trunk/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
lucene/dev/trunk/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java
lucene/dev/trunk/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
Modified: lucene/dev/trunk/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java?rev=965330&r1=965329&r2=965330&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java (original)
+++ lucene/dev/trunk/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java Mon Jul 19 00:06:18 2010
@@ -16,7 +16,7 @@ package org.apache.solr.handler;
* limitations under the License.
*/
-import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.common.util.ContentStream;
@@ -26,6 +26,11 @@ import org.apache.solr.common.SolrExcept
import org.apache.solr.handler.extraction.ExtractingParams;
import org.apache.solr.handler.extraction.ExtractingRequestHandler;
import org.apache.solr.handler.extraction.ExtractingDocumentLoader;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
import java.util.List;
import java.util.ArrayList;
@@ -36,18 +41,20 @@ import java.io.File;
*
*
**/
-public class ExtractingRequestHandlerTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema.xml";
+public class ExtractingRequestHandlerTest extends SolrTestCaseJ4 {
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
}
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ clearIndex();
+ assertU(commit());
}
-
+ @Test
public void testExtraction() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
assertTrue("handler is null and it shouldn't be", handler != null);
@@ -134,6 +141,7 @@ public class ExtractingRequestHandlerTes
}
+ @Test
public void testDefaultField() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
assertTrue("handler is null and it shouldn't be", handler != null);
@@ -177,7 +185,7 @@ public class ExtractingRequestHandlerTes
assertQ(req("+id:simple2 +t_href:[* TO *]"), "//*[@numFound='1']");
}
-
+ @Test
public void testLiterals() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
assertTrue("handler is null and it shouldn't be", handler != null);
@@ -231,7 +239,7 @@ public class ExtractingRequestHandlerTes
}
-
+ @Test
public void testPlainTextSpecifyingMimeType() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
assertTrue("handler is null and it shouldn't be", handler != null);
@@ -250,6 +258,7 @@ public class ExtractingRequestHandlerTes
assertQ(req("extractedContent:Apache"), "//*[@numFound='1']");
}
+ @Test
public void testPlainTextSpecifyingResourceName() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
assertTrue("handler is null and it shouldn't be", handler != null);
@@ -271,7 +280,7 @@ public class ExtractingRequestHandlerTes
// Note: If you load a plain text file specifying neither MIME type nor filename, extraction will silently fail. This is because Tika's
// automatic MIME type detection will fail, and it will default to using an empty-string-returning default parser
-
+ @Test
public void testExtractOnly() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
assertTrue("handler is null and it shouldn't be", handler != null);
@@ -308,6 +317,7 @@ public class ExtractingRequestHandlerTes
}
+ @Test
public void testXPath() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
assertTrue("handler is null and it shouldn't be", handler != null);
@@ -323,6 +333,7 @@ public class ExtractingRequestHandlerTes
}
/** test arabic PDF extraction is functional */
+ @Test
public void testArabicPDF() throws Exception {
ExtractingRequestHandler handler = (ExtractingRequestHandler)
h.getCore().getRequestHandler("/update/extract");
Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java?rev=965330&r1=965329&r2=965330&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java Mon Jul 19 00:06:18 2010
@@ -17,8 +17,10 @@
package org.apache.solr.handler;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
-import org.apache.solr.util.AbstractSolrTestCase;
+
+import static org.junit.Assert.*;
/**
* A base class for all analysis request handler tests.
@@ -26,7 +28,7 @@ import org.apache.solr.util.AbstractSolr
* @version $Id$
* @since solr 1.4
*/
-public abstract class AnalysisRequestHandlerTestBase extends AbstractSolrTestCase {
+public abstract class AnalysisRequestHandlerTestBase extends SolrTestCaseJ4 {
protected void assertToken(NamedList token, TokenInfo info) {
assertEquals(info.getText(), token.get("text"));
Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java?rev=965330&r1=965329&r2=965330&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java Mon Jul 19 00:06:18 2010
@@ -26,6 +26,11 @@ import org.apache.solr.common.util.Conte
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
@@ -40,17 +45,13 @@ public class DocumentAnalysisRequestHand
private DocumentAnalysisRequestHandler handler;
- @Override
- public String getSchemaFile() {
- return "schema.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
}
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
handler = new DocumentAnalysisRequestHandler();
@@ -60,6 +61,7 @@ public class DocumentAnalysisRequestHand
/**
* Tests the {@link DocumentAnalysisRequestHandler#resolveAnalysisRequest(org.apache.solr.request.SolrQueryRequest)}
*/
+ @Test
public void testResolveAnalysisRequest() throws Exception {
String docsInput =
@@ -108,6 +110,7 @@ public class DocumentAnalysisRequestHand
* Tests the {@link DocumentAnalysisRequestHandler#handleAnalysisRequest(org.apache.solr.client.solrj.request.DocumentAnalysisRequest,
* org.apache.solr.schema.IndexSchema)}
*/
+ @Test
public void testHandleAnalysisRequest() throws Exception {
SolrInputDocument document = new SolrInputDocument();
Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java?rev=965330&r1=965329&r2=965330&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java Mon Jul 19 00:06:18 2010
@@ -25,6 +25,11 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.util.NamedList;
import org.apache.solr.client.solrj.request.FieldAnalysisRequest;
import org.apache.solr.request.LocalSolrQueryRequest;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
import java.util.List;
@@ -39,24 +44,21 @@ public class FieldAnalysisRequestHandler
private FieldAnalysisRequestHandler handler;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
handler = new FieldAnalysisRequestHandler();
}
- @Override
- public String getSchemaFile() {
- return "schema.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
}
/**
* Tests the {@link FieldAnalysisRequestHandler#resolveAnalysisRequest(org.apache.solr.request.SolrQueryRequest)}
*/
+ @Test
public void testResolveAnalysisRequest() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(AnalysisParams.FIELD_NAME, "text,nametext");
@@ -101,6 +103,7 @@ public class FieldAnalysisRequestHandler
* Tests the {@link FieldAnalysisRequestHandler#handleAnalysisRequest(org.apache.solr.client.solrj.request.FieldAnalysisRequest,
* org.apache.solr.schema.IndexSchema)}
*/
+ @Test
public void testHandleAnalysisRequest() throws Exception {
FieldAnalysisRequest request = new FieldAnalysisRequest();
@@ -293,6 +296,7 @@ public class FieldAnalysisRequestHandler
}
+ @Test
public void testCharFilterAnalysis() throws Exception {
FieldAnalysisRequest request = new FieldAnalysisRequest();
Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/search/TestRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/search/TestRangeQuery.java?rev=965330&r1=965329&r2=965330&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/search/TestRangeQuery.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/search/TestRangeQuery.java Mon Jul 19 00:06:18 2010
@@ -16,30 +16,33 @@
*/
package org.apache.solr.search;
-import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.response.SolrQueryResponse;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
import java.util.*;
import junit.framework.TestCase;
-public class TestRangeQuery extends AbstractSolrTestCase {
-
- public String getSchemaFile() { return "schema11.xml"; }
- public String getSolrConfigFile() { return "solrconfig.xml"; }
- public String getCoreName() { return "basic"; }
+public class TestRangeQuery extends SolrTestCaseJ4 {
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema11.xml");
+ }
+ @Before
public void setUp() throws Exception {
// if you override setUp or tearDown, you better call
// the super classes version
super.setUp();
- }
- public void tearDown() throws Exception {
- // if you override setUp or tearDown, you better call
- // the super classes version
- super.tearDown();
+ clearIndex();
+ assertU(commit());
}
Random r = new Random(1);
@@ -69,7 +72,7 @@ public class TestRangeQuery extends Abst
}
}
-
+ @Test
public void testRangeQueries() throws Exception {
// ensure that we aren't losing precision on any fields in addition to testing other non-numeric fields
// that aren't tested in testRandomRangeQueries()
@@ -197,6 +200,7 @@ public class TestRangeQuery extends Abst
}
+ @Test
public void testRandomRangeQueries() throws Exception {
String handler="";
final String[] fields = {"foo_s","foo_i","foo_l","foo_f","foo_d" // SortableIntField, etc
Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java?rev=965330&r1=965329&r2=965330&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java Mon Jul 19 00:06:18 2010
@@ -24,6 +24,7 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
@@ -31,18 +32,31 @@ import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.SolrIndexReader;
-import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
*
*
*/
-public class DirectUpdateHandlerTest extends AbstractSolrTestCase {
+public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
- public String getSchemaFile() { return "schema12.xml"; }
- public String getSolrConfigFile() { return "solrconfig.xml"; }
-
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
+ }
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ clearIndex();
+ assertU(commit());
+ }
+
+ @Test
public void testRequireUniqueKey() throws Exception
{
SolrCore core = h.getCore();
@@ -83,6 +97,7 @@ public class DirectUpdateHandlerTest ext
catch( SolrException ex ) { } // expected
}
+ @Test
public void testUncommit() throws Exception {
addSimpleDoc("A");
@@ -96,6 +111,7 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testAddCommit() throws Exception {
addSimpleDoc("A");
@@ -117,6 +133,7 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testDeleteCommit() throws Exception {
addSimpleDoc("A");
addSimpleDoc("B");
@@ -159,7 +176,12 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testAddRollback() throws Exception {
+ // re-init the core
+ deleteCore();
+ initCore("solrconfig.xml", "schema12.xml");
+
addSimpleDoc("A");
// commit "A"
@@ -209,7 +231,12 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testDeleteRollback() throws Exception {
+ // re-init the core
+ deleteCore();
+ initCore("solrconfig.xml", "schema12.xml");
+
addSimpleDoc("A");
addSimpleDoc("B");
@@ -276,6 +303,7 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testExpungeDeletes() throws Exception {
assertU(adoc("id","1"));
assertU(adoc("id","2"));
Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java?rev=965330&r1=965329&r2=965330&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java Mon Jul 19 00:06:18 2010
@@ -18,22 +18,28 @@
package org.apache.solr.update;
import org.apache.lucene.document.Document;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.SolrCore;
-import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.schema.FieldType;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
*
*
*/
-public class DocumentBuilderTest extends AbstractSolrTestCase {
+public class DocumentBuilderTest extends SolrTestCaseJ4 {
- @Override public String getSchemaFile() { return "schema.xml"; }
- @Override public String getSolrConfigFile() { return "solrconfig.xml"; }
-
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+ @Test
public void testBuildDocument() throws Exception
{
SolrCore core = h.getCore();
@@ -50,6 +56,7 @@ public class DocumentBuilderTest extends
}
}
+ @Test
public void testNullField()
{
SolrCore core = h.getCore();
@@ -61,6 +68,7 @@ public class DocumentBuilderTest extends
assertNull( out.get( "name" ) );
}
+ @Test
public void testMultiField() throws Exception {
SolrCore core = h.getCore();
Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java?rev=965330&r1=965329&r2=965330&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java Mon Jul 19 00:06:18 2010
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.MultiMapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
@@ -31,32 +32,35 @@ import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.XmlUpdateRequestHandler;
import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
*
*/
-public class SignatureUpdateProcessorFactoryTest extends AbstractSolrTestCase {
+public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
/** modified by tests as needed */
private String processor = "dedupe";
- @Override
- public String getSchemaFile() {
- return "schema12.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
}
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
+ clearIndex();
+ assertU(commit());
processor = "dedupe"; // set the default that most tests expect
}
+ @Test
public void testDupeDetection() throws Exception {
SolrCore core = h.getCore();
UpdateRequestProcessorChain chained = core.getUpdateProcessingChain(
@@ -103,6 +107,7 @@ public class SignatureUpdateProcessorFac
factory.setEnabled(false);
}
+ @Test
public void testMultiThreaded() throws Exception {
UpdateRequestProcessorChain chained = h.getCore().getUpdateProcessingChain(
"dedupe");
@@ -182,6 +187,7 @@ public class SignatureUpdateProcessorFac
/**
* a non-indexed signatureField is fine as long as overwriteDupes==false
*/
+ @Test
public void testNonIndexedSignatureField() throws Exception {
SolrCore core = h.getCore();
@@ -197,6 +203,7 @@ public class SignatureUpdateProcessorFac
2l, core.getSearcher().get().getReader().numDocs());
}
+ @Test
public void testFailNonIndexedSigWithOverwriteDupes() throws Exception {
SolrCore core = h.getCore();
SignatureUpdateProcessorFactory f = new SignatureUpdateProcessorFactory();