This is an automated email from the ASF dual-hosted git repository. dsmiley pushed a commit to branch branch_9x in repository https://gitbox.apache.org/repos/asf/solr.git
commit 517d366af350008311018e69acbd8574b638de25 Author: David Smiley <[email protected]> AuthorDate: Wed Oct 7 18:21:33 2026 -0400 SolrTestCase: reset system properties per test (#5056) (cherry picked from commit 9d7cc2884e8a843f33076e8171401e3f39d1f533) (cherry picked from commit 447de11169e850691ecb3baa0b83a340becd5b9d) --- .../src/java/org/apache/solr/SolrTestCase.java | 14 +++++++------- .../src/java/org/apache/solr/SolrTestCaseJ4.java | 6 ------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java index 73fc008ae8b..53bba894175 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java @@ -54,12 +54,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * All Solr test cases should derive from this class eventually. This is originally a result of - * async logging, see: SOLR-12055 and associated. To enable async logging, we must gracefully shut - * down logging. Many Solr tests subclass LuceneTestCase. + * All Solr test cases should derive from this class. * - * <p>Rather than add the cruft from SolrTestCaseJ4 to all the Solr tests that currently subclass - * LuceneTestCase, we'll add the shutdown to this class and subclass it. + * <p><em>Be conservative in what's here; avoid arbitrary/misc utilities.</em> * * <p>Other changes that should affect every Solr test case may go here if they don't require the * added capabilities in SolrTestCaseJ4. @@ -180,11 +177,13 @@ public class SolrTestCase extends LuceneTestCase { } @AfterClass - public static void afterClassShutdownLogging() { + public static void afterClassSolrTestCase() { StartupLoggingUtils.shutdown(); } - @Rule public TestRule methodRules = new LogLevelTestRule(); + @Rule + public TestRule solrTestRules = + RuleChain.outerRule(new SystemPropertiesRestoreRule()).around(new LogLevelTestRule()); /** * Special hook for sanity checking if any tests trigger failures when an Assumption failure @@ -199,6 +198,7 @@ public class SolrTestCase extends LuceneTestCase { } // UTILITY METHODS FOLLOW + // NOTE: be very conservative in what we add! public static void assertJSONEquals(String expected, String actual) { Object json1 = fromJSONString(expected); diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index 76a11aabccb..ab99ac874d6 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -25,7 +25,6 @@ import static org.hamcrest.core.StringContains.containsString; import com.carrotsearch.randomizedtesting.RandomizedContext; import com.carrotsearch.randomizedtesting.RandomizedTest; -import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule; import io.opentracing.noop.NoopTracerFactory; import io.opentracing.util.GlobalTracer; import java.io.File; @@ -152,9 +151,6 @@ import org.apache.zookeeper.KeeperException; import org.hamcrest.Matcher; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.rules.RuleChain; -import org.junit.rules.TestRule; import org.noggit.CharArr; import org.noggit.JSONUtil; import org.noggit.ObjectBuilder; @@ -252,8 +248,6 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { // thread will read the latest value public static volatile SSLTestConfig sslConfig; - @Rule public TestRule solrTestRules = RuleChain.outerRule(new SystemPropertiesRestoreRule()); - @BeforeClass public static void setupTestCases() { resetExceptionIgnores();
