Reputation: 337
I'm using Spring Data Solr to implement the search module in my project. To enable multicore support, I simply instantiate a HttpSolrServer and then declare a java-based Spring configuration class with @EnableSolrRepositores(multicoreSupport=true)
. Everything works perfectly, until when I try to write integration test for Solr related codes and schema.
I want to use EmbeddedSolrServer for testing so that the tests can run without depending on an external Solr server, but I can't find a way to configure correctly. Please advise.
Upvotes: 2
Views: 3027
Reputation: 6726
This can at this time not be done directly due to DATASOLR-203.
Once the issue mentioned above is resolved you can do it as follows:
@Configuration
@EnableSolrRepositories(multicoreSupport = true)
static class SolrConfiguration {
@Bean
SolrServer solrServer() throws FileNotFoundException {
String solrHome = ResourceUtils.getURL("classpath:your/path/here").getPath();
CoreContainer container = CoreContainer.createAndLoad(solrHome, new File(solrHome + "/solr.xml"));
return new EmbeddedSolrServer(container, null);
}
}
Upvotes: 5