Apache Lucene open-source search software
convert some more tests to junit4
Robert Muir7912d72cfed4
diff --git a/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java b/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.javaindex 0ce7abae2ac..37f36f973be 100644--- a/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java+++ b/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java@@ -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.SolrException;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());}-+ @Testpublic 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 ExtractingRequestHandlerTest extends AbstractSolrTestCase {}+ @Testpublic 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 ExtractingRequestHandlerTest extends AbstractSolrTestCase {assertQ(req("+id:simple2 +t_href:[* TO *]"), "//*[@numFound='1']");}-+ @Testpublic 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 ExtractingRequestHandlerTest extends AbstractSolrTestCase {}-+ @Testpublic 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 ExtractingRequestHandlerTest extends AbstractSolrTestCase {assertQ(req("extractedContent:Apache"), "//*[@numFound='1']");}+ @Testpublic 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 ExtractingRequestHandlerTest extends AbstractSolrTestCase {// 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-+ @Testpublic 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 ExtractingRequestHandlerTest extends AbstractSolrTestCase {}+ @Testpublic 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 ExtractingRequestHandlerTest extends AbstractSolrTestCase {}/** test arabic PDF extraction is functional */+ @Testpublic void testArabicPDF() throws Exception {ExtractingRequestHandler handler = (ExtractingRequestHandler)h.getCore().getRequestHandler("/update/extract");diff --git a/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java b/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.javaindex 7d23ea11643..580ad7becbc 100644--- a/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java+++ b/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java@@ -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.AbstractSolrTestCase;* @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"));diff --git a/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java b/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.javaindex 099accc8a85..03a8a5c6d9e 100644--- a/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java+++ b/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java@@ -26,6 +26,11 @@ import org.apache.solr.common.util.ContentStreamBase;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 DocumentAnalysisRequestHandlerTest extends AnalysisRequestHandlerTeprivate 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+ @Beforepublic void setUp() throws Exception {super.setUp();handler = new DocumentAnalysisRequestHandler();@@ -60,6 +61,7 @@ public class DocumentAnalysisRequestHandlerTest extends AnalysisRequestHandlerTe/*** Tests the {@link DocumentAnalysisRequestHandler#resolveAnalysisRequest(org.apache.solr.request.SolrQueryRequest)}*/+ @Testpublic void testResolveAnalysisRequest() throws Exception {String docsInput =@@ -108,6 +110,7 @@ public class DocumentAnalysisRequestHandlerTest extends AnalysisRequestHandlerTe* Tests the {@link DocumentAnalysisRequestHandler#handleAnalysisRequest(org.apache.solr.client.solrj.request.DocumentAnalysisRequest,* org.apache.solr.schema.IndexSchema)}*/+ @Testpublic void testHandleAnalysisRequest() throws Exception {SolrInputDocument document = new SolrInputDocument();diff --git a/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java b/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.javaindex cf570329588..fe6425c46a1 100644--- a/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java+++ b/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java@@ -25,6 +25,11 @@ import org.apache.solr.common.params.ModifiableSolrParams;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 FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestBprivate FieldAnalysisRequestHandler handler;@Override+ @Beforepublic 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)}*/+ @Testpublic void testResolveAnalysisRequest() throws Exception {ModifiableSolrParams params = new ModifiableSolrParams();params.add(AnalysisParams.FIELD_NAME, "text,nametext");@@ -101,6 +103,7 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB* Tests the {@link FieldAnalysisRequestHandler#handleAnalysisRequest(org.apache.solr.client.solrj.request.FieldAnalysisRequest,* org.apache.solr.schema.IndexSchema)}*/+ @Testpublic void testHandleAnalysisRequest() throws Exception {FieldAnalysisRequest request = new FieldAnalysisRequest();@@ -293,6 +296,7 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB}+ @Testpublic void testCharFilterAnalysis() throws Exception {FieldAnalysisRequest request = new FieldAnalysisRequest();diff --git a/solr/src/test/org/apache/solr/search/TestRangeQuery.java b/solr/src/test/org/apache/solr/search/TestRangeQuery.javaindex 575308bbbcf..192a57073b4 100644--- a/solr/src/test/org/apache/solr/search/TestRangeQuery.java+++ b/solr/src/test/org/apache/solr/search/TestRangeQuery.java@@ -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");+ }+ @Beforepublic void setUp() throws Exception {// if you override setUp or tearDown, you better call// the super classes versionsuper.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 AbstractSolrTestCase {}}-+ @Testpublic 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 AbstractSolrTestCase {}+ @Testpublic void testRandomRangeQueries() throws Exception {String handler="";final String[] fields = {"foo_s","foo_i","foo_l","foo_f","foo_d" // SortableIntField, etcdiff --git a/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java b/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.javaindex 5920553c2ae..d58e78027f2 100644--- a/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java+++ b/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java@@ -24,6 +24,7 @@ import org.apache.lucene.document.Document;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());+ }++ @Testpublic void testRequireUniqueKey() throws Exception{SolrCore core = h.getCore();@@ -83,6 +97,7 @@ public class DirectUpdateHandlerTest extends AbstractSolrTestCase {catch( SolrException ex ) { } // expected}+ @Testpublic void testUncommit() throws Exception {addSimpleDoc("A");@@ -96,6 +111,7 @@ public class DirectUpdateHandlerTest extends AbstractSolrTestCase {);}+ @Testpublic void testAddCommit() throws Exception {addSimpleDoc("A");@@ -117,6 +133,7 @@ public class DirectUpdateHandlerTest extends AbstractSolrTestCase {);}+ @Testpublic void testDeleteCommit() throws Exception {addSimpleDoc("A");addSimpleDoc("B");@@ -159,7 +176,12 @@ public class DirectUpdateHandlerTest extends AbstractSolrTestCase {);}+ @Testpublic 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 extends AbstractSolrTestCase {);}+ @Testpublic 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 extends AbstractSolrTestCase {);}+ @Testpublic void testExpungeDeletes() throws Exception {assertU(adoc("id","1"));assertU(adoc("id","2"));diff --git a/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java b/solr/src/test/org/apache/solr/update/DocumentBuilderTest.javaindex 84d8bd547c8..1cd084a2b08 100644--- a/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java+++ b/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java@@ -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");+ }+ @Testpublic void testBuildDocument() throws Exception{SolrCore core = h.getCore();@@ -50,6 +56,7 @@ public class DocumentBuilderTest extends AbstractSolrTestCase {}}+ @Testpublic void testNullField(){SolrCore core = h.getCore();@@ -61,6 +68,7 @@ public class DocumentBuilderTest extends AbstractSolrTestCase {assertNull( out.get( "name" ) );}+ @Testpublic void testMultiField() throws Exception {SolrCore core = h.getCore();diff --git a/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java b/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.javaindex cdbc53de8c7..d55e1ec2905 100755--- a/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java+++ b/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java@@ -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+ @Beforepublic void setUp() throws Exception {super.setUp();+ clearIndex();+ assertU(commit());processor = "dedupe"; // set the default that most tests expect}+ @Testpublic void testDupeDetection() throws Exception {SolrCore core = h.getCore();UpdateRequestProcessorChain chained = core.getUpdateProcessingChain(@@ -103,6 +107,7 @@ public class SignatureUpdateProcessorFactoryTest extends AbstractSolrTestCase {factory.setEnabled(false);}+ @Testpublic void testMultiThreaded() throws Exception {UpdateRequestProcessorChain chained = h.getCore().getUpdateProcessingChain("dedupe");@@ -182,6 +187,7 @@ public class SignatureUpdateProcessorFactoryTest extends AbstractSolrTestCase {/*** a non-indexed signatureField is fine as long as overwriteDupes==false*/+ @Testpublic void testNonIndexedSignatureField() throws Exception {SolrCore core = h.getCore();@@ -197,6 +203,7 @@ public class SignatureUpdateProcessorFactoryTest extends AbstractSolrTestCase {2l, core.getSearcher().get().getReader().numDocs());}+ @Testpublic void testFailNonIndexedSigWithOverwriteDupes() throws Exception {SolrCore core = h.getCore();SignatureUpdateProcessorFactory f = new SignatureUpdateProcessorFactory();