Search in sources :

Example 1 with TestCoresLocator

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");
}
Also used : SolrResourceLoader(org.apache.solr.core.SolrResourceLoader) SolrConfig(org.apache.solr.core.SolrConfig) TestCoresLocator(org.apache.solr.util.TestHarness.TestCoresLocator) CoreContainer(org.apache.solr.core.CoreContainer) BaseTestHarness(org.apache.solr.util.BaseTestHarness) TestHarness(org.apache.solr.util.TestHarness) IndexSchema(org.apache.solr.schema.IndexSchema) Properties(java.util.Properties) XPathExpressionException(javax.xml.xpath.XPathExpressionException) SAXException(org.xml.sax.SAXException) ParseException(org.apache.lucene.queryparser.classic.ParseException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) NodeConfig(org.apache.solr.core.NodeConfig)

Aggregations

IOException (java.io.IOException)1 Properties (java.util.Properties)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 ParseException (org.apache.lucene.queryparser.classic.ParseException)1 CoreContainer (org.apache.solr.core.CoreContainer)1 NodeConfig (org.apache.solr.core.NodeConfig)1 SolrConfig (org.apache.solr.core.SolrConfig)1 SolrResourceLoader (org.apache.solr.core.SolrResourceLoader)1 IndexSchema (org.apache.solr.schema.IndexSchema)1 BaseTestHarness (org.apache.solr.util.BaseTestHarness)1 TestHarness (org.apache.solr.util.TestHarness)1 TestCoresLocator (org.apache.solr.util.TestHarness.TestCoresLocator)1 SAXException (org.xml.sax.SAXException)1