dsmiley commented on code in PR #1218: URL: https://github.com/apache/solr/pull/1218#discussion_r1097758339
########## solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java: ########## @@ -31,18 +30,18 @@ public class SolrPingTest extends EmbeddedSolrServerTestBase { @BeforeClass public static void beforeClass() throws Exception { - File testHome = createTempDir().toFile(); - FileUtils.copyDirectory(getFile("solrj/solr"), testHome); - initCore("solrconfig.xml", "schema.xml", testHome.getAbsolutePath(), "collection1"); + solrClientTestRule.startSolr(SolrTestCaseJ4.getFile("solrj/solr").toPath()); + + SolrTestCaseJ4.newRandomConfig(); + solrClientTestRule.newCollection().withConfigSet("../collection1").create(); } @Before @Override public void setUp() throws Exception { super.setUp(); - clearIndex(); - assertU(commit()); - assertU(optimize()); + solrClientTestRule.clearIndex(); Review Comment: TestRules (a JUnit thing) can either be declared statically and thus become a so-called `@ClassRule` (they are annotated this way; see EmbeddedSolrServerTestBase in this PR), or non-statically declared rule is annotated `@Rule`. ClassRule operate for the whole class; don't participate in life-cycle between individual tests in the class. Rule is for each test. So with that background, if a test needs a separate Solr instance per test, it could do so by defining this rule using `@Rule` and it would not need to bother clearing the index. If a test does not need to restart Solr between tests (typical; why bother), then if a test also creates data, it'll need to arrange for that data to be cleaned up. This is not a new concern; it exists today. It's sometimes annoying to call clearIndex. I could imagine some new mechanism where we create a new separate `@Rule` _from_ the `@ClassRule` that represents the data so that it cleans up so that it has the life-cycle hooks to call clearIndex. If it works, it'll be one line of code in a test. It'd be a pretty unusual / weird thing though. :shrug: could warrant an exploration. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org