Apache Lucene open-source search software
speed up a few more tests with SolrTestCaseJ4
Robert Muir733aabd0822b
diff --git a/solr/src/test/org/apache/solr/EchoParamsTest.java b/solr/src/test/org/apache/solr/EchoParamsTest.javaindex 3648aaaa372..4d9f78bf50d 100644--- a/solr/src/test/org/apache/solr/EchoParamsTest.java+++ b/solr/src/test/org/apache/solr/EchoParamsTest.java@@ -17,17 +17,21 @@package org.apache.solr;-import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.BeforeClass;+import org.junit.Test;/** Test SOLR-59, echo of query parameters */-public class EchoParamsTest extends AbstractSolrTestCase {+public class EchoParamsTest extends SolrTestCaseJ4 {- public String getSchemaFile() { return "solr/crazy-path-to-schema.xml"; }- public String getSolrConfigFile() { return "solr/crazy-path-to-config.xml"; }+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solr/crazy-path-to-config.xml","solr/crazy-path-to-schema.xml");+ }private static final String HEADER_XPATH = "/response/lst[@name='responseHeader']";+ @Testpublic void testDefaultEchoParams() {lrf.args.put("wt", "xml");lrf.args.put("version", "2.2");@@ -35,6 +39,7 @@ public class EchoParamsTest extends AbstractSolrTestCase {assertQ(req("foo"),"not(//lst[@name='params'])");}+ @Testpublic void testDefaultEchoParamsDefaultVersion() {lrf.args.put("wt", "xml");lrf.args.remove("version");@@ -42,6 +47,7 @@ public class EchoParamsTest extends AbstractSolrTestCase {assertQ(req("foo"),"not(//lst[@name='params'])");}+ @Testpublic void testExplicitEchoParams() {lrf.args.put("wt", "xml");lrf.args.put("version", "2.2");@@ -51,6 +57,7 @@ public class EchoParamsTest extends AbstractSolrTestCase {assertQ(req("foo"),HEADER_XPATH + "/lst[@name='params']/str[@name='wt'][.='xml']");}+ @Testpublic void testAllEchoParams() {lrf = h.getRequestFactory("crazy_custom_qt", 0, 20,diff --git a/solr/src/test/org/apache/solr/MinimalSchemaTest.java b/solr/src/test/org/apache/solr/MinimalSchemaTest.javaindex bcb7726b921..b20c9417413 100644--- a/solr/src/test/org/apache/solr/MinimalSchemaTest.java+++ b/solr/src/test/org/apache/solr/MinimalSchemaTest.java@@ -17,52 +17,50 @@package org.apache.solr;-import org.apache.solr.request.*;-import org.apache.solr.util.*;+import org.junit.BeforeClass;+import org.junit.Test;++import static org.junit.Assert.*;import java.util.Set;/*** A test of basic features using the minial legal solr schema.*/-public class MinimalSchemaTest extends AbstractSolrTestCase {-- public String getSchemaFile() { return "solr/conf/schema-minimal.xml"; }--+public class MinimalSchemaTest extends SolrTestCaseJ4 {/**- * NOTE: we explicilty use the general 'solrconfig.xml' file here, in- * an attempt to test as many braod features as possible.+ * NOTE: we explicitly use the general 'solrconfig.xml' file here, in+ * an attempt to test as many broad features as possible.** Do not change this to point at some other "simpler" solrconfig.xml* just because you want to add a new test case using solrconfig.xml,* but your new testcase adds a feature that breaks this test.*/- public String getSolrConfigFile() { return "solr/conf/solrconfig.xml"; }-- public void setUp() throws Exception {- super.setUp();+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solr/conf/solrconfig.xml","solr/conf/schema-minimal.xml");- /* make sure some missguided soul doesn't inadvertantly give us- a uniqueKey field and defeat the point of hte tests+ /* make sure some misguided soul doesn't inadvertently give us+ a uniqueKey field and defeat the point of the tests*/assertNull("UniqueKey Field isn't null",h.getCore().getSchema().getUniqueKeyField());lrf.args.put("version","2.0");- assertU("Simple assertion that adding a document works",+ assertNull("Simple assertion that adding a document works", h.validateUpdate(adoc("id", "4055","subject", "Hoss",- "project", "Solr"));- assertU(adoc("id", "4056",+ "project", "Solr")));+ assertNull(h.validateUpdate(adoc("id", "4056","subject", "Yonik",- "project", "Solr"));- assertU(commit());- assertU(optimize());+ "project", "Solr")));+ assertNull(h.validateUpdate(commit()));+ assertNull(h.validateUpdate(optimize()));}+ @Testpublic void testSimpleQueries() {assertQ("couldn't find subject hoss",@@ -79,6 +77,7 @@ public class MinimalSchemaTest extends AbstractSolrTestCase {}/** SOLR-1371 */+ @Testpublic void testLuke() {assertQ("basic luke request failed",@@ -104,6 +103,7 @@ public class MinimalSchemaTest extends AbstractSolrTestCase {* them with a request (using some simple params) to verify that they* don't generate an error against the minimal schema*/+ @Testpublic void testAllConfiguredHandlers() {Set<String> handlerNames = h.getCore().getRequestHandlers().keySet();for (String handler : handlerNames) {diff --git a/solr/src/test/org/apache/solr/OutputWriterTest.java b/solr/src/test/org/apache/solr/OutputWriterTest.javaindex ecd92660ff0..c5c71f6b9d4 100644--- a/solr/src/test/org/apache/solr/OutputWriterTest.java+++ b/solr/src/test/org/apache/solr/OutputWriterTest.java@@ -24,23 +24,28 @@ import org.apache.solr.common.util.NamedList;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.response.QueryResponseWriter;import org.apache.solr.response.SolrQueryResponse;-import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.BeforeClass;+import org.junit.Test;++import static org.junit.Assert.*;/** Tests the ability to configure multiple query output writers, and select those* at query time.**/-public class OutputWriterTest extends AbstractSolrTestCase {+public class OutputWriterTest extends SolrTestCaseJ4 {/** The XML string that's output for testing purposes. */public static final String USELESS_OUTPUT = "useless output";- public String getSchemaFile() { return "solr/crazy-path-to-schema.xml"; }-- public String getSolrConfigFile() { return "solr/crazy-path-to-config.xml"; }+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solr/crazy-path-to-config.xml","solr/crazy-path-to-schema.xml");+ }/** responseHeader has changed in SOLR-59, check old and new variants */+ @Testpublic void testSOLR59responseHeaderVersions() {// default version is 2.2, with "new" responseHeaderlrf.args.remove("version");@@ -64,12 +69,14 @@ public class OutputWriterTest extends AbstractSolrTestCase {assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='QTime']");}+ @Testpublic void testUselessWriter() throws Exception {lrf.args.put("wt", "useless");String out = h.query(req("foo"));assertEquals(USELESS_OUTPUT, out);}+ @Testpublic void testTrivialXsltWriter() throws Exception {lrf.args.put("wt", "xslt");lrf.args.put("tr", "dummy.xsl");diff --git a/solr/src/test/org/apache/solr/SampleTest.java b/solr/src/test/org/apache/solr/SampleTest.javaindex 1d733809edf..5d869514f09 100644--- a/solr/src/test/org/apache/solr/SampleTest.java+++ b/solr/src/test/org/apache/solr/SampleTest.java@@ -19,36 +19,34 @@ package org.apache.solr;import org.apache.solr.request.*;import org.apache.solr.util.*;+import org.junit.BeforeClass;+import org.junit.Test;++import static org.junit.Assert.*;/*** This is an example of how to write a JUnit tests for Solr using the- * AbstractSolrTestCase+ * SolrTestCaseJ4*/-public class SampleTest extends AbstractSolrTestCase {+public class SampleTest extends SolrTestCaseJ4 {/**- * All subclasses of AbstractSolrTestCase must define this method.- *- * <p>- * Note that different tests can use different schemas by refering- * to any crazy path they want (as long as it works).- * </p>- */- public String getSchemaFile() { return "solr/crazy-path-to-schema.xml"; }-- /**- * All subclasses of AbstractSolrTestCase must define this method+ * All subclasses of SolrTestCaseJ4 should initialize the core.** <p>- * Note that different tests can use different configs by refering+ * Note that different tests can use different schemas/configs by referring* to any crazy path they want (as long as it works).* </p>*/- public String getSolrConfigFile() { return "solr/crazy-path-to-config.xml"; }+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solr/crazy-path-to-config.xml","solr/crazy-path-to-schema.xml");+ }/*** Demonstration of some of the simple ways to use the base class*/+ @Testpublic void testSimple() {lrf.args.put("version","2.0");assertU("Simple assertion that adding a document works",@@ -72,6 +70,7 @@ public class SampleTest extends AbstractSolrTestCase {/*** Demonstration of some of the more complex ways to use the base class*/+ @Testpublic void testAdvanced() throws Exception {lrf.args.put("version","2.0");assertU("less common case, a complex addition with options",diff --git a/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java b/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.javaindex e310206f3e1..3e768776392 100644--- a/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java+++ b/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java@@ -28,30 +28,32 @@ import org.apache.lucene.analysis.TokenStream;import org.apache.lucene.analysis.WhitespaceTokenizer;import org.apache.lucene.queryParser.ParseException;import org.apache.lucene.search.Query;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.schema.IndexSchema;import org.apache.solr.search.SolrQueryParser;-import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.Before;+import org.junit.BeforeClass;+import org.junit.Test;import static org.apache.solr.analysis.BaseTokenTestCase.*;-public class TestReversedWildcardFilterFactory extends AbstractSolrTestCase {+public class TestReversedWildcardFilterFactory extends SolrTestCaseJ4 {Map<String,String> args = new HashMap<String, String>();ReversedWildcardFilterFactory factory = new ReversedWildcardFilterFactory();IndexSchema schema;- public String getSchemaFile() {- return "schema-reversed.xml";- }-- public String getSolrConfigFile() {- return "solrconfig.xml";+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema-reversed.xml");}+ @Beforepublic void setUp() throws Exception {super.setUp();schema = new IndexSchema(solrConfig, getSchemaFile(), null);}+ @Testpublic void testReversedTokens() throws IOException {String text = "simple text";args.put("withOriginal", "true");@@ -70,6 +72,7 @@ public class TestReversedWildcardFilterFactory extends AbstractSolrTestCase {new int[] { 1, 1 });}+ @Testpublic void testIndexingAnalysis() throws Exception {Analyzer a = schema.getAnalyzer();String text = "one two three si\uD834\uDD1Ex";@@ -101,6 +104,7 @@ public class TestReversedWildcardFilterFactory extends AbstractSolrTestCase {);}+ @Testpublic void testQueryParsing() throws IOException, ParseException {SolrQueryParser parserOne = new SolrQueryParser(schema, "one");diff --git a/solr/src/test/org/apache/solr/core/TestConfig.java b/solr/src/test/org/apache/solr/core/TestConfig.javaindex 539e1af95c5..04b266feef8 100644--- a/solr/src/test/org/apache/solr/core/TestConfig.java+++ b/solr/src/test/org/apache/solr/core/TestConfig.java@@ -18,31 +18,32 @@package org.apache.solr.core;import org.apache.lucene.index.IndexWriter;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.handler.admin.ShowFileRequestHandler;import org.apache.solr.search.SolrIndexReader;import org.apache.solr.search.SolrIndexSearcher;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.solr.update.SolrIndexConfig;-import org.apache.solr.util.AbstractSolrTestCase;import org.apache.solr.util.RefCounted;+import org.junit.BeforeClass;+import org.junit.Test;import org.w3c.dom.Node;import org.w3c.dom.NodeList;+import static org.junit.Assert.*;+import javax.xml.xpath.XPathConstants;import java.io.IOException;import java.io.InputStream;-public class TestConfig extends AbstractSolrTestCase {-- public String getSchemaFile() {- return "schema.xml";- }+public class TestConfig extends SolrTestCaseJ4 {- //public String getSolrConfigFile() { return "solrconfig.xml"; }- public String getSolrConfigFile() {- return "solrconfig-termindex.xml";+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig-termindex.xml","schema-reversed.xml");}+ @Testpublic void testLib() throws IOException {SolrResourceLoader loader = h.getCore().getResourceLoader();InputStream data = null;@@ -68,6 +69,7 @@ public class TestConfig extends AbstractSolrTestCase {}}+ @Testpublic void testJavaProperty() {// property values defined in build.xml@@ -91,6 +93,7 @@ public class TestConfig extends AbstractSolrTestCase {assertEquals("prefix-proptwo-suffix", node.getTextContent());}+ @Testpublic void testLucene23Upgrades() throws Exception {double bufferSize = solrConfig.getDouble("indexDefaults/ramBufferSizeMB");assertTrue(bufferSize + " does not equal: " + 32, bufferSize == 32);@@ -103,6 +106,7 @@ public class TestConfig extends AbstractSolrTestCase {}// sometime if the config referes to old things, it must be replaced with new stuff+ @Testpublic void testAutomaticDeprecationSupport() {// make sure the "admin/file" handler is registeredShowFileRequestHandler handler = (ShowFileRequestHandler) h.getCore().getRequestHandler("/admin/file");@@ -114,6 +118,7 @@ public class TestConfig extends AbstractSolrTestCase {assertTrue(handler.getHiddenFiles().contains("PROTWORDS.TXT"));}+ @Testpublic void testTermIndexInterval() throws Exception {class ExposeWriterHandler extends DirectUpdateHandler2 {public ExposeWriterHandler() throws IOException {@@ -131,6 +136,7 @@ public class TestConfig extends AbstractSolrTestCase {assertEquals(256, interval);}+ @Testpublic void testTermIndexDivisor() throws Exception {IndexReaderFactory irf = h.getCore().getIndexReaderFactory();StandardIndexReaderFactory sirf = (StandardIndexReaderFactory) irf;diff --git a/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java b/solr/src/test/org/apache/solr/core/TestQuerySenderListener.javaindex 91e51def2cb..8cb657e4dab 100644--- a/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java+++ b/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java@@ -17,16 +17,22 @@package org.apache.solr.core;-import org.apache.solr.util.AbstractSolrTestCase;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.search.SolrIndexSearcher;import org.apache.solr.common.params.EventParams;import org.apache.lucene.store.Directory;+import org.junit.BeforeClass;+import org.junit.Test;+import static org.junit.Assert.*;-public class TestQuerySenderListener extends AbstractSolrTestCase {+public class TestQuerySenderListener extends SolrTestCaseJ4 {- @Override public String getSchemaFile() { return "schema.xml"; }- @Override public String getSolrConfigFile() { return "solrconfig-querysender.xml"; }+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig-querysender.xml","schema.xml");+ }+ @Testpublic void testRequestHandlerRegistry() {// property values defined in build.xmlSolrCore core = h.getCore();@@ -35,6 +41,7 @@ public class TestQuerySenderListener extends AbstractSolrTestCase {assertEquals( 1, core.newSearcherListeners.size() );}+ @Testpublic void testSearcherEvents() throws Exception {SolrCore core = h.getCore();SolrEventListener newSearcherListener = core.newSearcherListeners.get(0);diff --git a/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java b/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.javaindex aae2971dd7d..f45f81a2d73 100644--- a/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java+++ b/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java@@ -26,6 +26,7 @@ import java.util.HashMap;import java.util.Map;import org.apache.lucene.index.IndexReader;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.common.util.NamedList;@@ -34,14 +35,21 @@ import org.apache.solr.handler.component.QueryElevationComponent.ElevationObj;import org.apache.solr.request.LocalSolrQueryRequest;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.BeforeClass;+import org.junit.Test;+import static org.junit.Assert.*;-public class QueryElevationComponentTest extends AbstractSolrTestCase {- @Override public String getSchemaFile() { return "schema12.xml"; }- @Override public String getSolrConfigFile() { return "solrconfig-elevate.xml"; }+public class QueryElevationComponentTest extends SolrTestCaseJ4 {++ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig-elevate.xml","schema12.xml");+ }+ @Testpublic void testInterface() throws Exception{SolrCore core = h.getCore();@@ -86,6 +94,7 @@ public class QueryElevationComponentTest extends AbstractSolrTestCase {assertEquals( "xxxxyyyy", comp.getAnalyzedQuery( "XXXX YYYY" ) );}+ @Testpublic void testEmptyQuery() throws Exception {SolrCore core = h.getCore();@@ -101,7 +110,7 @@ public class QueryElevationComponentTest extends AbstractSolrTestCase {}-+ @Testpublic void testSorting() throws IOException{SolrCore core = h.getCore();@@ -221,6 +230,7 @@ public class QueryElevationComponentTest extends AbstractSolrTestCase {log.info( "OUT:"+file.getAbsolutePath() );}+ @Testpublic void testElevationReloading() throws Exception{SolrCore core = h.getCore();diff --git a/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java b/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.javaindex 7e361ee73cb..867f3e21ba2 100644--- a/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java+++ b/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java@@ -1,5 +1,6 @@package org.apache.solr.handler.component;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.util.AbstractSolrTestCase;import org.apache.solr.core.SolrCore;import org.apache.solr.common.params.ModifiableSolrParams;@@ -10,6 +11,10 @@ import org.apache.solr.common.util.SimpleOrderedMap;import org.apache.solr.request.SolrRequestHandler;import org.apache.solr.request.LocalSolrQueryRequest;import org.apache.solr.response.SolrQueryResponse;+import org.junit.BeforeClass;+import org.junit.Test;++import static org.junit.Assert.*;import java.util.HashMap;import java.util.ArrayList;@@ -36,36 +41,28 @@ import java.util.Arrays;****/-public class TermVectorComponentTest extends AbstractSolrTestCase {- @Override- public String getSchemaFile() {- return "schema.xml";- }-- @Override- public String getSolrConfigFile() {- return "solrconfig.xml";- }-- @Override- public void setUp() throws Exception {- super.setUp();- assertU(adoc("id", "0", "test_posofftv", "This is a title and another title"));- assertU(adoc("id", "1", "test_posofftv",- "The quick reb fox jumped over the lazy brown dogs."));- assertU(adoc("id", "2", "test_posofftv", "This is a document"));- assertU(adoc("id", "3", "test_posofftv", "another document"));+public class TermVectorComponentTest extends SolrTestCaseJ4 {+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");++ assertNull(h.validateUpdate(adoc("id", "0", "test_posofftv", "This is a title and another title")));+ assertNull(h.validateUpdate(adoc("id", "1", "test_posofftv",+ "The quick reb fox jumped over the lazy brown dogs.")));+ assertNull(h.validateUpdate(adoc("id", "2", "test_posofftv", "This is a document")));+ assertNull(h.validateUpdate(adoc("id", "3", "test_posofftv", "another document")));//bunch of docs that are variants on blue- assertU(adoc("id", "4", "test_posofftv", "blue"));- assertU(adoc("id", "5", "test_posofftv", "blud"));- assertU(adoc("id", "6", "test_posofftv", "boue"));- assertU(adoc("id", "7", "test_posofftv", "glue"));- assertU(adoc("id", "8", "test_posofftv", "blee"));- assertU(adoc("id", "9", "test_posofftv", "blah"));-- assertU("commit", commit());+ assertNull(h.validateUpdate(adoc("id", "4", "test_posofftv", "blue")));+ assertNull(h.validateUpdate(adoc("id", "5", "test_posofftv", "blud")));+ assertNull(h.validateUpdate(adoc("id", "6", "test_posofftv", "boue")));+ assertNull(h.validateUpdate(adoc("id", "7", "test_posofftv", "glue")));+ assertNull(h.validateUpdate(adoc("id", "8", "test_posofftv", "blee")));+ assertNull(h.validateUpdate(adoc("id", "9", "test_posofftv", "blah")));++ assertNull(h.validateUpdate(commit()));}+ @Testpublic void testBasics() throws Exception {SolrCore core = h.getCore();SearchComponent tvComp = core.getSearchComponent("tvComponent");@@ -104,6 +101,7 @@ public class TermVectorComponentTest extends AbstractSolrTestCase {}+ @Testpublic void testOptions() throws Exception {SolrCore core = h.getCore();SearchComponent tvComp = core.getSearchComponent("tvComponent");@@ -150,7 +148,7 @@ public class TermVectorComponentTest extends AbstractSolrTestCase {}-+ @Testpublic void testNoFields() throws Exception {SolrCore core = h.getCore();SearchComponent tvComp = core.getSearchComponent("tvComponent");@@ -175,6 +173,7 @@ public class TermVectorComponentTest extends AbstractSolrTestCase {assertTrue(doc.size() + " does not equal: " + 1, doc.size() == 1);}+ @Testpublic void testDistributed() throws Exception {SolrCore core = h.getCore();TermVectorComponent tvComp = (TermVectorComponent) core.getSearchComponent("tvComponent");diff --git a/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.java b/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.javaindex 3058f610b03..15896c0dba2 100644--- a/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.java+++ b/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.java@@ -19,14 +19,22 @@ package org.apache.solr.highlight;import java.util.HashMap;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.util.AbstractSolrTestCase;import org.apache.solr.util.TestHarness;+import org.junit.BeforeClass;+import org.junit.Test;-public class FastVectorHighlighterTest extends AbstractSolrTestCase {+import static org.junit.Assert.*;- @Override public String getSchemaFile() { return "schema.xml"; }- @Override public String getSolrConfigFile() { return "solrconfig.xml"; }+public class FastVectorHighlighterTest extends SolrTestCaseJ4 {++ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");+ }+ @Testpublic void testConfig(){SolrHighlighter highlighter = h.getCore().getHighlighter();@@ -49,6 +57,7 @@ public class FastVectorHighlighterTest extends AbstractSolrTestCase {assertTrue( solrFbSO instanceof ScoreOrderFragmentsBuilder );}+ @Testpublic void test() {HashMap<String,String> args = new HashMap<String,String>();args.put("hl", "true");diff --git a/solr/src/test/org/apache/solr/request/JSONWriterTest.java b/solr/src/test/org/apache/solr/request/JSONWriterTest.javaindex 015009f90c6..e108d354fc7 100644--- a/solr/src/test/org/apache/solr/request/JSONWriterTest.java+++ b/solr/src/test/org/apache/solr/request/JSONWriterTest.java@@ -21,6 +21,7 @@ import java.io.IOException;import java.io.Writer;import java.io.StringWriter;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.util.NamedList;import org.apache.solr.response.JSONResponseWriter;import org.apache.solr.response.PHPSerializedResponseWriter;@@ -28,16 +29,21 @@ import org.apache.solr.response.PythonResponseWriter;import org.apache.solr.response.QueryResponseWriter;import org.apache.solr.response.RubyResponseWriter;import org.apache.solr.response.SolrQueryResponse;-import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.BeforeClass;+import org.junit.Test;++import static org.junit.Assert.*;/** Test some aspects of JSON/python writer output (very incomplete)**/-public class JSONWriterTest extends AbstractSolrTestCase {-- public String getSchemaFile() { return "schema.xml"; }- public String getSolrConfigFile() { return "solrconfig.xml"; }-+public class JSONWriterTest extends SolrTestCaseJ4 {+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");+ }++ @Testpublic void testNaNInf() throws IOException {SolrQueryRequest req = req("dummy");SolrQueryResponse rsp = new SolrQueryResponse();@@ -57,6 +63,7 @@ public class JSONWriterTest extends AbstractSolrTestCase {}+ @Testpublic void testPHPS() throws IOException {SolrQueryRequest req = req("dummy");SolrQueryResponse rsp = new SolrQueryResponse();@@ -70,6 +77,7 @@ public class JSONWriterTest extends AbstractSolrTestCase {assertEquals(buf.toString(), "a:3:{s:5:\"data1\";s:5:\"hello\";s:5:\"data2\";i:42;s:5:\"data3\";b:1;}");}+ @Testpublic void testJSON() throws IOException {SolrQueryRequest req = req("wt","json","json.nl","arrarr");SolrQueryResponse rsp = new SolrQueryResponse();diff --git a/solr/src/test/org/apache/solr/schema/CopyFieldTest.java b/solr/src/test/org/apache/solr/schema/CopyFieldTest.javaindex 192f0f2723d..9c55959844a 100644--- a/solr/src/test/org/apache/solr/schema/CopyFieldTest.java+++ b/solr/src/test/org/apache/solr/schema/CopyFieldTest.java@@ -20,41 +20,28 @@ package org.apache.solr.schema;import java.util.HashMap;import java.util.Map;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.core.SolrCore;import org.apache.solr.request.LocalSolrQueryRequest;import org.apache.solr.request.SolrQueryRequest;-import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.BeforeClass;import org.junit.Test;+import static org.junit.Assert.*;+/*** This is a simple test to make sure the <code>CopyField</code> works.* It uses its own special schema file.** @since solr 1.4*/-public class CopyFieldTest extends AbstractSolrTestCase {-- @Override- public String getSchemaFile() {- return "schema-copyfield-test.xml";- }-- @Override- public String getSolrConfigFile() {- return "solrconfig.xml";- }-- @Override- public void setUp() throws Exception {- super.setUp();- }-- @Override- public void tearDown() throws Exception {- super.tearDown();- }+public class CopyFieldTest extends SolrTestCaseJ4 {+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema-copyfield-test.xml");+ }@Testpublic void testCopyFieldSchemaFieldSchemaField() {diff --git a/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java b/solr/src/test/org/apache/solr/schema/IndexSchemaTest.javaindex 52daaa75f7c..9a1d7b82050 100644--- a/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java+++ b/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java@@ -20,37 +20,32 @@ package org.apache.solr.schema;import java.util.HashMap;import java.util.Map;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.MapSolrParams;-import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.core.SolrCore;import org.apache.solr.request.LocalSolrQueryRequest;import org.apache.solr.request.SolrQueryRequest;-import org.apache.solr.util.AbstractSolrTestCase;import org.apache.lucene.search.Similarity;+import org.junit.BeforeClass;+import org.junit.Test;+import static org.junit.Assert.*;-public class IndexSchemaTest extends AbstractSolrTestCase {- @Override public String getSchemaFile() { return "schema.xml"; }- @Override public String getSolrConfigFile() { return "solrconfig.xml"; }-- @Override- public void setUp() throws Exception {- super.setUp();- }-- @Override- public void tearDown() throws Exception {- super.tearDown();- }+public class IndexSchemaTest extends SolrTestCaseJ4 {+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");+ }/*** This test assumes the schema includes:* <dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>* <dynamicField name="*_dynamic" type="string" indexed="true" stored="true"/>*/+ @Testpublic void testDynamicCopy(){SolrCore core = h.getCore();@@ -84,8 +79,10 @@ public class IndexSchemaTest extends AbstractSolrTestCase {,"//*[@numFound='1']","//result/doc[1]/int[@name='id'][.='10']");+ clearIndex();}+ @Testpublic void testSimilarityFactory() {SolrCore core = h.getCore();Similarity similarity = core.getSchema().getSimilarity();@@ -93,6 +90,7 @@ public class IndexSchemaTest extends AbstractSolrTestCase {assertEquals("is there an echo?", ((MockConfigurableSimilarity)similarity).getPassthrough());}+ @Testpublic void testRuntimeFieldCreation(){// any field manipulation needs to happen when you know the core will not@@ -128,8 +126,10 @@ public class IndexSchemaTest extends AbstractSolrTestCase {,"//*[@numFound='1']","//result/doc[1]/int[@name='id'][.='10']");+ clearIndex();}+ @Testpublic void testIsDynamicField() throws Exception {SolrCore core = h.getCore();IndexSchema schema = core.getSchema();@@ -138,6 +138,7 @@ public class IndexSchemaTest extends AbstractSolrTestCase {assertFalse( schema.isDynamicField( "no_such_field" ) );}+ @Testpublic void testProperties() throws Exception{SolrCore core = h.getCore();IndexSchema schema = core.getSchema();diff --git a/solr/src/test/org/apache/solr/schema/PolyFieldTest.java b/solr/src/test/org/apache/solr/schema/PolyFieldTest.javaindex 26ada0bd68a..5f82518b8be 100644--- a/solr/src/test/org/apache/solr/schema/PolyFieldTest.java+++ b/solr/src/test/org/apache/solr/schema/PolyFieldTest.java@@ -16,41 +16,34 @@ package org.apache.solr.schema;* limitations under the License.*/-import org.apache.lucene.document.Field;import org.apache.lucene.document.Fieldable;-import org.apache.lucene.document.Document;import org.apache.lucene.search.BooleanClause;import org.apache.lucene.search.BooleanQuery;import org.apache.lucene.search.Query;-import org.apache.lucene.search.TopDocs;-import org.apache.lucene.index.IndexReader;import org.apache.lucene.spatial.tier.CartesianPolyFilterBuilder;import org.apache.lucene.spatial.tier.Shape;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.core.SolrCore;-import org.apache.solr.util.AbstractSolrTestCase;import org.apache.solr.common.SolrException;import org.apache.solr.search.function.ValueSource;+import org.junit.BeforeClass;+import org.junit.Test;++import static org.junit.Assert.*;-import java.util.Map;-import java.util.Random;import java.util.List;/*** Test a whole slew of things related to PolyFields*/-public class PolyFieldTest extends AbstractSolrTestCase {-- @Override- public String getSchemaFile() {- return "schema.xml";- }-- @Override- public String getSolrConfigFile() {- return "solrconfig.xml";+public class PolyFieldTest extends SolrTestCaseJ4 {+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");}+ @Testpublic void testSchemaBasics() throws Exception {IndexSchema schema = h.getCore().getSchema();@@ -83,6 +76,7 @@ public class PolyFieldTest extends AbstractSolrTestCase {assertTrue(home.isPolyField());}+ @Testpublic void testPointFieldType() throws Exception {SolrCore core = h.getCore();IndexSchema schema = core.getSchema();@@ -132,6 +126,7 @@ public class PolyFieldTest extends AbstractSolrTestCase {assertEquals(v1.hashCode(), v2.hashCode());}+ @Testpublic void testSearching() throws Exception {for (int i = 0; i < 50; i++) {assertU(adoc("id", "" + i, "home", i + "," + (i * 100), "homed", (i * 1000) + "," + (i * 10000)));@@ -162,9 +157,10 @@ public class PolyFieldTest extends AbstractSolrTestCase {assertQEx("Query should throw an exception due to incorrect dimensions", req("fl", "*,score", "q","homed:[1 TO 2000]"), SolrException.ErrorCode.BAD_REQUEST);+ clearIndex();}-+ @Testpublic void testSearchDetails() throws Exception {SolrCore core = h.getCore();IndexSchema schema = core.getSchema();@@ -184,10 +180,10 @@ public class PolyFieldTest extends AbstractSolrTestCase {BooleanQuery bq = (BooleanQuery) q;BooleanClause[] clauses = bq.getClauses();assertEquals(clauses.length, 2);-+ clearIndex();}-+ @Testpublic void testCartesian() throws Exception {for (int i = 40; i < 50; i++) {for (int j = -85; j < -79; j++) {@@ -219,7 +215,7 @@ public class PolyFieldTest extends AbstractSolrTestCase {assertQ(req("fl", "*,score", "q", qry.toString()),"//*[@numFound='1']");-+ clearIndex();}}\ No newline at end of filediff --git a/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.java b/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.javaindex aee39b1655c..cccbdc7fa04 100644--- a/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.java+++ b/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.java@@ -19,29 +19,23 @@ package org.apache.solr.schema;import java.util.Collection;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.core.SolrCore;import org.apache.solr.schema.SchemaField;-import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.BeforeClass;+import org.junit.Test;+import static org.junit.Assert.*;/****/-public class RequiredFieldsTest extends AbstractSolrTestCase {-- @Override public String getSchemaFile() { return "schema-required-fields.xml"; }- @Override public String getSolrConfigFile() { return "solrconfig.xml"; }-- @Override- public void setUp() throws Exception {- super.setUp();+public class RequiredFieldsTest extends SolrTestCaseJ4 {+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema-required-fields.xml");}- @Override- public void tearDown() throws Exception {- super.tearDown();- }--+ @Testpublic void testRequiredFieldsConfig() {SolrCore core = h.getCore();IndexSchema schema = core.getSchema();@@ -57,6 +51,7 @@ public class RequiredFieldsTest extends AbstractSolrTestCase {assertEquals( numDefaultFields+1+1, requiredFields.size()); // also the uniqueKey}+ @Testpublic void testRequiredFieldsSingleAdd() {SolrCore core = h.getCore();// Add a single document@@ -85,9 +80,11 @@ public class RequiredFieldsTest extends AbstractSolrTestCase {assertU(commit());// Check to make sure this submission did not succeed- assertQ("should not find any", req("id:531") ,"//result[@numFound=0]" );+ assertQ("should not find any", req("id:531") ,"//result[@numFound=0]" );+ clearIndex();}+ @Testpublic void testAddMultipleDocumentsWithErrors() {//Add three documents at once to make sure the baseline succeedsassertU("adding 3 documents",diff --git a/solr/src/test/org/apache/solr/search/QueryParsingTest.java b/solr/src/test/org/apache/solr/search/QueryParsingTest.javaindex 637253c5c05..8c7b20245be 100644--- a/solr/src/test/org/apache/solr/search/QueryParsingTest.java+++ b/solr/src/test/org/apache/solr/search/QueryParsingTest.java@@ -18,25 +18,25 @@ package org.apache.solr.search;import org.apache.lucene.search.Sort;import org.apache.lucene.search.SortField;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.SolrException;import org.apache.solr.schema.IndexSchema;-import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.BeforeClass;+import org.junit.Test;+import static org.junit.Assert.*;/******/-public class QueryParsingTest extends AbstractSolrTestCase {- public String getSchemaFile() {- return "schema.xml";+public class QueryParsingTest extends SolrTestCaseJ4 {+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");}- public String getSolrConfigFile() {- return "solrconfig.xml";- }--+ @Testpublic void testSort() throws Exception {Sort sort;@@ -152,6 +152,7 @@ public class QueryParsingTest extends AbstractSolrTestCase {}+ @Testpublic void testBad() throws Exception {Sort sort;diff --git a/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java b/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.javaindex 52b28569a3c..ea133246d33 100644--- a/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java+++ b/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java@@ -17,11 +17,16 @@package org.apache.solr.spelling;-import org.apache.solr.util.AbstractSolrTestCase;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.util.NamedList;import org.apache.solr.core.SolrCore;import org.apache.lucene.index.IndexReader;import org.apache.lucene.analysis.Token;+import org.junit.AfterClass;+import org.junit.BeforeClass;+import org.junit.Test;++import static org.junit.Assert.*;import java.io.File;import java.util.Date;@@ -32,29 +37,29 @@ import java.util.Collection;** @since solr 1.3**/-public class FileBasedSpellCheckerTest extends AbstractSolrTestCase{-- public String getSchemaFile() { return "schema.xml"; }- public String getSolrConfigFile() { return "solrconfig.xml"; }+public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {- private SpellingQueryConverter queryConverter;+ private static SpellingQueryConverter queryConverter;- @Override- public void setUp() throws Exception {- super.setUp();+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");//Index something with a title- assertU(adoc("id", "0", "teststop", "This is a title"));- assertU(adoc("id", "1", "teststop", "The quick reb fox jumped over the lazy brown dogs."));- assertU(adoc("id", "2", "teststop", "This is a Solr"));- assertU(adoc("id", "3", "teststop", "solr foo"));- assertU("commit",- commit());- String allq = "id:[0 TO 3]";- assertQ("docs not added", req(allq));+ assertNull(h.validateUpdate(adoc("id", "0", "teststop", "This is a title")));+ assertNull(h.validateUpdate(adoc("id", "1", "teststop", "The quick reb fox jumped over the lazy brown dogs.")));+ assertNull(h.validateUpdate(adoc("id", "2", "teststop", "This is a Solr")));+ assertNull(h.validateUpdate(adoc("id", "3", "teststop", "solr foo")));+ assertNull(h.validateUpdate(commit()));queryConverter = new SimpleQueryConverter();queryConverter.init(new NamedList());}++ @AfterClass+ public static void afterClass() throws Exception {+ queryConverter = null;+ }+ @Testpublic void test() throws Exception {FileBasedSpellChecker checker = new FileBasedSpellChecker();NamedList spellchecker = new NamedList();@@ -92,6 +97,7 @@ public class FileBasedSpellCheckerTest extends AbstractSolrTestCase{}+ @Testpublic void testFieldType() throws Exception {FileBasedSpellChecker checker = new FileBasedSpellChecker();NamedList spellchecker = new NamedList();@@ -135,6 +141,7 @@ public class FileBasedSpellCheckerTest extends AbstractSolrTestCase{* No indexDir location set* @throws Exception*/+ @Testpublic void testRAMDirectory() throws Exception {FileBasedSpellChecker checker = new FileBasedSpellChecker();NamedList spellchecker = new NamedList();diff --git a/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java b/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.javaindex 5c7258f14f6..ba772ac83ba 100644--- a/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java+++ b/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java@@ -16,6 +16,8 @@*/package org.apache.solr.spelling;+import static org.junit.Assert.*;+import org.apache.lucene.analysis.Token;import org.apache.lucene.analysis.WhitespaceAnalyzer;import org.apache.lucene.document.Document;@@ -26,11 +28,14 @@ import org.apache.lucene.search.spell.JaroWinklerDistance;import org.apache.lucene.search.spell.SpellChecker;import org.apache.lucene.search.spell.StringDistance;import org.apache.lucene.store.FSDirectory;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.util.NamedList;import org.apache.solr.core.SolrCore;-import org.apache.solr.util.AbstractSolrTestCase;import org.apache.solr.util.RefCounted;import org.apache.solr.search.SolrIndexSearcher;+import org.junit.AfterClass;+import org.junit.BeforeClass;+import org.junit.Test;import java.io.File;import java.util.Collection;@@ -40,8 +45,8 @@ import java.util.Map;/*** @since solr 1.3*/-public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {- protected SpellingQueryConverter queryConverter;+public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {+ protected static SpellingQueryConverter queryConverter;protected static String[] DOCS = new String[]{"This is a title",@@ -54,28 +59,23 @@ public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {};- public String getSchemaFile() {- return "schema.xml";- }-- public String getSolrConfigFile() {- return "solrconfig.xml";- }-- @Override- public void setUp() throws Exception {- super.setUp();+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");//Index something with a titlefor (int i = 0; i < DOCS.length; i++) {- assertU(adoc("id", String.valueOf(i), "title", DOCS[i]));+ assertNull(h.validateUpdate(adoc("id", String.valueOf(i), "title", DOCS[i])));}- assertU("commit",- commit());- String allq = "id:[0 TO 3]";- assertQ("docs not added", req(allq));+ assertNull(h.validateUpdate(commit()));queryConverter = new SimpleQueryConverter();}++ @AfterClass+ public static void afterClass() throws Exception {+ queryConverter = null;+ }+ @Testpublic void testSpelling() throws Exception {IndexBasedSpellChecker checker = new IndexBasedSpellChecker();@@ -151,6 +151,7 @@ public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {}}+ @Testpublic void testExtendedResults() throws Exception {IndexBasedSpellChecker checker = new IndexBasedSpellChecker();NamedList spellchecker = new NamedList();@@ -206,6 +207,7 @@ public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {}}+ @Testpublic void testAlternateDistance() throws Exception {TestSpellChecker checker = new TestSpellChecker();NamedList spellchecker = new NamedList();@@ -236,6 +238,7 @@ public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {}}+ @Testpublic void testAlternateLocation() throws Exception {String[] ALT_DOCS = new String[]{"jumpin jack flash",diff --git a/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java b/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.javaindex e383e8823d8..eae5f2f71f3 100644--- a/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java+++ b/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java@@ -17,6 +17,7 @@package org.apache.solr.util;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.util.SolrPluginUtils;import org.apache.solr.util.SolrPluginUtils.DisjunctionMaxQueryParser;import org.apache.solr.core.SolrCore;@@ -37,6 +38,10 @@ import org.apache.lucene.search.BooleanQuery;import org.apache.lucene.search.BooleanClause;import org.apache.lucene.search.MatchAllDocsQuery;import org.apache.lucene.search.BooleanClause.Occur;+import org.junit.BeforeClass;+import org.junit.Test;++import static org.junit.Assert.*;import java.util.List;import java.util.Map;@@ -48,12 +53,14 @@ import java.util.HashSet;/*** Tests that the functions in SolrPluginUtils work as advertised.*/-public class SolrPluginUtilsTest extends AbstractSolrTestCase {-- public String getSchemaFile() { return "schema.xml"; }- public String getSolrConfigFile() { return "solrconfig.xml"; }+public class SolrPluginUtilsTest extends SolrTestCaseJ4 {+ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml","schema.xml");+ }+ @Testpublic void testDocListConversion() throws Exception {assertU("", adoc("id", "3234", "val_t", "quick red fox"));assertU("", adoc("id", "3235", "val_t", "quick green fox"));@@ -78,6 +85,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {}+ @Testpublic void testPartialEscape() {assertEquals("",pe(""));@@ -91,6 +99,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {}+ @Testpublic void testStripUnbalancedQuotes() {assertEquals("",strip(""));@@ -102,6 +111,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {}+ @Testpublic void testStripIllegalOperators() {assertEquals("",stripOp(""));@@ -120,6 +130,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {}+ @Testpublic void testParseFieldBoosts() throws Exception {Map<String,Float> e1 = new HashMap<String,Float>();@@ -145,7 +156,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {(" \t "));}-+ @Testpublic void testDisjunctionMaxQueryParser() throws Exception {Query out;@@ -277,7 +288,8 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {}return count;}-++ @Testpublic void testMinShouldMatchCalculator() {/* zero is zero is zero */