use of org.apache.solr.util.TestHarness.TestCoresLocator in project SearchServices by Alfresco.
the class AbstractAlfrescoSolrTests method createAlfrescoCore.
public static void createAlfrescoCore(String schema) throws ParserConfigurationException, IOException, SAXException {
Properties properties = new Properties();
properties.put("solr.tests.maxBufferedDocs", "1000");
properties.put("solr.tests.maxIndexingThreads", "10");
properties.put("solr.tests.ramBufferSizeMB", "1024");
properties.put("solr.tests.mergeScheduler", "org.apache.lucene.index.ConcurrentMergeScheduler");
properties.put("alfresco.acl.tracker.cron", "0/10 * * * * ? *");
properties.put("alfresco.content.tracker.cron", "0/10 * * * * ? *");
properties.put("alfresco.metadata.tracker.cron", "0/10 * * * * ? *");
properties.put("alfresco.cascade.tracker.cron", "0/10 * * * * ? *");
properties.put("alfresco.commit.tracker.cron", "0/10 * * * * ? *");
if ("schema.xml".equalsIgnoreCase(schema)) {
String templateName = "rerank";
String templateNameSystemProperty = System.getProperty("templateName");
if (StringUtils.isNotBlank(templateNameSystemProperty)) {
templateName = templateNameSystemProperty;
}
FileUtils.copyFile(Paths.get(String.format(TEMPLATE_CONF, templateName) + schema).toFile(), Paths.get(TEST_SOLR_CONF + schema).toFile());
}
// The local test solrconfig with RAMDirectoryFactory and lockType of single.
CoreContainer coreContainer = new CoreContainer(TEST_FILES_LOCATION);
SolrResourceLoader resourceLoader = new SolrResourceLoader(Paths.get(TEST_SOLR_CONF), null, properties);
solrConfig = new SolrConfig(resourceLoader, "solrconfig.xml", null);
IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema(schema, solrConfig);
log.info("################ Index schema:" + schema + ":" + indexSchema.getResourceName());
TestCoresLocator locator = new TestCoresLocator(SolrTestCaseJ4.DEFAULT_TEST_CORENAME, "data", solrConfig.getResourceName(), indexSchema.getResourceName());
NodeConfig nodeConfig = new NodeConfig.NodeConfigBuilder("name", coreContainer.getResourceLoader()).setUseSchemaCache(false).setCoreAdminHandlerClass("org.alfresco.solr.AlfrescoCoreAdminHandler").build();
coreContainer.shutdown();
try {
h = new TestHarness(nodeConfig, locator);
h.coreName = SolrTestCaseJ4.DEFAULT_TEST_CORENAME;
} catch (Exception e) {
log.info("we hit an issue", e);
}
lrf = h.getRequestFactory("standard", 0, 20, CommonParams.VERSION, "2.2");
}
Aggregations