本文整理汇总了Java中org.apache.solr.SolrTestCaseJ4类的典型用法代码示例。如果您正苦于以下问题:Java SolrTestCaseJ4类的具体用法?Java SolrTestCaseJ4怎么用?Java SolrTestCaseJ4使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SolrTestCaseJ4类属于org.apache.solr包,在下文中一共展示了SolrTestCaseJ4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
super.setUp();
System.setProperty("solr.solr.home", SOLR_HOME.getAbsolutePath());
System.setProperty("configSetBase", SolrTestCaseJ4.getFile("solrj/solr/configsets").getAbsolutePath());
System.out.println("Solr home: " + SOLR_HOME.getAbsolutePath());
//The index is always stored within a temporary directory
tempDir = createTempDir();
File dataDir = new File(tempDir,"data1");
File dataDir2 = new File(tempDir,"data2");
System.setProperty("dataDir1", dataDir.getAbsolutePath());
System.setProperty("dataDir2", dataDir2.getAbsolutePath());
System.setProperty("tempDir", tempDir.getAbsolutePath());
System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
cores = CoreContainer.createAndLoad(SOLR_HOME.getAbsolutePath(), getSolrXml());
//cores.setPersistent(false);
}
示例2: setUp
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
public void setUp() throws Exception {
File home = new File(dataDir,
getClass().getName() + "-" + System.currentTimeMillis());
homeDir = new File(home, name);
dataDir = new File(homeDir + "/collection1", "data");
confDir = new File(homeDir + "/collection1", "conf");
homeDir.mkdirs();
dataDir.mkdirs();
confDir.mkdirs();
FileUtils.copyFile(SolrTestCaseJ4.getFile(getSolrXmlFile()), new File(homeDir, "solr.xml"));
File f = new File(confDir, "solrconfig.xml");
FileUtils.copyFile(SolrTestCaseJ4.getFile(getSolrConfigFile()), f);
f = new File(confDir, "schema.xml");
FileUtils.copyFile(SolrTestCaseJ4.getFile(getSchemaFile()), f);
}
示例3: getDocs
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
private SolrDocumentList getDocs(int start, int rows) {
SolrDocumentList docs = new SolrDocumentList();
docs.setNumFound(docsData.size());
docs.setStart(start);
int endIndex = start + rows;
int end = docsData.size() < endIndex ? docsData.size() : endIndex;
for (int i = start; i < end; i++) {
SolrDocument doc = new SolrDocument();
SolrTestCaseJ4.Doc testDoc = docsData.get(i);
doc.addField("id", testDoc.id);
doc.addField("description", testDoc.getValues("description"));
docs.add(doc);
}
return docs;
}
示例4: teardownClass
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
public static void teardownClass(MiniDFSCluster dfsCluster) throws Exception {
SolrTestCaseJ4.resetFactory();
System.clearProperty("solr.lock.type");
System.clearProperty("test.build.data");
System.clearProperty("test.cache.data");
System.clearProperty("solr.hdfs.home");
System.clearProperty("solr.hdfs.blockcache.global");
if (dfsCluster != null) {
timers.remove(dfsCluster);
dfsCluster.shutdown();
}
// TODO: we HACK around HADOOP-9643
if (savedLocale != null) {
Locale.setDefault(savedLocale);
}
}
示例5: beforeTest
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
@BeforeClass
public static void beforeTest() throws Exception {
File homeDir = createTempDir();
File collDir = new File(homeDir, "collection1");
File dataDir = new File(collDir, "data");
File confDir = new File(collDir, "conf");
homeDir.mkdirs();
collDir.mkdirs();
dataDir.mkdirs();
confDir.mkdirs();
FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(homeDir, "solr.xml"));
String src_dir = TEST_HOME() + "/collection1/conf";
FileUtils.copyFile(new File(src_dir, "schema-binaryfield.xml"),
new File(confDir, "schema.xml"));
FileUtils.copyFile(new File(src_dir, "solrconfig-basic.xml"),
new File(confDir, "solrconfig.xml"));
FileUtils.copyFile(new File(src_dir, "solrconfig.snippet.randomindexconfig.xml"),
new File(confDir, "solrconfig.snippet.randomindexconfig.xml"));
createJetty(homeDir.getAbsolutePath(), null, null);
}
示例6: testPropertySub
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
public void testPropertySub() throws IOException {
System.setProperty("coreRootDirectory", "myCoreRoot" + File.separator);
System.setProperty("hostPort", "8888");
System.setProperty("shareSchema", "false");
System.setProperty("socketTimeout", "220");
System.setProperty("connTimeout", "200");
File testSrcRoot = new File(SolrTestCaseJ4.TEST_HOME());
FileUtils.copyFile(new File(testSrcRoot, "solr-50-all.xml"), new File(solrHome, "solr.xml"));
ConfigSolr cfg = ConfigSolr.fromSolrHome(loader, solrHome.getAbsolutePath());
assertEquals("core root dir", "myCoreRoot" + File.separator, cfg.getCoreRootDirectory());
assertEquals("zk host port", "8888", cfg.getZkHostPort());
assertEquals("schema cache", false, cfg.hasSchemaCache());
}
示例7: makeCores
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
private void makeCores(File home, boolean oldStyle) throws Exception {
File testSrcRoot = new File(SolrTestCaseJ4.TEST_HOME());
String srcSolrXml = "solr-stress-new.xml";
if (oldStyle) {
srcSolrXml = "solr-stress-old.xml";
}
FileUtils.copyFile(new File(testSrcRoot, srcSolrXml), new File(home, "solr.xml"));
// create directories in groups of 100 until you have enough.
for (int idx = 0; idx < numCores; ++idx) {
String coreName = String.format(Locale.ROOT, "%05d_core", idx);
makeCore(new File(home, coreName), testSrcRoot, coreName);
coreCounts.put(coreName, 0L);
coreNames.add(coreName);
}
}
示例8: setUp
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
saveProp = System.getProperty("solr.directoryFactory");
System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
super.setUp();
SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
cores.setPersistent(false);
// setup datadirs
System.setProperty( "solr.core0.data.dir", SolrTestCaseJ4.dataDir.getCanonicalPath() );
dataDir2 = new File(TEMP_DIR, getClass().getName() + "-"
+ System.currentTimeMillis());
dataDir2.mkdirs();
System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
}
示例9: setUp
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
public void setUp() throws Exception {
File home = new File(LuceneTestCase.TEMP_DIR,
getClass().getName() + "-" + System.currentTimeMillis());
homeDir = new File(home, name);
dataDir = new File(homeDir + "/collection1", "data");
confDir = new File(homeDir + "/collection1", "conf");
homeDir.mkdirs();
dataDir.mkdirs();
confDir.mkdirs();
File f = new File(confDir, "solrconfig.xml");
FileUtils.copyFile(SolrTestCaseJ4.getFile(getSolrConfigFile()), f);
f = new File(confDir, "schema.xml");
FileUtils.copyFile(SolrTestCaseJ4.getFile(getSchemaFile()), f);
}
示例10: setupSentry
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
public void setupSentry() throws Exception {
sentrySite = File.createTempFile("sentry-site", "xml");
File authProviderDir = SolrTestCaseJ4.getFile("sentry-handlers/sentry");
sentrySite.deleteOnExit();
// need to write sentry-site at execution time because we don't know
// the location of sentry.solr.provider.resource beforehand
StringBuilder sentrySiteData = new StringBuilder();
sentrySiteData.append("<configuration>\n");
addPropertyToSentry(sentrySiteData, "sentry.provider",
"org.apache.sentry.provider.file.LocalGroupResourceAuthorizationProvider");
addPropertyToSentry(sentrySiteData, "sentry.solr.provider.resource",
new File(authProviderDir.toString(), "test-authz-provider.ini").toURI().toURL().toString());
sentrySiteData.append("</configuration>\n");
FileUtils.writeStringToFile(sentrySite,sentrySiteData.toString(), Charsets.UTF_8.toString());
}
示例11: createServer
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
protected SolrServer createServer( String name )
{
try {
// setup the server...
String url = buildUrl(port, context) + "/" + name;
HttpSolrServer s = new HttpSolrServer( url );
s.setConnectionTimeout(SolrTestCaseJ4.DEFAULT_CONNECTION_TIMEOUT);
s.setDefaultMaxConnectionsPerHost(100);
s.setMaxTotalConnections(100);
return s;
}
catch( Exception ex ) {
throw new RuntimeException( ex );
}
}
示例12: beforeTest
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
@BeforeClass
public static void beforeTest() throws Exception {
solrHomeDirectory = createTempDir();
setupJettyTestHome(solrHomeDirectory, "collection1");
String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
FileUtils.copyFile(new File(top, "solrconfig-headers.xml"), new File(solrHomeDirectory + "/collection1/conf", "solrconfig.xml"));
createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
}
示例13: setupCore
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
private static void setupCore(String coreName, boolean blivet) throws IOException {
File instDir = new File(solrHomeDirectory, coreName);
File subHome = new File(instDir, "conf");
assertTrue("Failed to make subdirectory ", subHome.mkdirs());
// Be sure we pick up sysvars when we create this
String srcDir = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
FileUtils.copyFile(new File(srcDir, "schema-tiny.xml"), new File(subHome, "schema_ren.xml"));
FileUtils.copyFile(new File(srcDir, "solrconfig-minimal.xml"), new File(subHome, "solrconfig_ren.xml"));
FileUtils.copyFile(new File(srcDir, "solrconfig.snippet.randomindexconfig.xml"),
new File(subHome, "solrconfig.snippet.randomindexconfig.xml"));
}
示例14: createJetty
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
private static JettySolrRunner createJetty(SolrInstance instance) throws Exception {
FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(instance.getHomeDir(), "solr.xml"));
JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), "/solr", 0);
jetty.setDataDir(instance.getDataDir());
jetty.start();
return jetty;
}
示例15: createJetty
import org.apache.solr.SolrTestCaseJ4; //导入依赖的package包/类
private static JettySolrRunner createJetty(TestReplicationHandler.SolrInstance instance) throws Exception {
FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(instance.getHomeDir(), "solr.xml"));
JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), "/solr", 0);
jetty.setDataDir(instance.getDataDir());
jetty.start();
return jetty;
}