Solr comes with packaged jetty jar start.jar in example folder . For my scalatest automation I need to control solr start and stop from my scalatest module . How can I do that ? Please guide and suggest.
I have written a JUnit rule is intended for integration tests. This rule starts and stops the Jetty server that is wrapped by Solr on behalf of the class JettySolrRunner.
The relevant part to start Solr with the embedded Jetty is
File solrXml = new File("/solr/home/solr.xml");
File solrHomeDir = solrXml.getParentFile();
int port = 8080;
String context = "/solr";
// use org.apache.solr.client.solrj.embedded.JettySolrRunner
JettySolrRunner jettySolr
= new JettySolrRunner(solrHomeDir.getAbsolutePath(), context, port);
boolean waitUntilTheSolrWebAppHasStarted = true;
jettySolr.start(waitUntilTheSolrWebAppHasStarted);
Stopping that server is rather straight forward
jettySolr.stop();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With