Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-5865: Testing improvements.

Mark Robert Millerb2335520fe3c
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
index b846d54ffb5..2a5e1d0a4a5 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
@@ -17,15 +17,12 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@@ -42,20 +39,25 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.util.RevertDefaultThreadHandlerRule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+
/**
- * Test of the MiniSolrCloudCluster functionality. This doesn't derive from
- * LuceneTestCase, as the MiniSolrCloudCluster is designed to be used outside of the
- * lucene test hierarchy. Because of this, normal checks are not applied to this test
- * to ensure it does not do things like pollute future tests that will run in this JVM.
- * *Please be very careful*.
+ * Test of the MiniSolrCloudCluster functionality. Keep in mind,
+ * MiniSolrCloudCluster is designed to be used outside of the Lucene test
+ * hierarchy.
*/
-public class TestMiniSolrCloudCluster {
+public class TestMiniSolrCloudCluster extends LuceneTestCase {
private static Logger log = LoggerFactory.getLogger(MiniSolrCloudCluster.class);
private static final int NUM_SERVERS = 5;
@@ -63,6 +65,15 @@ public class TestMiniSolrCloudCluster {
private static final int REPLICATION_FACTOR = 2;
private static MiniSolrCloudCluster miniCluster;
+ @Rule
+ public TestRule solrTestRules = RuleChain
+ .outerRule(new SystemPropertiesRestoreRule());
+
+ @ClassRule
+ public static TestRule solrClassRules = RuleChain.outerRule(
+ new SystemPropertiesRestoreRule()).around(
+ new RevertDefaultThreadHandlerRule());
+
@BeforeClass
public static void startup() throws Exception {
String testHome = SolrTestCaseJ4.TEST_HOME();
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
index 4b872dbe892..b98e219b379 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
@@ -31,19 +31,12 @@ import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooDefs;
import org.eclipse.jetty.servlet.ServletHolder;
-import org.junit.Rule;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TestRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import com.google.common.io.Files;
public class MiniSolrCloudCluster {
- @Rule
- public TestRule testRules =
- RuleChain.outerRule(new SystemPropertiesRestoreRule());
private static Logger log = LoggerFactory.getLogger(MiniSolrCloudCluster.class);