mirror of
https://github.com/apache/lucene.git
synced 2025-02-24 11:16:35 +00:00
SOLR-11754: remove AbstractSolrTestCase; use SolrTestCaseJ4 instead.
Also removed SolrExampleTestBase in Solrj-tests.
This commit is contained in:
parent
63cba40931
commit
f354a278f8
@ -74,6 +74,8 @@ Other Changes
|
||||
* SOLR-11757: In tests, fix race condition on SolrException.ignoreException.
|
||||
Also ensure we register "ignore_exception" in @BeforeClass (previously only @AfterClass) (David Smiley)
|
||||
|
||||
* SOLR-11754: Remove AbstractSolrTestCase which has long been supplanted by SolrTestCaseJ4. (David Smiley)
|
||||
|
||||
================== 7.2.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
@ -57,7 +57,7 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests some basic functionality of Solr while demonstrating good
|
||||
* Best Practices for using AbstractSolrTestCase
|
||||
* Best Practices for using SolrTestCaseJ4
|
||||
*/
|
||||
public class BasicFunctionalityTest extends SolrTestCaseJ4 {
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import junit.framework.Assert;
|
||||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
import org.apache.solr.common.cloud.ZkCmdExecutor;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.zookeeper.CreateMode;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.WatchedEvent;
|
||||
@ -31,7 +31,7 @@ import org.apache.zookeeper.Watcher;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public class ZkSolrClientTest extends AbstractSolrTestCase {
|
||||
public class ZkSolrClientTest extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -18,7 +18,7 @@ package org.apache.solr.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.util.DOMUtilTestBase;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Node;
|
||||
@ -63,14 +63,14 @@ public class PluginInfoTest extends DOMUtilTestBase {
|
||||
@Test
|
||||
public void testNameRequired() throws Exception {
|
||||
Node nodeWithNoName = getNode("<plugin></plugin>", "plugin");
|
||||
AbstractSolrTestCase.ignoreException("missing mandatory attribute");
|
||||
SolrTestCaseJ4.ignoreException("missing mandatory attribute");
|
||||
try {
|
||||
PluginInfo pi = new PluginInfo(nodeWithNoName, "Node with No name", true, false);
|
||||
fail("Exception should have been thrown");
|
||||
} catch (RuntimeException e) {
|
||||
assertTrue(e.getMessage().contains("missing mandatory attribute"));
|
||||
} finally {
|
||||
AbstractSolrTestCase.resetExceptionIgnores();
|
||||
SolrTestCaseJ4.resetExceptionIgnores();
|
||||
}
|
||||
Node nodeWithAName = getNode("<plugin name=\"myName\" />", "plugin");
|
||||
PluginInfo pi2 = new PluginInfo(nodeWithAName, "Node with a Name", true, false);
|
||||
@ -80,7 +80,7 @@ public class PluginInfoTest extends DOMUtilTestBase {
|
||||
@Test
|
||||
public void testClassRequired() throws Exception {
|
||||
Node nodeWithNoClass = getNode("<plugin></plugin>", "plugin");
|
||||
AbstractSolrTestCase.ignoreException("missing mandatory attribute");
|
||||
SolrTestCaseJ4.ignoreException("missing mandatory attribute");
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
PluginInfo pi = new PluginInfo(nodeWithNoClass, "Node with No Class", false, true);
|
||||
@ -88,7 +88,7 @@ public class PluginInfoTest extends DOMUtilTestBase {
|
||||
} catch (RuntimeException e) {
|
||||
assertTrue(e.getMessage().contains("missing mandatory attribute"));
|
||||
} finally {
|
||||
AbstractSolrTestCase.resetExceptionIgnores();
|
||||
SolrTestCaseJ4.resetExceptionIgnores();
|
||||
}
|
||||
Node nodeWithAClass = getNode("<plugin class=\"myName\" />", "plugin");
|
||||
PluginInfo pi2 = new PluginInfo(nodeWithAClass, "Node with a Class", false, true);
|
||||
|
@ -20,7 +20,7 @@ import org.apache.solr.metrics.SolrMetricManager;
|
||||
import org.apache.solr.metrics.SolrMetricReporter;
|
||||
import org.apache.solr.metrics.reporters.jmx.JmxObjectNameFactory;
|
||||
import org.apache.solr.metrics.reporters.SolrJmxReporter;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -44,7 +44,7 @@ import java.util.Set;
|
||||
*
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class TestJmxIntegration extends AbstractSolrTestCase {
|
||||
public class TestJmxIntegration extends SolrTestCaseJ4 {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
@ -21,14 +21,14 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.apache.solr.schema.IndexSchema;
|
||||
import org.apache.solr.update.processor.RegexReplaceProcessorFactory;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.Assume;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
* Test both XInclude as well as more old school "entity includes"
|
||||
*/
|
||||
public class TestXIncludeConfig extends AbstractSolrTestCase {
|
||||
public class TestXIncludeConfig extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -16,13 +16,13 @@
|
||||
*/
|
||||
package org.apache.solr.handler;
|
||||
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
* Most of the tests for {@link org.apache.solr.handler.component.SearchHandler} are in {@link org.apache.solr.ConvertedLegacyTest}.
|
||||
*/
|
||||
public class SearchHandlerTest extends AbstractSolrTestCase {
|
||||
public class SearchHandlerTest extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -23,7 +23,7 @@ import org.apache.solr.common.luke.FieldFlag;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.schema.CustomAnalyzerStrField; // jdoc
|
||||
import org.apache.solr.schema.IndexSchema;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.util.TestHarness;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@ -32,7 +32,7 @@ import org.junit.Test;
|
||||
/**
|
||||
* :TODO: currently only tests some of the utilities in the LukeRequestHandler
|
||||
*/
|
||||
public class LukeRequestHandlerTest extends AbstractSolrTestCase {
|
||||
public class LukeRequestHandlerTest extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -18,7 +18,7 @@ package org.apache.solr.handler.admin;
|
||||
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.solr.index.LogDocMergePolicyFactory;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -26,7 +26,7 @@ import org.junit.Test;
|
||||
/**
|
||||
* Tests for SegmentsInfoRequestHandler. Plugin entry, returning data of created segment.
|
||||
*/
|
||||
public class SegmentsInfoRequestHandlerTest extends AbstractSolrTestCase {
|
||||
public class SegmentsInfoRequestHandlerTest extends SolrTestCaseJ4 {
|
||||
private static final int DOC_COUNT = 5;
|
||||
|
||||
private static final int DEL_COUNT = 1;
|
||||
|
@ -50,7 +50,7 @@ import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.schema.SchemaField;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
|
||||
import org.apache.commons.math3.util.Combinations;
|
||||
import com.tdunning.math.stats.AVLTreeDigest;
|
||||
@ -62,7 +62,7 @@ import org.junit.BeforeClass;
|
||||
/**
|
||||
* Statistics Component Test
|
||||
*/
|
||||
public class StatsComponentTest extends AbstractSolrTestCase {
|
||||
public class StatsComponentTest extends SolrTestCaseJ4 {
|
||||
|
||||
final static String XPRE = "/response/lst[@name='stats']/";
|
||||
|
||||
|
@ -20,13 +20,13 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.solr.handler.component.HighlightComponent;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.util.TestHarness;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class HighlighterConfigTest extends AbstractSolrTestCase {
|
||||
public class HighlighterConfigTest extends SolrTestCaseJ4 {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
@ -30,14 +30,14 @@ import org.apache.solr.client.solrj.impl.XMLResponseParser;
|
||||
import org.apache.solr.response.BinaryQueryResponseWriter;
|
||||
import org.apache.solr.response.QueryResponseWriter;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.util.RTimer;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class TestWriterPerf extends AbstractSolrTestCase {
|
||||
public class TestWriterPerf extends SolrTestCaseJ4 {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
@ -30,7 +30,7 @@ import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.response.BinaryResponseWriter.Resolver;
|
||||
import org.apache.solr.search.SolrReturnFields;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
@ -39,7 +39,7 @@ import org.junit.BeforeClass;
|
||||
*
|
||||
* @since solr 1.4
|
||||
*/
|
||||
public class TestBinaryResponseWriter extends AbstractSolrTestCase {
|
||||
public class TestBinaryResponseWriter extends SolrTestCaseJ4 {
|
||||
|
||||
|
||||
@BeforeClass
|
||||
|
@ -19,14 +19,14 @@ package org.apache.solr.search;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.HighlightParams;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.util.TestHarness;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TestComplexPhraseQParserPlugin extends AbstractSolrTestCase {
|
||||
public class TestComplexPhraseQParserPlugin extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -21,7 +21,7 @@ import org.apache.solr.legacy.LegacyNumericRangeQuery;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.solr.common.params.MapSolrParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -30,7 +30,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
public class TestMaxScoreQueryParser extends AbstractSolrTestCase {
|
||||
public class TestMaxScoreQueryParser extends SolrTestCaseJ4 {
|
||||
Query q;
|
||||
BooleanClause[] clauses;
|
||||
|
||||
|
@ -18,11 +18,11 @@ package org.apache.solr.search;
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestQueryTypes extends AbstractSolrTestCase {
|
||||
public class TestQueryTypes extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -21,7 +21,7 @@ import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -29,7 +29,7 @@ import java.util.Collection;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestQueryUtils extends AbstractSolrTestCase {
|
||||
public class TestQueryUtils extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -18,7 +18,7 @@ package org.apache.solr.search;
|
||||
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
|
||||
@ -34,7 +34,7 @@ import java.io.IOException;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestSearchPerf extends AbstractSolrTestCase {
|
||||
public class TestSearchPerf extends SolrTestCaseJ4 {
|
||||
|
||||
|
||||
@BeforeClass
|
||||
|
@ -16,10 +16,10 @@
|
||||
*/
|
||||
package org.apache.solr.search;
|
||||
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public class TestSurroundQueryParser extends AbstractSolrTestCase {
|
||||
public class TestSurroundQueryParser extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.solr.search.function;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import org.junit.BeforeClass;
|
||||
*
|
||||
* @see TestSortByMinMaxFunction
|
||||
**/
|
||||
public class SortByFunctionTest extends AbstractSolrTestCase {
|
||||
public class SortByFunctionTest extends SolrTestCaseJ4 {
|
||||
|
||||
|
||||
@BeforeClass
|
||||
|
@ -35,7 +35,7 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests some basic functionality of Solr while demonstrating good
|
||||
* Best Practices for using AbstractSolrTestCase
|
||||
* Best Practices for using SolrTestCaseJ4
|
||||
*/
|
||||
public class TestFunctionQuery extends SolrTestCaseJ4 {
|
||||
@BeforeClass
|
||||
|
@ -41,7 +41,7 @@ import org.apache.solr.common.util.Base64;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
import org.apache.solr.handler.admin.SecurityConfHandler;
|
||||
import org.apache.solr.handler.admin.SecurityConfHandlerLocalForTesting;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.util.LogLevel;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@ -54,10 +54,10 @@ import static org.apache.solr.security.BasicAuthIntegrationTest.NOT_NULL_PREDICA
|
||||
import static org.apache.solr.security.BasicAuthIntegrationTest.STD_CONF;
|
||||
import static org.apache.solr.security.BasicAuthIntegrationTest.verifySecurityStatus;
|
||||
|
||||
public class BasicAuthStandaloneTest extends AbstractSolrTestCase {
|
||||
public class BasicAuthStandaloneTest extends SolrTestCaseJ4 {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private Path ROOT_DIR = Paths.get(getSolrHome());
|
||||
private Path ROOT_DIR = Paths.get(TEST_HOME());
|
||||
private Path CONF_DIR = ROOT_DIR.resolve("configsets").resolve("configset-2").resolve("conf");
|
||||
|
||||
SecurityConfHandlerLocalForTesting securityConfHandler;
|
||||
|
@ -19,12 +19,12 @@ package org.apache.solr.servlet;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
||||
|
||||
public class DirectSolrConnectionTest extends AbstractSolrTestCase
|
||||
public class DirectSolrConnectionTest extends SolrTestCaseJ4
|
||||
{
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ import java.io.FileFilter;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ import org.junit.BeforeClass;
|
||||
*
|
||||
*
|
||||
**/
|
||||
public class DirectUpdateHandlerOptimizeTest extends AbstractSolrTestCase {
|
||||
public class DirectUpdateHandlerOptimizeTest extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -31,7 +31,8 @@ import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.SolrEventListener;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.util.TestHarness;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
@ -57,7 +58,7 @@ import org.slf4j.LoggerFactory;
|
||||
* </ul>
|
||||
*/
|
||||
@Slow
|
||||
public class SoftAutoCommitTest extends AbstractSolrTestCase {
|
||||
public class SoftAutoCommitTest extends SolrTestCaseJ4 {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@BeforeClass
|
||||
@ -529,6 +530,15 @@ public class SoftAutoCommitTest extends AbstractSolrTestCase {
|
||||
};
|
||||
public abstract int useValue(final int softCommitWaitMillis, final int hardCommitWaitMillis);
|
||||
}
|
||||
|
||||
public String delI(String id, String... args) {
|
||||
return TestHarness.deleteById(id, args);
|
||||
}
|
||||
|
||||
public String adoc(int commitWithin, String... fieldsAndValues) {
|
||||
XmlDoc d = doc(fieldsAndValues);
|
||||
return add(d, "commitWithin", String.valueOf(commitWithin));
|
||||
}
|
||||
}
|
||||
|
||||
class MockEventListener implements SolrEventListener {
|
||||
|
@ -18,7 +18,7 @@ package org.apache.solr.update;
|
||||
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.util.RTimer;
|
||||
import org.junit.AfterClass;
|
||||
@ -36,7 +36,7 @@ import java.util.Arrays;
|
||||
*
|
||||
* $ ant test -Dtestcase=TestIndexingPerformance -Dargs="-server -Diter=100000"; grep throughput build/test-results/*TestIndexingPerformance.xml
|
||||
*/
|
||||
public class TestIndexingPerformance extends AbstractSolrTestCase {
|
||||
public class TestIndexingPerformance extends SolrTestCaseJ4 {
|
||||
|
||||
// TODO: fix this test to not require FSDirectory
|
||||
static String savedFactory;
|
||||
|
@ -24,12 +24,12 @@ import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.handler.UpdateRequestHandler;
|
||||
import org.apache.solr.request.SolrQueryRequestBase;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
||||
|
||||
public class UpdateParamsTest extends AbstractSolrTestCase {
|
||||
public class UpdateParamsTest extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
@ -26,7 +26,7 @@ import java.util.List;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
||||
public class UpdateRequestProcessorFactoryTest extends SolrTestCaseJ4 {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
@ -40,7 +40,7 @@ import java.util.Arrays;
|
||||
* @since solr 1.4
|
||||
*
|
||||
*/
|
||||
public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
|
||||
public abstract class MergeIndexesExampleTestBase extends SolrTestCaseJ4 {
|
||||
|
||||
protected CoreContainer cores;
|
||||
private String saveProp;
|
||||
@ -49,16 +49,10 @@ public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@Override
|
||||
public String getSolrHome() {
|
||||
static String getSolrHome() {
|
||||
return SolrTestCaseJ4.getFile("solrj/solr/multicore").getAbsolutePath();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass2() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
protected void setupCoreContainer() {
|
||||
cores = new CoreContainer(getSolrHome());
|
||||
cores.load();
|
||||
@ -93,16 +87,6 @@ public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
|
||||
else System.setProperty("solr.directoryFactory", saveProp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final SolrClient getSolrClient() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final SolrClient createNewSolrClient() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
protected abstract SolrClient getSolrCore0();
|
||||
|
||||
protected abstract SolrClient getSolrCore1();
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.solr.client.solrj;
|
||||
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
* This should include tests against the example solr config
|
||||
*
|
||||
* This lets us try various SolrServer implementations with the same tests.
|
||||
*
|
||||
*/
|
||||
abstract public class SolrExampleTestBase extends AbstractSolrTestCase {
|
||||
@Override
|
||||
public String getSolrHome() {
|
||||
return "../../../example/solr/";
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// this sets the property for jetty starting SolrDispatchFilter
|
||||
System.setProperty("solr.solr.home", this.getSolrHome());
|
||||
System.setProperty("solr.data.dir", this.initCoreDataDir.getCanonicalPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
System.clearProperty("solr.solr.home");
|
||||
System.clearProperty("solr.data.dir");
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses need to initialize the server impl
|
||||
*/
|
||||
protected abstract SolrClient getSolrClient();
|
||||
|
||||
/**
|
||||
* Create a new solr server
|
||||
*/
|
||||
protected abstract SolrClient createNewSolrClient();
|
||||
}
|
@ -118,7 +118,6 @@ import org.apache.solr.schema.IndexSchema;
|
||||
import org.apache.solr.schema.SchemaField;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.servlet.DirectSolrConnection;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.util.LogLevel;
|
||||
import org.apache.solr.util.RandomizeSSL;
|
||||
import org.apache.solr.util.RandomizeSSL.SSLRandomizer;
|
||||
@ -149,10 +148,9 @@ import static org.apache.solr.update.processor.DistributedUpdateProcessor.Distri
|
||||
import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
|
||||
|
||||
/**
|
||||
* A junit4 Solr test harness that extends LuceneTestCaseJ4. To change which core is used when loading the schema and solrconfig.xml, simply
|
||||
* A junit4 Solr test harness that extends LuceneTestCaseJ4.
|
||||
* To change which core is used when loading the schema and solrconfig.xml, simply
|
||||
* invoke the {@link #initCore(String, String, String, String)} method.
|
||||
*
|
||||
* Unlike {@link AbstractSolrTestCase}, a new core is not created for each test method.
|
||||
*/
|
||||
@ThreadLeakFilters(defaultFilters = true, filters = {
|
||||
SolrIgnoredThreadsFilter.class,
|
||||
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.solr.util;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.lucene.util.QuickPatchThreadsFilter;
|
||||
import org.apache.solr.SolrIgnoredThreadsFilter;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.core.SolrConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
|
||||
/**
|
||||
* An Abstract base class that makes writing Solr JUnit tests "easier"
|
||||
*
|
||||
* <p>
|
||||
* Test classes that subclass this need only specify the path to the
|
||||
* schema.xml file (:TODO: the solrconfig.xml as well) and write some
|
||||
* testMethods. This class takes care of creating/destroying the index,
|
||||
* and provides several assert methods to assist you.
|
||||
* </p>
|
||||
*
|
||||
* @see #setUp
|
||||
* @see #tearDown
|
||||
*/
|
||||
@ThreadLeakFilters(defaultFilters = true, filters = {
|
||||
SolrIgnoredThreadsFilter.class,
|
||||
QuickPatchThreadsFilter.class
|
||||
})
|
||||
public abstract class AbstractSolrTestCase extends SolrTestCaseJ4 {
|
||||
protected SolrConfig solrConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Subclasses can override this to change a test's solr home
|
||||
* (default is in test-files)
|
||||
*/
|
||||
public String getSolrHome() {
|
||||
return SolrTestCaseJ4.TEST_HOME();
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
||||
/** Causes an exception matching the regex pattern to not be logged. */
|
||||
public static void ignoreException(String pattern) {
|
||||
if (SolrException.ignorePatterns == null)
|
||||
SolrException.ignorePatterns = new HashSet<>();
|
||||
SolrException.ignorePatterns.add(pattern);
|
||||
}
|
||||
|
||||
public static void resetExceptionIgnores() {
|
||||
SolrException.ignorePatterns = null;
|
||||
ignoreException("ignore_exception"); // always ignore "ignore_exception"
|
||||
}
|
||||
|
||||
/** Subclasses that override setUp can optionally call this method
|
||||
* to log the fact that their setUp process has ended.
|
||||
*/
|
||||
@Override
|
||||
public void postSetUp() {
|
||||
log.info("####POSTSETUP " + getTestName());
|
||||
}
|
||||
|
||||
|
||||
/** Subclasses that override tearDown can optionally call this method
|
||||
* to log the fact that the tearDown process has started. This is necessary
|
||||
* since subclasses will want to call super.tearDown() at the *end* of their
|
||||
* tearDown method.
|
||||
*/
|
||||
@Override
|
||||
public void preTearDown() {
|
||||
log.info("####PRETEARDOWN " + getTestName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a simple <add><doc>... XML String with the
|
||||
* commitWithin attribute.
|
||||
*
|
||||
* @param commitWithin the value of the commitWithin attribute
|
||||
* @param fieldsAndValues 0th and Even numbered args are fields names odds are field values.
|
||||
* @see #add
|
||||
* @see #doc
|
||||
*/
|
||||
public String adoc(int commitWithin, String... fieldsAndValues) {
|
||||
XmlDoc d = doc(fieldsAndValues);
|
||||
return add(d, "commitWithin", String.valueOf(commitWithin));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a <delete>... XML string for an ID
|
||||
*
|
||||
* @see TestHarness#deleteById
|
||||
*/
|
||||
public String delI(String id, String... args) {
|
||||
return TestHarness.deleteById(id, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <delete>... XML string for an query
|
||||
*
|
||||
* @see TestHarness#deleteByQuery
|
||||
*/
|
||||
public String delQ(String q, String... args) {
|
||||
return TestHarness.deleteByQuery(q, args);
|
||||
}
|
||||
|
||||
/** @see SolrTestCaseJ4#getFile */
|
||||
public static File getFile(String name) {
|
||||
return SolrTestCaseJ4.getFile(name);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user