dsmiley commented on code in PR #1218:
URL: https://github.com/apache/solr/pull/1218#discussion_r1061100149


##########
solr/test-framework/src/java/org/apache/solr/util/EmbeddedSolrServerTestRule.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * 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 static org.apache.solr.SolrTestCaseJ4.DEFAULT_TEST_COLLECTION_NAME;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.lucene.tests.util.LuceneTestCase;
+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import 
org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.RequestWriterSupplier;
+import org.apache.solr.client.solrj.impl.HttpClientUtil;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.NodeConfig;
+import org.apache.solr.update.UpdateShardHandlerConfig;
+
+/** TODO NOCOMMIT document */
+public class EmbeddedSolrServerTestRule extends SolrClientTestRule {
+
+  private EmbeddedSolrServer client = null;
+
+  public Builder build() {
+    return new Builder();
+  }
+
+  public class Builder {
+    private Path solrHome; // mandatory
+    private Path dataDir;
+    private String collectionName = DEFAULT_TEST_COLLECTION_NAME;
+    private String configFile;
+    private String schemaFile;
+    private RequestWriterSupplier requestWriterSupplier = 
RequestWriterSupplier.JavaBin;
+
+    public Builder setSolrHome(Path solrHome) {
+      this.solrHome = solrHome;
+      return this;
+    }
+
+    public Builder useTempDataDir() {

Review Comment:
   It's rather common for tests to create Solr pointed at SOLR_HOME -- an 
existing directory that should be considered read-only (instead of some build/ 
or temp dir).  Tests will complain (via the SecurityManager) if this mistake is 
overlooked.  I could easily imagine plugin writers making use of this as well.  
If the solr home provided is a temp dir populated from something, then there's 
no need for this.  It could be worth exploring creating one combo method like 
withMutableSolrHome vs withTemplateSolrHome (thus read-only) but I'm kind of 
"meh" on this.  Regardless, javadoc is necessary to help users understand when 
to use these methods.



-- 
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

Reply via email to