use of org.apache.stanbol.commons.solr.managed.ManagedSolrServer in project stanbol by apache.
the class SolrYardTest method initYard.
@BeforeClass
public static final void initYard() throws YardException, IOException {
// get the working directory
// use property substitution to test this feature!
String prefix = System.getProperty("basedir") == null ? "." : "${basedir}";
String solrServerDir = prefix + TEST_INDEX_REL_PATH;
log.info("Test Solr Server Directory: " + solrServerDir);
SolrYardConfig config = new SolrYardConfig(TEST_YARD_ID, TEST_SOLR_CORE_NAME);
config.setName("Solr Yard Test");
config.setDescription("The Solr Yard instance used to execute the Unit Tests defined for the Yard Interface");
config.setAllowInitialisation(true);
//for unit testing we want immidiate commits (required after STANBOL-1092
// as the default changed to false)
config.setImmediateCommit(true);
//init the ManagedSolrServer used for the UnitTest
System.setProperty(ManagedSolrServer.MANAGED_SOLR_DIR_PROPERTY, solrServerDir);
IndexReference solrServerRef = IndexReference.parse(config.getSolrServerLocation());
solrServerProvider = StandaloneEmbeddedSolrServerProvider.getInstance();
SolrServer server = solrServerProvider.getSolrServer(solrServerRef, config.isAllowInitialisation() ? config.getIndexConfigurationName() : null);
//Optional support for the nsPrefix service
final NamespacePrefixService nsPrefixService;
ServiceLoader<NamespacePrefixService> spsl = ServiceLoader.load(NamespacePrefixService.class);
Iterator<NamespacePrefixService> it = spsl.iterator();
if (it.hasNext()) {
nsPrefixService = it.next();
} else {
nsPrefixService = null;
}
yard = new SolrYard(server, config, nsPrefixService);
}
Aggregations