Apache Solr open-source search software
SOLR-18067: Migrate tests from EmbeddedSolrServerTestBase to EmbeddedSolrServerTestRule (#4041)
Eric Pugh1c1135963a15
diff --git a/changelog/unreleased/SOLR-18067.yml b/changelog/unreleased/SOLR-18067.ymlnew file mode 100644index 00000000000..72722db42e0--- /dev/null+++ b/changelog/unreleased/SOLR-18067.yml@@ -0,0 +1,8 @@+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc+title: Remove deprecated EmbeddedSolrServerTestBase from test-framework, tests updated to use EmbeddedSolrServerTestRule.+type: removed # added, changed, fixed, deprecated, removed, dependency_update, security, other+authors:+ - name: Eric Pugh+links:+ - name: SOLR-18067+ url: https://issues.apache.org/jira/browse/SOLR-18067diff --git a/solr/core/src/test/org/apache/solr/update/RootFieldTest.java b/solr/core/src/test/org/apache/solr/update/RootFieldTest.javaindex fce3c5e5ff8..d5ca7c66076 100644--- a/solr/core/src/test/org/apache/solr/update/RootFieldTest.java+++ b/solr/core/src/test/org/apache/solr/update/RootFieldTest.java@@ -19,7 +19,7 @@ package org.apache.solr.update;import static org.hamcrest.CoreMatchers.is;-import org.apache.solr.EmbeddedSolrServerTestBase;+import org.apache.solr.SolrTestCase;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.request.SolrQuery;@@ -28,13 +28,14 @@ import org.apache.solr.common.SolrDocumentList;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.CommonParams;+import org.apache.solr.util.EmbeddedSolrServerTestRule;import org.apache.solr.util.RandomNoReverseMergePolicyFactory;import org.junit.BeforeClass;import org.junit.ClassRule;import org.junit.Test;import org.junit.rules.TestRule;-public class RootFieldTest extends EmbeddedSolrServerTestBase {+public class RootFieldTest extends SolrTestCase {private static boolean useRootSchema;private static final String MESSAGE ="Update handler should create and process _root_ field "@@ -44,6 +45,9 @@ public class RootFieldTest extends EmbeddedSolrServerTestBase {return useRootSchema;}+ @ClassRule+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();+// not necessary right now but will be once block logic is asserted@ClassRulepublic static final TestRule noReverseMerge = RandomNoReverseMergePolicyFactory.createRule();@@ -62,7 +66,7 @@ public class RootFieldTest extends EmbeddedSolrServerTestBase {@Testpublic void testLegacyBlockProcessing() throws Exception {- SolrClient client = getSolrClient();+ SolrClient client = solrTestRule.getSolrClient();client.deleteByQuery("*:*"); // delete everything!// Add child free doc@@ -105,7 +109,7 @@ public class RootFieldTest extends EmbeddedSolrServerTestBase {@Testpublic void testUpdateWithChildDocs() throws Exception {- SolrClient client = getSolrClient();+ SolrClient client = solrTestRule.getSolrClient();client.deleteByQuery("*:*"); // delete everything!// Add child free docdiff --git a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.javaindex f885311cf10..dfd1ac8980e 100644--- a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java+++ b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java@@ -31,17 +31,22 @@ import java.util.Optional;import java.util.UUID;import java.util.function.Function;import java.util.stream.Collectors;-import org.apache.solr.EmbeddedSolrServerTestBase;+import org.apache.solr.SolrTestCase;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.RequestWriterSupplier;import org.apache.solr.client.solrj.request.SolrQuery;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.util.ByteArrayUtf8CharSequence;+import org.apache.solr.util.EmbeddedSolrServerTestRule;import org.junit.Before;+import org.junit.ClassRule;import org.junit.Test;-public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSolrServerTestBase {+public abstract class AbstractAtomicUpdatesMultivalueTestBase extends SolrTestCase {++ @ClassRule+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();protected static void initWithRequestWriter(RequestWriterSupplier requestWriterSupplier)throws Exception {@@ -55,14 +60,14 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo@Beforepublic void before() throws SolrServerException, IOException {- getSolrClient().deleteByQuery("*:*");+ solrTestRule.getSolrClient().deleteByQuery("*:*");}private void assertQR(final String fieldName, final String queryValue, final int numFound)throws SolrServerException, IOException {SolrQuery query = new SolrQuery("q", fieldName + ":" + queryValue);- QueryResponse rsp = getSolrClient().query(query);+ QueryResponse rsp = solrTestRule.getSolrClient().query(query);assertEquals(numFound, rsp.getResults().getNumFound());}@@ -75,12 +80,13 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSofinal Function<Object, Object> vc = valueConverter.orElse(o -> o);- getSolrClient()+ solrTestRule+ .getSolrClient().add(Arrays.asList(sdoc("id", "20000", fieldName, Arrays.asList(values[0], values[1], values[2])),sdoc("id", "20001", fieldName, Arrays.asList(values[1], values[2], values[3]))));- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().commit(true, true);if (queries != null) {assertQR(fieldName, queries[0], 1);@@ -89,19 +95,22 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSoassertQR(fieldName, queries[3], 1);}- Collection<Object> fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ Collection<Object> fieldValues =+ solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(3, fieldValues.size());assertThat(fieldValues, hasItems(vc.apply(values[0]), vc.apply(values[1]), vc.apply(values[2])));assertThat(fieldValues, not(hasItems(vc.apply(values[3]))));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertEquals(3, fieldValues.size());assertThat(fieldValues, hasItems(vc.apply(values[1]), vc.apply(values[2]), vc.apply(values[3])));assertThat(fieldValues, not(hasItems(vc.apply(values[0]))));- getSolrClient().add(sdoc("id", "20000", fieldName, Map.of("remove", List.of(values[0]))));- getSolrClient().commit(true, true);+ solrTestRule+ .getSolrClient()+ .add(sdoc("id", "20000", fieldName, Map.of("remove", List.of(values[0]))));+ solrTestRule.getSolrClient().commit(true, true);if (queries != null) {assertQR(fieldName, queries[0], 0);@@ -110,24 +119,25 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSoassertQR(fieldName, queries[3], 1);}- fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(2, fieldValues.size());assertThat(fieldValues, hasItems(vc.apply(values[1]), vc.apply(values[2])));assertThat(fieldValues, not(hasItems(vc.apply(values[0]), vc.apply(values[3]))));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertEquals(3, fieldValues.size());assertThat(fieldValues, hasItems(vc.apply(values[1]), vc.apply(values[2]), vc.apply(values[3])));assertThat(fieldValues, not(hasItems(vc.apply(values[0]))));- getSolrClient()+ solrTestRule+ .getSolrClient().add(sdoc("id","20001",fieldName,Map.of("remove", List.of(values[0], values[1], values[2]))));- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().commit(true, true);if (queries != null) {assertQR(fieldName, queries[0], 0);@@ -136,17 +146,18 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSoassertQR(fieldName, queries[3], 1);}- fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(2, fieldValues.size());assertThat(fieldValues, hasItems(vc.apply(values[1]), vc.apply(values[2])));assertThat(fieldValues, not(hasItems(vc.apply(values[0]), vc.apply(values[3]))));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertEquals(1, fieldValues.size());assertThat(fieldValues, hasItems(vc.apply(values[3])));assertThat(fieldValues, not(hasItems(vc.apply(values[0]), vc.apply(values[1]), vc.apply(values[2]))));- getSolrClient()+ solrTestRule+ .getSolrClient().add(Arrays.asList(sdoc(@@ -159,7 +170,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo"20001",fieldName,Map.of("add", List.of(values[0]), "remove", List.of(values[3])))));- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().commit(true, true);if (queries != null) {assertQR(fieldName, queries[0], 2);@@ -168,18 +179,19 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSoassertQR(fieldName, queries[3], 0);}- fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(1, fieldValues.size());assertThat(fieldValues, hasItems(vc.apply(values[0])));assertThat(fieldValues, not(hasItems(vc.apply(values[1]), vc.apply(values[2]), vc.apply(values[3]))));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertEquals(1, fieldValues.size());assertThat(fieldValues, hasItems(vc.apply(values[0])));assertThat(fieldValues, not(hasItems(vc.apply(values[1]), vc.apply(values[2]), vc.apply(values[3]))));- getSolrClient()+ solrTestRule+ .getSolrClient().add(Arrays.asList(sdoc(@@ -192,7 +204,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo"20001",fieldName,Map.of("set", List.of(values[0], values[1], values[2], values[3])))));- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().commit(true, true);if (queries != null) {assertQR(fieldName, queries[0], 2);@@ -201,13 +213,13 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSoassertQR(fieldName, queries[3], 2);}- fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(4, fieldValues.size());assertThat(fieldValues,hasItems(vc.apply(values[0]), vc.apply(values[1]), vc.apply(values[2]), vc.apply(values[3])));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertEquals(4, fieldValues.size());assertThat(fieldValues,@@ -259,76 +271,84 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSofinal String fieldName = "booleanRemove";- getSolrClient()+ solrTestRule+ .getSolrClient().add(Arrays.asList(sdoc("id", "20000", fieldName, List.of(true, false)),sdoc("id", "20001", fieldName, List.of(false, true))));- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().commit(true, true);assertQR(fieldName, "true", 2);assertQR(fieldName, "false", 2);- Collection<Object> fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ Collection<Object> fieldValues =+ solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(2, fieldValues.size());assertThat(fieldValues, hasItems(true, false));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertEquals(2, fieldValues.size());assertThat(fieldValues, hasItems(true, false));- getSolrClient().add(sdoc("id", "20000", fieldName, Map.of("remove", List.of(false))));- getSolrClient().commit(true, true);+ solrTestRule+ .getSolrClient()+ .add(sdoc("id", "20000", fieldName, Map.of("remove", List.of(false))));+ solrTestRule.getSolrClient().commit(true, true);assertQR(fieldName, "true", 2);assertQR(fieldName, "false", 1);- fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(1, fieldValues.size());assertThat(fieldValues, hasItems(true));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertEquals(2, fieldValues.size());assertThat(fieldValues, hasItems(true, false));- getSolrClient().add(sdoc("id", "20001", fieldName, Map.of("remove", List.of(true, false))));- getSolrClient().commit(true, true);+ solrTestRule+ .getSolrClient()+ .add(sdoc("id", "20001", fieldName, Map.of("remove", List.of(true, false))));+ solrTestRule.getSolrClient().commit(true, true);assertQR(fieldName, "true", 1);assertQR(fieldName, "false", 0);- fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(1, fieldValues.size());assertThat(fieldValues, hasItems(true));assertThat(fieldValues, not(hasItems(false)));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertNull(fieldValues);- getSolrClient()+ solrTestRule+ .getSolrClient().add(Arrays.asList(sdoc("id", "20000", fieldName, Map.of("add", List.of(false, false)))));- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().commit(true, true);assertQR(fieldName, "true", 1);assertQR(fieldName, "false", 1);- fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(3, fieldValues.size());assertThat(fieldValues, hasItems(true, false));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertNull(fieldValues);- getSolrClient()+ solrTestRule+ .getSolrClient().add(Arrays.asList(sdoc("id", "20000", fieldName, Map.of("set", List.of(true, false))),sdoc("id", "20001", fieldName, Map.of("set", List.of(false, true)))));- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().commit(true, true);assertQR(fieldName, "true", 2);assertQR(fieldName, "false", 2);- fieldValues = getSolrClient().getById("20000").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20000").getFieldValues(fieldName);assertEquals(2, fieldValues.size());assertThat(fieldValues, hasItems(true, false));- fieldValues = getSolrClient().getById("20001").getFieldValues(fieldName);+ fieldValues = solrTestRule.getSolrClient().getById("20001").getFieldValues(fieldName);assertEquals(2, fieldValues.size());assertThat(fieldValues, hasItems(true, false));}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/GetByIdTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/GetByIdTest.javaindex dd2b02d25eb..3cc64d0b3a5 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/GetByIdTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/GetByIdTest.java@@ -20,17 +20,22 @@ import static org.apache.solr.SolrTestCaseJ4.params;import static org.apache.solr.SolrTestCaseJ4.sdoc;import java.util.Arrays;-import org.apache.solr.EmbeddedSolrServerTestBase;+import org.apache.solr.SolrTestCase;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrDocumentList;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.SolrParams;+import org.apache.solr.util.EmbeddedSolrServerTestRule;import org.apache.solr.util.ExternalPaths;import org.junit.Before;import org.junit.BeforeClass;+import org.junit.ClassRule;import org.junit.Test;-public class GetByIdTest extends EmbeddedSolrServerTestBase {+public class GetByIdTest extends SolrTestCase {++ @ClassRule+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();@BeforeClasspublic static void beforeClass() throws Exception {@@ -40,11 +45,11 @@ public class GetByIdTest extends EmbeddedSolrServerTestBase {}@Before- @Overridepublic void setUp() throws Exception {super.setUp();- getSolrClient().deleteByQuery("*:*");- getSolrClient()+ solrTestRule.getSolrClient().deleteByQuery("*:*");+ solrTestRule+ .getSolrClient().add(Arrays.asList(sdoc("id", "1", "term_s", "Microsoft", "term2_s", "MSFT"),@@ -65,20 +70,20 @@ public class GetByIdTest extends EmbeddedSolrServerTestBase {"term2_s","id separator escape test document 2")));- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().commit(true, true);}@Testpublic void testGetId() throws Exception {- SolrDocument rsp = getSolrClient().getById("0");+ SolrDocument rsp = solrTestRule.getSolrClient().getById("0");assertNull(rsp);- rsp = getSolrClient().getById("1");+ rsp = solrTestRule.getSolrClient().getById("1");assertEquals("1", rsp.get("id"));assertEquals("Microsoft", rsp.get("term_s"));assertEquals("MSFT", rsp.get("term2_s"));- rsp = getSolrClient().getById("2");+ rsp = solrTestRule.getSolrClient().getById("2");assertEquals("2", rsp.get("id"));assertEquals("Apple", rsp.get("term_s"));assertEquals("AAPL", rsp.get("term2_s"));@@ -86,13 +91,13 @@ public class GetByIdTest extends EmbeddedSolrServerTestBase {@Testpublic void testGetIdWithSeparator() throws Exception {- SolrDocument rsp = getSolrClient().getById(",");+ SolrDocument rsp = solrTestRule.getSolrClient().getById(",");assertNotNull(rsp);assertEquals(",", rsp.get("id"));assertEquals("b00m! 1", rsp.get("term_s"));assertEquals("id separator escape test document 1", rsp.get("term2_s"));- rsp = getSolrClient().getById("1,2");+ rsp = solrTestRule.getSolrClient().getById("1,2");assertNotNull(rsp);assertEquals("1,2", rsp.get("id"));assertEquals("b00m! 2", rsp.get("term_s"));@@ -103,15 +108,15 @@ public class GetByIdTest extends EmbeddedSolrServerTestBase {public void testGetIdWithParams() throws Exception {final SolrParams ID_FL_ONLY = params(CommonParams.FL, "id");- SolrDocument rsp = getSolrClient().getById("0", ID_FL_ONLY);+ SolrDocument rsp = solrTestRule.getSolrClient().getById("0", ID_FL_ONLY);assertNull(rsp);- rsp = getSolrClient().getById("1", ID_FL_ONLY);+ rsp = solrTestRule.getSolrClient().getById("1", ID_FL_ONLY);assertEquals("1", rsp.get("id"));assertNull("This field should have been removed from the response.", rsp.get("term_s"));assertNull("This field should have been removed from the response.", rsp.get("term2_s"));- rsp = getSolrClient().getById("2", ID_FL_ONLY);+ rsp = solrTestRule.getSolrClient().getById("2", ID_FL_ONLY);assertEquals("2", rsp.get("id"));assertNull("This field should have been removed from the response.", rsp.get("term_s"));assertNull("This field should have been removed from the response.", rsp.get("term2_s"));@@ -119,7 +124,8 @@ public class GetByIdTest extends EmbeddedSolrServerTestBase {@Testpublic void testGetIds() throws Exception {- SolrDocumentList rsp = getSolrClient().getById(Arrays.asList("0", "1", "2", "3", "4"));+ SolrDocumentList rsp =+ solrTestRule.getSolrClient().getById(Arrays.asList("0", "1", "2", "3", "4"));assertEquals(3, rsp.getNumFound());assertEquals("1", rsp.get(0).get("id"));assertEquals("Microsoft", rsp.get(0).get("term_s"));@@ -136,7 +142,7 @@ public class GetByIdTest extends EmbeddedSolrServerTestBase {@Testpublic void testGetIdsWithSeparator() throws Exception {- SolrDocumentList rsp = getSolrClient().getById(Arrays.asList(",", "1,2"));+ SolrDocumentList rsp = solrTestRule.getSolrClient().getById(Arrays.asList(",", "1,2"));assertEquals(2, rsp.getNumFound());assertEquals(",", rsp.get(0).get("id"));assertEquals("1,2", rsp.get(1).get("id"));diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.javaindex 72ca4031404..963939f40a5 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java@@ -20,12 +20,14 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.List;-import org.apache.solr.EmbeddedSolrServerTestBase;+import org.apache.solr.SolrTestCase;import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;import org.apache.solr.client.solrj.request.SolrQuery;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.client.solrj.response.UpdateResponse;import org.apache.solr.common.SolrInputDocument;+import org.apache.solr.util.EmbeddedSolrServerTestRule;+import org.junit.ClassRule;import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -33,16 +35,19 @@ import org.slf4j.LoggerFactory;/*** @since solr 1.3*/-public abstract class LargeVolumeTestBase extends EmbeddedSolrServerTestBase {+public abstract class LargeVolumeTestBase extends SolrTestCase {private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());+ @ClassRule+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();+// for real load testing, make these numbers biggerstatic final int numdocs = 100; // 1000 * 1000;static final int threadCount = 5;@Testpublic void testMultiThreaded() throws Exception {- SolrClient client = getSolrClient();+ SolrClient client = solrTestRule.getSolrClient();client.deleteByQuery("*:*"); // delete everything!DocThread[] threads = new DocThread[threadCount];@@ -66,7 +71,7 @@ public abstract class LargeVolumeTestBase extends EmbeddedSolrServerTestBase {}private void query(int count) throws SolrServerException, IOException {- SolrClient client = getSolrClient();+ SolrClient client = solrTestRule.getSolrClient();SolrQuery query = new SolrQuery("*:*");QueryResponse response = client.query(query);assertEquals(0, response.getStatus());@@ -79,7 +84,7 @@ public abstract class LargeVolumeTestBase extends EmbeddedSolrServerTestBase {final String name;public DocThread(String name) {- client = getSolrClient();+ client = solrTestRule.getSolrClient();this.name = name;}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.javaindex b37c0b9d502..ca2acd5ebde 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java@@ -16,17 +16,22 @@*/package org.apache.solr.client.solrj.request;-import org.apache.solr.EmbeddedSolrServerTestBase;+import org.apache.solr.SolrTestCase;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.response.SolrPingResponse;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;+import org.apache.solr.util.EmbeddedSolrServerTestRule;import org.junit.Before;import org.junit.BeforeClass;+import org.junit.ClassRule;import org.junit.Test;/** Test SolrPing in Solrj */-public class SolrPingTest extends EmbeddedSolrServerTestBase {+public class SolrPingTest extends SolrTestCase {++ @ClassRule+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();@BeforeClasspublic static void beforeClass() throws Exception {@@ -37,7 +42,6 @@ public class SolrPingTest extends EmbeddedSolrServerTestBase {}@Before- @Overridepublic void setUp() throws Exception {super.setUp();solrTestRule.clearIndex();@@ -45,8 +49,8 @@ public class SolrPingTest extends EmbeddedSolrServerTestBase {SolrInputDocument doc = new SolrInputDocument();doc.setField("id", 1);doc.setField("terms_s", "samsung");- getSolrClient().add(doc);- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().add(doc);+ solrTestRule.getSolrClient().commit(true, true);}@Test@@ -54,9 +58,9 @@ public class SolrPingTest extends EmbeddedSolrServerTestBase {SolrPing ping = new SolrPing();SolrPingResponse rsp = null;ping.setActionEnable();- ping.process(getSolrClient());+ ping.process(solrTestRule.getSolrClient());ping.removeAction();- rsp = ping.process(getSolrClient());+ rsp = ping.process(solrTestRule.getSolrClient());assertNotNull(rsp);}@@ -66,12 +70,12 @@ public class SolrPingTest extends EmbeddedSolrServerTestBase {SolrPingResponse rsp = null;ping.setActionDisable();try {- ping.process(getSolrClient());+ ping.process(solrTestRule.getSolrClient());} catch (Exception e) {throw new Exception("disable action failed!");}ping.setActionPing();- rsp = ping.process(getSolrClient());+ rsp = ping.process(solrTestRule.getSolrClient());// the above line should fail with a 503 SolrException.assertNotNull(rsp);}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/json/DirectJsonQueryRequestFacetingEmbeddedTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/json/DirectJsonQueryRequestFacetingEmbeddedTest.javaindex 404ba2320c0..488dd83f41c 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/json/DirectJsonQueryRequestFacetingEmbeddedTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/json/DirectJsonQueryRequestFacetingEmbeddedTest.java@@ -21,7 +21,7 @@ import static org.apache.solr.SolrTestCaseJ4.getFile;import java.util.List;import org.apache.lucene.tests.util.LuceneTestCase;-import org.apache.solr.EmbeddedSolrServerTestBase;+import org.apache.solr.SolrTestCase;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.request.AbstractUpdateRequest;@@ -31,12 +31,17 @@ import org.apache.solr.client.solrj.response.UpdateResponse;import org.apache.solr.client.solrj.response.json.BucketJsonFacet;import org.apache.solr.client.solrj.response.json.NestableJsonFacet;import org.apache.solr.common.SolrDocumentList;+import org.apache.solr.util.EmbeddedSolrServerTestRule;import org.apache.solr.util.ExternalPaths;import org.junit.BeforeClass;+import org.junit.ClassRule;import org.junit.Test;@SuppressSSL-public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServerTestBase {+public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {++ @ClassRule+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();private static final String COLLECTION_NAME = "collection1";private static final int NUM_TECHPRODUCTS_DOCS = 32;@@ -85,7 +90,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -120,7 +125,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -158,7 +163,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -199,7 +204,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -234,7 +239,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -255,7 +260,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -281,7 +286,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -319,7 +324,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -359,7 +364,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -398,7 +403,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -429,7 +434,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ" }","}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -461,7 +466,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_ELECTRONICS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -492,7 +497,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_ELECTRONICS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -522,7 +527,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_ELECTRONICS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -552,7 +557,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_ELECTRONICS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -589,7 +594,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);assertExpectedDocumentsFoundAndReturned(response, NUM_IN_STOCK, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.javaindex 575fa87c2ad..aee28808401 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java@@ -17,18 +17,23 @@package org.apache.solr.client.solrj.response;import java.util.List;-import org.apache.solr.EmbeddedSolrServerTestBase;+import org.apache.solr.SolrTestCase;import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.request.SolrQuery;import org.apache.solr.client.solrj.response.TermsResponse.Term;import org.apache.solr.common.SolrInputDocument;+import org.apache.solr.util.EmbeddedSolrServerTestRule;import org.apache.solr.util.ExternalPaths;import org.junit.Before;import org.junit.BeforeClass;+import org.junit.ClassRule;import org.junit.Test;/** Test for TermComponent's response in Solrj */-public class TermsResponseTest extends EmbeddedSolrServerTestBase {+public class TermsResponseTest extends SolrTestCase {++ @ClassRule+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();@BeforeClasspublic static void beforeClass() throws Exception {@@ -38,7 +43,6 @@ public class TermsResponseTest extends EmbeddedSolrServerTestBase {}@Before- @Overridepublic void setUp() throws Exception {super.setUp();solrTestRule.clearIndex();@@ -49,8 +53,8 @@ public class TermsResponseTest extends EmbeddedSolrServerTestBase {SolrInputDocument doc = new SolrInputDocument();doc.setField("id", 1);doc.setField("terms_s", "samsung");- getSolrClient().add(doc);- getSolrClient().commit(true, true);+ solrTestRule.getSolrClient().add(doc);+ solrTestRule.getSolrClient().commit(true, true);SolrQuery query = new SolrQuery();query.setRequestHandler("/terms");@@ -62,7 +66,8 @@ public class TermsResponseTest extends EmbeddedSolrServerTestBase {query.setTermsMinCount(1);QueryRequest request = new QueryRequest(query);- List<Term> terms = request.process(getSolrClient()).getTermsResponse().getTerms("terms_s");+ List<Term> terms =+ request.process(solrTestRule.getSolrClient()).getTermsResponse().getTerms("terms_s");assertNotNull(terms);assertEquals(terms.size(), 1);diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.javaindex be51f216dab..a9a7f0ba072 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java@@ -17,7 +17,7 @@package org.apache.solr.client.solrj.response;import java.util.List;-import org.apache.solr.EmbeddedSolrServerTestBase;+import org.apache.solr.SolrTestCase;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.request.SolrQuery;@@ -26,9 +26,11 @@ import org.apache.solr.client.solrj.response.SpellCheckResponse.Correction;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.SpellingParams;+import org.apache.solr.util.EmbeddedSolrServerTestRule;import org.apache.solr.util.ExternalPaths;import org.junit.AfterClass;import org.junit.BeforeClass;+import org.junit.ClassRule;import org.junit.Test;/**@@ -36,7 +38,11 @@ import org.junit.Test;** @since solr 1.3*/-public class TestSpellCheckResponse extends EmbeddedSolrServerTestBase {+public class TestSpellCheckResponse extends SolrTestCase {++ @ClassRule+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();+private static SolrClient client;@BeforeClass@@ -45,7 +51,7 @@ public class TestSpellCheckResponse extends EmbeddedSolrServerTestBase {solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();- client = getSolrClient();+ client = solrTestRule.getSolrClient();}@AfterClassdiff --git a/solr/test-framework/src/java/org/apache/solr/EmbeddedSolrServerTestBase.java b/solr/test-framework/src/java/org/apache/solr/EmbeddedSolrServerTestBase.javadeleted file mode 100644index 12973d24bf6..00000000000--- a/solr/test-framework/src/java/org/apache/solr/EmbeddedSolrServerTestBase.java+++ /dev/null@@ -1,32 +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;--import org.apache.solr.client.solrj.SolrClient;-import org.apache.solr.util.EmbeddedSolrServerTestRule;-import org.junit.ClassRule;--@Deprecated // simply use EmbeddedSolrServerTestRule-public abstract class EmbeddedSolrServerTestBase extends SolrTestCase {-- @ClassRule- public static EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();-- public static SolrClient getSolrClient() {- return solrTestRule.getSolrClient();- }-}