Java Code Examples for org.apache.solr.util.TestHarness#getRequestFactory()

The following examples show how to use org.apache.solr.util.TestHarness#getRequestFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrTestCaseJ4.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Call this from @BeforeClass to set up the test harness and update handler with no cores.
 *
 * @param solrHome The solr home directory.
 * @param xmlStr - the text of an XML file to use. If null, use the what's the absolute minimal file.
 * @throws Exception Lost of file-type things can go wrong.
 */
public static void setupNoCoreTest(Path solrHome, String xmlStr) throws Exception {

  if (xmlStr == null)
    xmlStr = "<solr></solr>";
  Files.write(solrHome.resolve(SolrXmlConfig.SOLR_XML_FILE), xmlStr.getBytes(StandardCharsets.UTF_8));
  h = new TestHarness(SolrXmlConfig.fromSolrHome(solrHome, new Properties()));
  lrf = h.getRequestFactory("/select", 0, 20, CommonParams.VERSION, "2.2");
}
 
Example 2
Source File: SolrTestCaseJ4.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static void createCore() {
  assertNotNull(testSolrHome);
  solrConfig = TestHarness.createConfig(testSolrHome, coreName, getSolrConfigFile());
  h = new TestHarness( coreName, hdfsDataDir == null ? initAndGetDataDir().getAbsolutePath() : hdfsDataDir,
          solrConfig,
          getSchemaFile());
  lrf = h.getRequestFactory
          ("",0,20,CommonParams.VERSION,"2.2");
}
 
Example 3
Source File: AbstractAlfrescoSolrIT.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @deprecated as testHarness is used
 */
@Deprecated
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 = System.getProperty("templateName", "rerank");
        FileUtils.copyFile(
                Paths.get(String.format(templateConf, templateName) + schema).toFile(),
                Paths.get(testSolrConf + schema).toFile());
    }

    SolrResourceLoader resourceLoader = new SolrResourceLoader(Paths.get(testExecutionSolrHome), null, properties);
    TestCoresLocator locator = new TestCoresLocator(SolrTestCaseJ4.DEFAULT_TEST_CORENAME,
                                                    "data", 
                                                    "solrconfig.xml",
                                                    schema);
    
    NodeConfig nodeConfig = new NodeConfig.NodeConfigBuilder("name", resourceLoader)
            .setUseSchemaCache(false)
            .setCoreAdminHandlerClass(AlfrescoCoreAdminHandler.class.getName())
            .build();
    try
    {
        h = new TestHarness(nodeConfig, locator);
        h.coreName = SolrTestCaseJ4.DEFAULT_TEST_CORENAME;
        CORE_NOT_YET_CREATED = false;
    }
    catch(Exception e)
    {
        LOG.info("we hit an issue", e);
    }
    lrf = h.getRequestFactory
            ("standard",0,20, CommonParams.VERSION,"2.2");
}
 
Example 4
Source File: SolrTestCaseJ4.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public static CoreContainer createCoreContainer(Path solrHome, String solrXML) {
  testSolrHome = requireNonNull(solrHome);
  h = new TestHarness(solrHome, solrXML);
  lrf = h.getRequestFactory("", 0, 20, CommonParams.VERSION, "2.2");
  return h.getCoreContainer();
}
 
Example 5
Source File: SolrTestCaseJ4.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public static CoreContainer createCoreContainer(NodeConfig config, CoresLocator locator) {
  testSolrHome = config.getSolrHome();
  h = new TestHarness(config, locator);
  lrf = h.getRequestFactory("", 0, 20, CommonParams.VERSION, "2.2");
  return h.getCoreContainer();
}
 
Example 6
Source File: SolrTestCaseJ4.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public static CoreContainer createDefaultCoreContainer(Path solrHome) {
  testSolrHome = requireNonNull(solrHome);
  h = new TestHarness("collection1", initAndGetDataDir().getAbsolutePath(), "solrconfig.xml", "schema.xml");
  lrf = h.getRequestFactory("", 0, 20, CommonParams.VERSION, "2.2");
  return h.getCoreContainer();
}