/** * Shuts down the test harness, and makes the best attempt possible to delete dataDir, unless the * system property "solr.test.leavedatadir" is set. */ @Override public void tearDown() throws Exception { log.info("####TEARDOWN_START " + getTestName()); if (factoryProp == null) { System.clearProperty("solr.directoryFactory"); } if (h != null) { h.close(); } String skip = System.getProperty("solr.test.leavedatadir"); if (null != skip && 0 != skip.trim().length()) { System.err.println( "NOTE: per solr.test.leavedatadir, dataDir will not be removed: " + dataDir.getAbsolutePath()); } else { if (!recurseDelete(dataDir)) { System.err.println( "!!!! WARNING: best effort to remove " + dataDir.getAbsolutePath() + " FAILED !!!!!"); } } resetExceptionIgnores(); super.tearDown(); }
/** * Generates a SolrQueryRequest using the LocalRequestFactory * * @see #lrf */ public SolrQueryRequest req(String[] params, String... moreParams) { String[] allParams = moreParams; if (params.length != 0) { int len = params.length + moreParams.length; allParams = new String[len]; System.arraycopy(params, 0, allParams, 0, params.length); System.arraycopy(moreParams, 0, allParams, params.length, moreParams.length); } return lrf.makeRequest(allParams); }
/** * Initializes things your test might need * * <ul> * <li>Creates a dataDir in the "java.io.tmpdir" * <li>initializes the TestHarness h using this data directory, and getSchemaPath() * <li>initializes the LocalRequestFactory lrf using sensible defaults. * </ul> */ @Override public void setUp() throws Exception { super.setUp(); log.info("####SETUP_START " + getTestName()); ignoreException("ignore_exception"); factoryProp = System.getProperty("solr.directoryFactory"); if (factoryProp == null) { System.setProperty("solr.directoryFactory", "solr.RAMDirectoryFactory"); } dataDir = new File(TEMP_DIR, getClass().getName() + "-" + System.currentTimeMillis()); dataDir.mkdirs(); String configFile = getSolrConfigFile(); System.setProperty("solr.solr.home", getSolrHome()); if (configFile != null) { solrConfig = TestHarness.createConfig(getSolrConfigFile()); h = new TestHarness(dataDir.getAbsolutePath(), solrConfig, getSchemaFile()); lrf = h.getRequestFactory("standard", 0, 20, CommonParams.VERSION, "2.2"); } log.info("####SETUP_END " + getTestName()); }