SOLR-5914: Merge branch up to trunk, make all tests pass, make some other improvements and small changes.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/solr5914@1582571 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-03-28 00:55:45 +00:00
parent 688addbd50
commit 48c5ea550f
105 changed files with 524 additions and 570 deletions

View File

@ -787,6 +787,24 @@ public final class TestUtil {
* an exception (typically on Windows).
*/
public static File createTempDir(String name) {
return createTempDir(name, new File(System.getProperty("tempDir", System.getProperty("java.io.tmpdir"))));
}
/**
* Returns a new, empty temporary folder, based on the given name. The folder will be
* deleted at the end of the suite. Failure to delete the temporary folder will cause
* an exception (typically on Windows).
*/
public static File createTempDir(String name, File tmpDir) {
return createTempDir(name, tmpDir, true);
}
/**
* Returns a new, empty temporary folder, based on the given name. The folder will be
* deleted at the end of the suite. Failure to delete the temporary folder will cause
* an exception (typically on Windows).
*/
public static File createTempDir(String name, File tmpDir, boolean ensureCleanedUp) {
if (name.length() < 3) {
throw new IllegalArgumentException("description must be at least 3 characters");
}
@ -797,18 +815,18 @@ public final class TestUtil {
// does not affect the randomness of the test.
final Random random = new Random(RandomizedContext.current().getRandom().nextLong());
int attempt = 0;
String tmpDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
File f;
do {
f = genTempFile(random, name + "_", "", new File(tmpDir));
f = genTempFile(random, name + "_", "", tmpDir);
} while (!f.mkdir() && (attempt++) < GET_TEMP_DIR_RETRY_THRESHOLD);
if (attempt > GET_TEMP_DIR_RETRY_THRESHOLD) {
throw new RuntimeException(
"failed to get a temporary dir too many times. check your temp directory and consider manually cleaning it.");
}
LuceneTestCase.closeAfterSuite(new CloseableFile(f, LuceneTestCase.suiteFailureMarker));
if (ensureCleanedUp) {
LuceneTestCase.closeAfterSuite(new CloseableFile(f, LuceneTestCase.suiteFailureMarker));
}
return f;
}

View File

@ -63,13 +63,9 @@ public class TestICUCollationField extends SolrTestCaseJ4 {
* So its preferable to create this file on-the-fly.
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
File tmpFile = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
tmpFile.delete();
tmpFile.mkdir();
String tmpFile = createTempDir().getAbsolutePath();
// make data and conf dirs
new File(tmpFile + "/collection1", "data").mkdirs();
new File(tmpFile + "/collection1", "data").mkdirs();
File confDir = new File(tmpFile + "/collection1", "conf");
confDir.mkdirs();
@ -91,7 +87,7 @@ public class TestICUCollationField extends SolrTestCaseJ4 {
IOUtils.write(tailoredRules, os, "UTF-8");
os.close();
return tmpFile.getAbsolutePath();
return tmpFile;
}
/**

View File

@ -65,10 +65,7 @@ public class TestICUCollationFieldDocValues extends SolrTestCaseJ4 {
* So its preferable to create this file on-the-fly.
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
File tmpFile = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
tmpFile.delete();
tmpFile.mkdir();
File tmpFile = createTempDir();
// make data and conf dirs
new File(tmpFile + "/collection1", "data").mkdirs();

View File

@ -56,10 +56,11 @@ public abstract class AbstractSqlEntityProcessorTestCase extends
@Before
public void beforeSqlEntitiyProcessorTestCase() throws Exception {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpdir = createTempDir();
fileLocation = tmpdir.getPath();
fileName = "the.properties";
}
@After
public void afterSqlEntitiyProcessorTestCase() {
useSimpleCaches = false;

View File

@ -151,7 +151,8 @@ public class TestContentStreamDataSource extends AbstractDataImportHandlerTestCa
public void setUp() throws Exception {
File home = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File home = new File(dataDir,
getClass().getName() + "-" + System.currentTimeMillis());
homeDir = new File(home, "inst");
dataDir = new File(homeDir + "/collection1", "data");

View File

@ -16,18 +16,15 @@
*/
package org.apache.solr.handler.dataimport;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.request.LocalSolrQueryRequest;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.io.File;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
/**
* <p>
@ -242,7 +239,7 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTestCase {
@Test
@Ignore("Fix Me. See SOLR-4103.")
public void testFileListEntityProcessor_lastIndexTime() throws Exception {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpdir = File.createTempFile("test", "tmp", createTempDir());
Map<String, String> params = createMap("baseDir", tmpdir.getAbsolutePath());

View File

@ -39,7 +39,8 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test
@SuppressWarnings("unchecked")
public void testSimple() throws IOException {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpdir = createTempDir();
createFile(tmpdir, "a.xml", "a.xml".getBytes("UTF-8"), false);
createFile(tmpdir, "b.xml", "b.xml".getBytes("UTF-8"), false);
createFile(tmpdir, "c.props", "c.props".getBytes("UTF-8"), false);
@ -62,7 +63,10 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test
public void testBiggerSmallerFiles() throws IOException {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpdir = File.createTempFile("test", "tmp", createTempDir());
tmpdir.delete();
tmpdir.mkdir();
long minLength = Long.MAX_VALUE;
String smallestFile = "";
byte[] content = "abcdefgij".getBytes("UTF-8");
@ -129,7 +133,8 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test
public void testNTOT() throws IOException {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpdir = createTempDir();
createFile(tmpdir, "a.xml", "a.xml".getBytes("UTF-8"), true);
createFile(tmpdir, "b.xml", "b.xml".getBytes("UTF-8"), true);
createFile(tmpdir, "c.props", "c.props".getBytes("UTF-8"), true);
@ -162,8 +167,9 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test
public void testRECURSION() throws IOException {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpdir = createTempDir();
File childdir = new File(tmpdir + "/child" );
childdir.mkdir();
createFile(childdir, "a.xml", "a.xml".getBytes("UTF-8"), true);
createFile(childdir, "b.xml", "b.xml".getBytes("UTF-8"), true);
createFile(childdir, "c.props", "c.props".getBytes("UTF-8"), true);

View File

@ -16,17 +16,15 @@
*/
package org.apache.solr.handler.dataimport;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class TestNonWritablePersistFile extends AbstractDataImportHandlerTestCase {
private static final String FULLIMPORT_QUERY = "select * from x";
@ -54,8 +52,7 @@ public class TestNonWritablePersistFile extends AbstractDataImportHandlerTestCas
@BeforeClass
public static void createTempSolrHomeAndCore() throws Exception {
createTempDir();
tmpSolrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
tmpSolrHome = createTempDir().getAbsolutePath();
FileUtils.copyDirectory(getFile("dih/solr"), new File(tmpSolrHome).getAbsoluteFile());
initCore("dataimport-solrconfig.xml", "dataimport-schema.xml",
new File(tmpSolrHome).getAbsolutePath());

View File

@ -6,16 +6,11 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -48,7 +43,9 @@ public class TestSimplePropertiesWriter extends AbstractDIHJdbcTestCase {
@Before
public void spwBefore() throws Exception {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpdir = File.createTempFile("test", "tmp", createTempDir());
tmpdir.delete();
tmpdir.mkdir();
fileLocation = tmpdir.getPath();
fileName = "the.properties";
}

View File

@ -26,8 +26,6 @@ import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
@ -306,7 +304,7 @@ public class TestSolrEntityProcessorEndToEnd extends AbstractDataImportHandlerTe
}
public String getDataDir() {
return dataDir.toString();
return initCoreDataDir.toString();
}
public String getSolrConfigFile() {
@ -318,14 +316,13 @@ public class TestSolrEntityProcessorEndToEnd extends AbstractDataImportHandlerTe
}
public void setUp() throws Exception {
File home = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
homeDir = new File(home + "inst");
dataDir = new File(homeDir + "/collection1", "data");
String home = createTempDir().getAbsolutePath();
homeDir = new File(home + "inst");
initCoreDataDir = new File(homeDir + "/collection1", "data");
confDir = new File(homeDir + "/collection1", "conf");
homeDir.mkdirs();
dataDir.mkdirs();
initCoreDataDir.mkdirs();
confDir.mkdirs();
FileUtils.copyFile(getFile(getSolrXmlFile()), new File(homeDir, "solr.xml"));

View File

@ -16,10 +16,6 @@
*/
package org.apache.solr.handler.dataimport;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.Test;
import java.io.File;
import java.io.Reader;
import java.io.StringReader;
@ -29,6 +25,8 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
/**
* <p>
* Test for XPathEntityProcessor
@ -44,7 +42,8 @@ public class TestXPathEntityProcessor extends AbstractDataImportHandlerTestCase
@Test
public void withFieldsAndXpath() throws Exception {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpdir = createTempDir();
createFile(tmpdir, "x.xsl", xsl.getBytes("UTF-8"), false);
Map entityAttrs = createMap("name", "e", "url", "cd.xml",
XPathEntityProcessor.FOR_EACH, "/catalog/cd");
@ -332,8 +331,12 @@ public class TestXPathEntityProcessor extends AbstractDataImportHandlerTestCase
@Test
public void withDefaultSolrAndXsl() throws Exception {
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
AbstractDataImportHandlerTestCase.createFile(tmpdir, "x.xsl", xsl.getBytes("UTF-8"), false);
File tmpdir = File.createTempFile("test", "tmp", createTempDir());
tmpdir.delete();
tmpdir.mkdir();
AbstractDataImportHandlerTestCase.createFile(tmpdir, "x.xsl", xsl.getBytes("UTF-8"),
false);
Map entityAttrs = createMap("name", "e",
XPathEntityProcessor.USE_SOLR_ADD_SCHEMA, "true", "xsl", ""
+ new File(tmpdir, "x.xsl").toURI(), "url", "cd.xml");

View File

@ -50,8 +50,7 @@ public class TestZKPropertiesWriter extends AbstractDataImportHandlerTestCase {
@BeforeClass
public static void dihZk_beforeClass() throws Exception {
createTempDir();
zkDir = dataDir.getAbsolutePath() + File.separator
zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();

View File

@ -21,8 +21,6 @@ import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.hadoop.morphline.MorphlineMapRunner;
import org.apache.solr.morphlines.solr.AbstractSolrMorphlineTestBase;
@ -47,7 +45,9 @@ public abstract class MRUnitBase extends SolrTestCaseJ4 {
}
protected void setupHadoopConfig(Configuration config) throws IOException {
String tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
String tempDir = createTempDir().getAbsolutePath();
FileUtils.copyFile(new File(RESOURCES_DIR + "/custom-mimetypes.xml"), new File(tempDir + "/custom-mimetypes.xml"));
AbstractSolrMorphlineTestBase.setupMorphline(tempDir, "test-morphlines/solrCellDocumentTypes", true);

View File

@ -27,8 +27,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.AbstractZkTestCase;
import org.apache.solr.hadoop.dedup.NoChangeUpdateConflictResolver;
@ -57,12 +55,11 @@ public class MapReduceIndexerToolArgumentParserTest extends SolrTestCaseJ4 {
private static final Logger LOG = LoggerFactory.getLogger(MapReduceIndexerToolArgumentParserTest.class);
private static File solrHomeDirectory;
private final File solrHomeDirectory = createTempDir();
@BeforeClass
public static void beforeClass() {
assumeFalse("Does not work on Windows, because it uses UNIX shell commands or POSIX paths", Constants.WINDOWS);
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
}
@Before

View File

@ -38,8 +38,6 @@ import org.apache.hadoop.util.JarFinder;
import org.apache.hadoop.util.ToolRunner;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.AbstractZkTestCase;
@ -81,7 +79,7 @@ public class MorphlineBasicMiniMRTest extends SolrTestCaseJ4 {
private static String tempDir;
private static File solrHomeDirectory;
private static final File solrHomeDirectory = createTempDir();
protected MapReduceIndexerTool createTool() {
return new MapReduceIndexerTool();
@ -110,7 +108,6 @@ public class MorphlineBasicMiniMRTest extends SolrTestCaseJ4 {
@BeforeClass
public static void setupClass() throws Exception {
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
assumeTrue(
"Currently this test can only be run without the lucene test security policy in place",
@ -125,8 +122,8 @@ public class MorphlineBasicMiniMRTest extends SolrTestCaseJ4 {
AbstractZkTestCase.SOLRHOME = solrHomeDirectory;
FileUtils.copyDirectory(MINIMR_CONF_DIR, solrHomeDirectory);
tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
File dataDir = createTempDir();
tempDir = dataDir.getAbsolutePath();
new File(tempDir).mkdirs();
FileUtils.copyFile(new File(RESOURCES_DIR + "/custom-mimetypes.xml"), new File(tempDir + "/custom-mimetypes.xml"));
@ -144,7 +141,6 @@ public class MorphlineBasicMiniMRTest extends SolrTestCaseJ4 {
// sb.append(",").append(i.getCanonicalHostName());
// }
createTempDir();
new File(dataDir, "nm-local-dirs").mkdirs();
System.setProperty("solr.hdfs.blockcache.enabled", "false");

View File

@ -43,8 +43,6 @@ import org.apache.hadoop.util.JarFinder;
import org.apache.hadoop.util.ToolRunner;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
@ -110,7 +108,7 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
private final String inputAvroFile2;
private final String inputAvroFile3;
private static File solrHomeDirectory;
private static final File solrHomeDirectory = createTempDir();
@Override
public String getSolrHome() {
@ -140,17 +138,18 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
assumeFalse("FIXME: This test fails under Java 8 due to the Saxon dependency - see SOLR-1301", Constants.JRE_IS_MINIMUM_JAVA8);
assumeFalse("FIXME: This test fails under J9 due to the Saxon dependency - see SOLR-1301", System.getProperty("java.vm.info", "<?>").contains("IBM J9"));
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
AbstractZkTestCase.SOLRHOME = solrHomeDirectory;
FileUtils.copyDirectory(MINIMR_INSTANCE_DIR, AbstractZkTestCase.SOLRHOME);
tempDir = createTempDir().getAbsolutePath();
new File(tempDir).mkdirs();
tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
FileUtils.copyFile(new File(RESOURCES_DIR + "/custom-mimetypes.xml"), new File(tempDir + "/custom-mimetypes.xml"));
AbstractSolrMorphlineTestBase.setupMorphline(tempDir, "test-morphlines/solrCellDocumentTypes", true);
System.setProperty("hadoop.log.dir", new File(dataDir, "logs").getAbsolutePath());
System.setProperty("hadoop.log.dir", new File(tempDir, "logs").getAbsolutePath());
int taskTrackers = 2;
int dataNodes = 2;
@ -162,16 +161,15 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
conf.set("dfs.permissions", "true");
conf.set("hadoop.security.authentication", "simple");
conf.set(YarnConfiguration.NM_LOCAL_DIRS, dataDir + File.separator + "nm-local-dirs");
conf.set(YarnConfiguration.DEFAULT_NM_LOG_DIRS, dataDir + File.separator + "nm-logs");
conf.set(YarnConfiguration.NM_LOCAL_DIRS, tempDir + File.separator + "nm-local-dirs");
conf.set(YarnConfiguration.DEFAULT_NM_LOG_DIRS, tempDir + File.separator + "nm-logs");
createTempDir();
new File(dataDir + File.separator + "nm-local-dirs").mkdirs();
new File(tempDir + File.separator + "nm-local-dirs").mkdirs();
System.setProperty("test.build.dir", dataDir + File.separator + "hdfs" + File.separator + "test-build-dir");
System.setProperty("test.build.data", dataDir + File.separator + "hdfs" + File.separator + "build");
System.setProperty("test.cache.data", dataDir + File.separator + "hdfs" + File.separator + "cache");
System.setProperty("test.build.dir", tempDir + File.separator + "hdfs" + File.separator + "test-build-dir");
System.setProperty("test.build.data", tempDir + File.separator + "hdfs" + File.separator + "build");
System.setProperty("test.cache.data", tempDir + File.separator + "hdfs" + File.separator + "cache");
dfsCluster = new MiniDFSCluster(conf, dataNodes, true, null);
FileSystem fileSystem = dfsCluster.getFileSystem();
@ -185,7 +183,7 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
fileSystem.setPermission(new Path("/hadoop/mapred/system"),
FsPermission.valueOf("-rwx------"));
mrCluster = MiniMRClientClusterFactory.create(MorphlineGoLiveMiniMRTest.class, 1, conf, new File(dataDir, "mrCluster"));
mrCluster = MiniMRClientClusterFactory.create(MorphlineGoLiveMiniMRTest.class, 1, conf, new File(tempDir, "mrCluster"));
//new MiniMRCluster(0, 0, taskTrackers, nnURI, numDirs, racks,
//hosts, null, conf);

View File

@ -32,8 +32,6 @@ import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
@ -120,7 +118,7 @@ public class AbstractSolrMorphlineTestBase extends SolrTestCaseJ4 {
testServer = new SolrServerDocumentLoader(solrServer, batchSize);
deleteAllDocuments();
tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
tempDir = createTempDir().getAbsolutePath();
}
@After

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import java.util.Iterator;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
@ -33,9 +32,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.kitesdk.morphline.api.Command;
import org.kitesdk.morphline.api.Collector;
import org.kitesdk.morphline.api.Command;
import org.kitesdk.morphline.api.MorphlineContext;
import org.kitesdk.morphline.api.Record;
import org.kitesdk.morphline.base.Compiler;
@ -48,7 +46,7 @@ import com.google.common.collect.ListMultimap;
import com.typesafe.config.Config;
public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistribZkTestBase {
private static File solrHomeDirectory;
private static final File solrHomeDirectory = createTempDir();
protected static final String RESOURCES_DIR = getFile("morphlines-core.marker").getParent();
private static final File SOLR_INSTANCE_DIR = new File(RESOURCES_DIR + "/solr");
@ -70,10 +68,8 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri
@BeforeClass
public static void setupClass() throws Exception {
solrHomeDirectory = TestUtil.createTempDir(AbstractSolrMorphlineZkTestBase.class.getName());
AbstractZkTestCase.SOLRHOME = solrHomeDirectory;
FileUtils.copyDirectory(SOLR_INSTANCE_DIR, solrHomeDirectory);
createTempDir();
}
@Override

View File

@ -17,8 +17,10 @@ package org.apache.solr;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
@ -30,9 +32,6 @@ import org.apache.solr.core.SolrCore;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.io.File;
import java.io.IOException;
public class AnalysisAfterCoreReloadTest extends SolrTestCaseJ4 {
private static String tmpSolrHome;
@ -43,8 +42,7 @@ public class AnalysisAfterCoreReloadTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
createTempDir();
tmpSolrHome = TestUtil.createTempDir(AnalysisAfterCoreReloadTest.class.getSimpleName()).getAbsolutePath();
tmpSolrHome = createTempDir().getAbsolutePath();
FileUtils.copyDirectory(new File(TEST_HOME()), new File(tmpSolrHome).getAbsoluteFile());
initCore("solrconfig.xml", "schema.xml", new File(tmpSolrHome).getAbsolutePath());
}

View File

@ -17,15 +17,13 @@ package org.apache.solr;
* limitations under the License.
*/
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
public class SolrTestCaseJ4Test extends SolrTestCaseJ4 {
@ -35,8 +33,7 @@ public class SolrTestCaseJ4Test extends SolrTestCaseJ4 {
public static void beforeClass() throws Exception {
// Create a temporary directory that holds a core NOT named "collection1". Use the smallest configuration sets
// we can so we don't copy that much junk around.
createTempDir();
tmpSolrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
tmpSolrHome = createTempDir().getAbsolutePath();
File subHome = new File(new File(tmpSolrHome, "core0"), "conf");
assertTrue("Failed to make subdirectory ", subHome.mkdirs());

View File

@ -16,25 +16,19 @@
*/
package org.apache.solr;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.TestUtil;
//import org.apache.lucene.util.LuceneTestCase;
//import org.apache.solr.util.AbstractSolrTestCase;
//import org.apache.solr.client.solrj.embedded.JettySolrRunner;
//import org.apache.solr.client.solrj.impl.HttpSolrServer;
//import org.apache.solr.client.solrj.SolrServer;
//import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.commons.io.FileUtils;
import org.junit.BeforeClass;
import java.io.*;
import java.util.Properties;
/**
* <p> Test for Loading core properties from a properties file </p>
@ -46,7 +40,8 @@ public class TestSolrCoreProperties extends SolrJettyTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
File homeDir = TestUtil.createTempDir(TestSolrCoreProperties.class.getSimpleName());
File homeDir = createTempDir();
File collDir = new File(homeDir, "collection1");
File dataDir = new File(collDir, "data");
File confDir = new File(collDir, "conf");

View File

@ -26,8 +26,6 @@ import java.util.regex.Pattern;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
@ -170,8 +168,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
createCmd.setCoreName(ONE_NODE_COLLECTION + "core");
createCmd.setCollection(ONE_NODE_COLLECTION);
createCmd.setNumShards(1);
createCmd.setDataDir(getDataDir(dataDir.getAbsolutePath() + File.separator
+ ONE_NODE_COLLECTION));
createCmd.setDataDir(getDataDir(createTempDir(ONE_NODE_COLLECTION).getAbsolutePath()));
server.request(createCmd);
server.shutdown();
} catch (Exception e) {
@ -417,7 +414,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/replication");
params.set("command", "backup");
File location = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + "-backupdir");
File location = createTempDir();
params.set("location", location.getAbsolutePath());
QueryRequest request = new QueryRequest(params);

View File

@ -17,7 +17,6 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
@ -38,8 +37,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.lang.StringUtils;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.JSONTestUtil;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServer;
@ -388,8 +387,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
Create createCmd = new Create();
createCmd.setCoreName("core1");
createCmd.setCollection("the_core_collection");
String coredataDir = dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + "the_core_collection";
String coredataDir = createTempDir().getAbsolutePath();
createCmd.setDataDir(coredataDir);
createCmd.setNumShards(1);
createCmd.setSchemaName("nonexistent_schema.xml");
@ -569,8 +567,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
createCmd.setNumShards(numShards);
try {
String core3dataDir = dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + collection + "_3n" + freezeI;
String core3dataDir = createTempDir(collection).getAbsolutePath();
createCmd.setDataDir(getDataDir(core3dataDir));
server.request(createCmd);
@ -982,8 +979,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
if (shardId == null) {
createCmd.setNumShards(2);
}
createCmd.setDataDir(getDataDir(dataDir.getAbsolutePath() + File.separator
+ collection + num));
createCmd.setDataDir(getDataDir(createTempDir(collection).getAbsolutePath()));
if (shardId != null) {
createCmd.setShardId(shardId);
}
@ -1110,11 +1106,8 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
server.setSoTimeout(60000);
Create createCmd = new Create();
createCmd.setCoreName(collection);
createCmd.setDataDir(getDataDir(dataDir.getAbsolutePath() + File.separator
+ collection + frozeUnique));
createCmd.setDataDir(getDataDir(createTempDir(collection).getAbsolutePath()));
server.request(createCmd);
} catch (Exception e) {
e.printStackTrace();
//fails

View File

@ -68,11 +68,12 @@ public class ClusterStateUpdateTest extends SolrTestCaseJ4 {
private File dataDir4;
private static File solrHomeDirectory;
private static volatile File solrHomeDirectory;
@BeforeClass
public static void beforeClass() throws IOException {
solrHomeDirectory = TestUtil.createTempDir(ClusterStateUpdateTest.class.getSimpleName());
solrHomeDirectory = new File(createTempDir(), "ZkControllerTest");
System.setProperty("solrcloud.skip.autorecovery", "true");
System.setProperty("genericCoreNodeNames", "false");
if (solrHomeDirectory.exists()) {
@ -95,10 +96,9 @@ public class ClusterStateUpdateTest extends SolrTestCaseJ4 {
@Override
public void setUp() throws Exception {
super.setUp();
createTempDir();
System.setProperty("zkClientTimeout", "3000");
zkDir = dataDir.getAbsolutePath() + File.separator
File tmpDir = createTempDir();
zkDir = tmpDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();
@ -107,16 +107,16 @@ public class ClusterStateUpdateTest extends SolrTestCaseJ4 {
.getZkAddress(), "solrconfig.xml", "schema.xml");
log.info("####SETUP_START " + getTestName());
dataDir1 = new File(dataDir + File.separator + "data1");
dataDir1 = new File(tmpDir + File.separator + "data1");
dataDir1.mkdirs();
dataDir2 = new File(dataDir + File.separator + "data2");
dataDir2 = new File(tmpDir + File.separator + "data2");
dataDir2.mkdirs();
dataDir3 = new File(dataDir + File.separator + "data3");
dataDir3 = new File(tmpDir + File.separator + "data3");
dataDir3.mkdirs();
dataDir4 = new File(dataDir + File.separator + "data4");
dataDir4 = new File(tmpDir + File.separator + "data4");
dataDir4.mkdirs();
// set some system properties for use by tests

View File

@ -50,7 +50,6 @@ import javax.management.ObjectName;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServer;
@ -335,8 +334,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
Create createCmd = new Create();
createCmd.setCoreName("halfdeletedcollection_shard1_replica1");
createCmd.setCollection(collectionName);
String dataDir = SolrTestCaseJ4.dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + "halfcollection" + "_hdn";
String dataDir = createTempDir().getAbsolutePath();
createCmd.setDataDir(dataDir);
createCmd.setNumShards(2);
if (secondConfigSet) {
@ -527,8 +525,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
Create createCmd = new Create();
createCmd.setCoreName("halfcollection_shard1_replica1");
createCmd.setCollection("halfcollectionblocker");
String dataDir = SolrTestCaseJ4.dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + "halfcollection" + "_3n";
String dataDir = createTempDir().getAbsolutePath();
createCmd.setDataDir(dataDir);
createCmd.setNumShards(1);
if (secondConfigSet) {
@ -539,8 +536,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
createCmd = new Create();
createCmd.setCoreName("halfcollection_shard1_replica1");
createCmd.setCollection("halfcollectionblocker2");
dataDir = SolrTestCaseJ4.dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + "halfcollection" + "_3n";
dataDir = createTempDir().getAbsolutePath();
createCmd.setDataDir(dataDir);
createCmd.setNumShards(1);
if (secondConfigSet) {
@ -589,8 +585,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
Create createCmd = new Create();
createCmd.setCoreName("corewithnocollection");
createCmd.setCollection("");
String dataDir = SolrTestCaseJ4.dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + "corewithnocollection" + "_1v";
String dataDir = createTempDir().getAbsolutePath();
createCmd.setDataDir(dataDir);
createCmd.setNumShards(1);
if (secondConfigSet) {

View File

@ -36,9 +36,8 @@ public class ConnectionManagerTest extends SolrTestCaseJ4 {
@Ignore
public void testConnectionManager() throws Exception {
createTempDir();
// setup a SolrZkClient to do some getBaseUrlForNodeName testing
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -72,9 +71,8 @@ public class ConnectionManagerTest extends SolrTestCaseJ4 {
public void testLikelyExpired() throws Exception {
createTempDir();
// setup a SolrZkClient to do some getBaseUrlForNodeName testing
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);

View File

@ -73,14 +73,14 @@ public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
@Override
public void setUp() throws Exception {
super.setUp();
createTempDir();
ignoreException("No UpdateLog found - cannot sync");
ignoreException("No UpdateLog found - cannot recover");
System.setProperty("zkClientTimeout", "8000");
zkDir = dataDir.getAbsolutePath() + File.separator
+ "zookeeper" + System.currentTimeMillis() + "/server1/data";
zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();
System.setProperty("zkHost", zkServer.getZkAddress());
@ -133,8 +133,7 @@ public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
private void setupContainer(int port, String shard) throws IOException,
ParserConfigurationException, SAXException {
File data = new File(dataDir + File.separator + "data_" + port);
data.mkdirs();
File data = createTempDir();
System.setProperty("hostPort", Integer.toString(port));
System.setProperty("shard", shard);

View File

@ -55,7 +55,7 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() {
createTempDir();
}
@AfterClass
@ -66,7 +66,7 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
@Override
public void setUp() throws Exception {
super.setUp();
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
server = new ZkTestServer(zkDir);

View File

@ -43,7 +43,6 @@ import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.handler.admin.CollectionsHandler;
import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.zookeeper.CreateMode;
@ -204,7 +203,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testShardAssignment() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -260,7 +259,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testBadQueueItem() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -335,7 +334,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testShardAssignmentBigger() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
final int nodeCount = random().nextInt(50)+50; //how many simulated nodes (num of threads)
@ -506,7 +505,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testStateChange() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -603,7 +602,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testOverseerFailure() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -726,7 +725,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testShardLeaderChange() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
final ZkTestServer server = new ZkTestServer(zkDir);
SolrZkClient controllerClient = null;
@ -782,7 +781,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testDoubleAssignment() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -847,7 +846,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testPlaceholders() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -896,7 +895,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
@Test
public void testReplay() throws Exception{
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
SolrZkClient zkClient = null;

View File

@ -74,10 +74,10 @@ public class SliceStateUpdateTest extends SolrTestCaseJ4 {
@Override
public void setUp() throws Exception {
super.setUp();
createTempDir();
System.setProperty("zkClientTimeout", "3000");
zkDir = dataDir.getAbsolutePath() + File.separator
zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();
@ -99,11 +99,9 @@ public class SliceStateUpdateTest extends SolrTestCaseJ4 {
CreateMode.PERSISTENT, true);
zkClient.close();
dataDir1 = new File(dataDir + File.separator + "data1");
dataDir1.mkdirs();
dataDir1 = new File(createTempDir() + File.separator + "data1");
dataDir2 = new File(dataDir + File.separator + "data2");
dataDir2.mkdirs();
dataDir2 = new File(createTempDir() + File.separator + "data2");
// set some system properties for use by tests
System.setProperty("solr.test.sys.prop1", "propone");

View File

@ -16,8 +16,10 @@ package org.apache.solr.cloud;
* the License.
*/
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import com.google.common.base.Charsets;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
@ -32,11 +34,8 @@ import org.junit.Test;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import com.google.common.base.Charsets;
public class SolrXmlInZkTest extends SolrTestCaseJ4 {
@ -51,8 +50,6 @@ public class SolrXmlInZkTest extends SolrTestCaseJ4 {
private ZkStateReader reader;
private static int PORT = 7000;
private ConfigSolr cfg;
@Before
@ -61,9 +58,9 @@ public class SolrXmlInZkTest extends SolrTestCaseJ4 {
}
private void setUpZkAndDiskXml(boolean toZk, boolean leaveOnLocal) throws Exception {
createTempDir();
File solrHome = new File(dataDir, "home");
File tmpDir = createTempDir();
recurseDelete(tmpDir);
File solrHome = new File(tmpDir, "home");
copyMinConf(new File(solrHome, "myCollect"));
if (leaveOnLocal) {
FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr-stress-new.xml"), new File(solrHome, "solr.xml"));
@ -76,7 +73,7 @@ public class SolrXmlInZkTest extends SolrTestCaseJ4 {
System.setProperty("zkClientTimeout", "8000");
zkDir = dataDir.getAbsolutePath() + File.separator
zkDir = tmpDir.getAbsolutePath() + File.separator
+ "zookeeper" + System.currentTimeMillis() + "/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();

View File

@ -19,8 +19,6 @@ package org.apache.solr.cloud;
import java.io.File;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.core.CoreContainer;
@ -36,6 +34,7 @@ public class TestMultiCoreConfBootstrap extends SolrTestCaseJ4 {
protected CoreContainer cores = null;
private String home;
protected File dataDir1;
protected File dataDir2;
protected ZkTestServer zkServer;
protected String zkDir;
@ -44,16 +43,15 @@ public class TestMultiCoreConfBootstrap extends SolrTestCaseJ4 {
@Before
public void setUp() throws Exception {
super.setUp();
createTempDir();
dataDir2 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
dataDir1 = createTempDir();
dataDir2 = createTempDir();
home = ExternalPaths.EXAMPLE_MULTICORE_HOME;
System.setProperty("solr.solr.home", home);
System.setProperty( "solr.core0.data.dir", dataDir.getCanonicalPath() );
System.setProperty( "solr.core0.data.dir", dataDir1.getCanonicalPath() );
System.setProperty( "solr.core1.data.dir", dataDir2.getCanonicalPath() );
zkDir = dataDir.getAbsolutePath() + File.separator
zkDir = dataDir1.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();

View File

@ -17,11 +17,12 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
import java.io.File;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZooKeeperException;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.ExternalPaths;
import org.junit.After;
import org.junit.Before;
@ -29,8 +30,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class TestZkChroot extends SolrTestCaseJ4 {
protected static Logger log = LoggerFactory.getLogger(TestZkChroot.class);
protected CoreContainer cores = null;
@ -43,8 +42,8 @@ public class TestZkChroot extends SolrTestCaseJ4 {
@Before
public void setUp() throws Exception {
super.setUp();
createTempDir();
zkDir = dataDir.getAbsolutePath() + File.separator
zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();

View File

@ -84,13 +84,11 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
private void testUnloadShardAndCollection() throws Exception{
// create one leader and one replica
Create createCmd = new Create();
createCmd.setCoreName("test_unload_shard_and_collection_1");
String collection = "test_unload_shard_and_collection";
createCmd.setCollection(collection);
String coreDataDir = dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + collection + "1";
String coreDataDir = createTempDir().getAbsolutePath();
createCmd.setDataDir(getDataDir(coreDataDir));
createCmd.setNumShards(2);
@ -105,8 +103,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
createCmd.setCoreName("test_unload_shard_and_collection_2");
collection = "test_unload_shard_and_collection";
createCmd.setCollection(collection);
coreDataDir = dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + collection + "2";
coreDataDir = createTempDir().getAbsolutePath();
createCmd.setDataDir(getDataDir(coreDataDir));
server.request(createCmd);
@ -157,6 +154,8 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
* @throws Exception on any problem
*/
private void testCoreUnloadAndLeaders() throws Exception {
File tmpDir = createTempDir();
// create a new collection collection
SolrServer client = clients.get(0);
String url1 = getBaseUrl(client);
@ -168,7 +167,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
createCmd.setCoreName("unloadcollection1");
createCmd.setCollection("unloadcollection");
createCmd.setNumShards(1);
String core1DataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection1" + "_1n";
String core1DataDir = tmpDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection1" + "_1n";
createCmd.setDataDir(getDataDir(core1DataDir));
server.request(createCmd);
server.shutdown();
@ -188,7 +187,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
createCmd = new Create();
createCmd.setCoreName("unloadcollection2");
createCmd.setCollection("unloadcollection");
String core2dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection1" + "_2n";
String core2dataDir = tmpDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection1" + "_2n";
createCmd.setDataDir(getDataDir(core2dataDir));
server.request(createCmd);
server.shutdown();
@ -230,7 +229,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
createCmd = new Create();
createCmd.setCoreName("unloadcollection3");
createCmd.setCollection("unloadcollection");
String core3dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection" + "_3n";
String core3dataDir = tmpDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection" + "_3n";
createCmd.setDataDir(getDataDir(core3dataDir));
server.request(createCmd);
server.shutdown();
@ -308,7 +307,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
createCmd = new Create();
createCmd.setCoreName("unloadcollection4");
createCmd.setCollection("unloadcollection");
String core4dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection" + "_4n";
String core4dataDir = tmpDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection" + "_4n";
createCmd.setDataDir(getDataDir(core4dataDir));
server.request(createCmd);
server.shutdown();

View File

@ -28,8 +28,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.SolrZkClient;
@ -76,21 +74,20 @@ public class ZkCLITest extends SolrTestCaseJ4 {
public void setUp() throws Exception {
super.setUp();
log.info("####SETUP_START " + getTestName());
createTempDir();
boolean useNewSolrXml = random().nextBoolean();
File tmpDir = createTempDir();
if (useNewSolrXml) {
solrHome = ExternalPaths.EXAMPLE_HOME;
} else {
File tmpSolrHome = new File(dataDir, "tmp-solr-home");
File tmpSolrHome = new File(tmpDir, "tmp-solr-home");
FileUtils.copyDirectory(new File(ExternalPaths.EXAMPLE_HOME), tmpSolrHome);
FileUtils.copyFile(getFile("old-solr-example/solr.xml"), new File(tmpSolrHome, "solr.xml"));
solrHome = tmpSolrHome.getAbsolutePath();
}
zkDir = dataDir.getAbsolutePath() + File.separator
zkDir = tmpDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
log.info("ZooKeeper dataDir:" + zkDir);
zkServer = new ZkTestServer(zkDir);
@ -206,6 +203,8 @@ public class ZkCLITest extends SolrTestCaseJ4 {
@Test
public void testUpConfigLinkConfigClearZk() throws Exception {
File tmpDir = createTempDir();
// test upconfig
String confsetname = "confsetone";
String[] args = new String[] {
@ -233,7 +232,8 @@ public class ZkCLITest extends SolrTestCaseJ4 {
assertEquals(confsetname, collectionProps.getStr("configName"));
// test down config
File confDir = new File(TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()), "solrtest-confdropspot");
File confDir = new File(tmpDir,
"solrtest-confdropspot-" + this.getClass().getName() + "-" + System.currentTimeMillis());
assertFalse(confDir.exists());
args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
@ -277,11 +277,14 @@ public class ZkCLITest extends SolrTestCaseJ4 {
@Test
public void testGetFile() throws Exception {
File tmpDir = createTempDir();
String getNode = "/getFileNode";
byte [] data = new String("getFileNode-data").getBytes("UTF-8");
this.zkClient.create(getNode, data, CreateMode.PERSISTENT, true);
File file = TestUtil.createTempFile("solrtest-getfile", "");
File file = new File(tmpDir,
"solrtest-getfile-" + this.getClass().getName() + "-" + System.currentTimeMillis());
String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
"getfile", getNode, file.getAbsolutePath()};
ZkCLI.main(args);
@ -292,9 +295,10 @@ public class ZkCLITest extends SolrTestCaseJ4 {
@Test
public void testGetFileNotExists() throws Exception {
File tmpDir = createTempDir();
String getNode = "/getFileNotExistsNode";
File file = TestUtil.createTempFile("solrtest-getfilenotexists", "");
File file = File.createTempFile("newfile", null, tmpDir);
String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
"getfile", getNode, file.getAbsolutePath()};
try {

View File

@ -50,7 +50,7 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
createTempDir();
}
@AfterClass
@ -81,7 +81,7 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
ZkController.generateNodeName("foo-bar", "77", "/solr/sub_dir/"));
// setup a SolrZkClient to do some getBaseUrlForNodeName testing
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -152,7 +152,7 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
@Test
public void testReadConfigName() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
CoreContainer cc = null;
@ -208,7 +208,7 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
@Test
public void testUploadToCloud() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
@ -261,7 +261,7 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
@Test
public void testGetHostName() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
CoreContainer cc = null;

View File

@ -40,7 +40,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
}
public void testConnect() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = null;
@ -54,7 +54,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
}
public void testMakeRootNode() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = null;
@ -73,7 +73,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
}
public void testClean() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = null;
@ -99,7 +99,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
}
public void testReconnect() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
ZkTestServer server = null;
SolrZkClient zkClient = null;
@ -193,7 +193,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
}
public void testWatchChildren() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
String zkDir = createTempDir().getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
final AtomicInteger cnt = new AtomicInteger();

View File

@ -21,7 +21,6 @@ import java.io.IOException;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.cloud.BasicDistributedZk2Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@ -38,7 +37,7 @@ public class HdfsBasicDistributedZk2Test extends BasicDistributedZk2Test {
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
}
@AfterClass

View File

@ -39,7 +39,7 @@ public class HdfsBasicDistributedZkTest extends BasicDistributedZkTest {
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
}
@AfterClass

View File

@ -21,7 +21,6 @@ import java.io.IOException;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.cloud.ChaosMonkeySafeLeaderTest;
import org.junit.AfterClass;
import org.junit.Before;
@ -39,7 +38,7 @@ public class HdfsChaosMonkeySafeLeaderTest extends ChaosMonkeySafeLeaderTest {
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
}
@AfterClass

View File

@ -17,11 +17,9 @@ package org.apache.solr.cloud.hdfs;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.cloud.CollectionsAPIDistributedZkTest;
import org.junit.AfterClass;
@ -39,7 +37,7 @@ public class HdfsCollectionsAPIDistributedZkTest extends CollectionsAPIDistribut
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
System.setProperty("solr.hdfs.home", dfsCluster.getURI().toString() + "/solr");
System.setProperty("solr.hdfs.blockcache.enabled", "false");

View File

@ -17,7 +17,6 @@ package org.apache.solr.cloud.hdfs;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.hdfs.MiniDFSCluster;
@ -38,7 +37,7 @@ public class HdfsRecoveryZkTest extends RecoveryZkTest {
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
System.setProperty("solr.hdfs.blockcache.blocksperbank", "2048");
}

View File

@ -17,9 +17,7 @@ package org.apache.solr.cloud.hdfs;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.LuceneTestCase.Slow;
@ -40,7 +38,7 @@ public class HdfsSyncSliceTest extends SyncSliceTest {
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
}
@AfterClass

View File

@ -39,12 +39,10 @@ public class HdfsTestUtil {
private static Map<MiniDFSCluster,Timer> timers = new ConcurrentHashMap<>();
public static MiniDFSCluster setupClass() throws Exception {
public static MiniDFSCluster setupClass(String dir) throws Exception {
LuceneTestCase.assumeFalse("HDFS tests were disabled by -Dtests.disableHdfs",
Boolean.parseBoolean(System.getProperty("tests.disableHdfs", "false")));
File dir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
savedLocale = Locale.getDefault();
// TODO: we HACK around HADOOP-9643
Locale.setDefault(Locale.ENGLISH);
@ -55,12 +53,12 @@ public class HdfsTestUtil {
conf.set("dfs.block.access.token.enable", "false");
conf.set("dfs.permissions.enabled", "false");
conf.set("hadoop.security.authentication", "simple");
conf.set("hdfs.minidfs.basedir", dir.getAbsolutePath() + File.separator + "hdfsBaseDir");
conf.set("dfs.namenode.name.dir", dir.getAbsolutePath() + File.separator + "nameNodeNameDir");
conf.set("hdfs.minidfs.basedir", dir + File.separator + "hdfsBaseDir");
conf.set("dfs.namenode.name.dir", dir + File.separator + "nameNodeNameDir");
System.setProperty("test.build.data", dir.getAbsolutePath() + File.separator + "hdfs" + File.separator + "build");
System.setProperty("test.cache.data", dir.getAbsolutePath() + File.separator + "hdfs" + File.separator + "cache");
System.setProperty("test.build.data", dir + File.separator + "hdfs" + File.separator + "build");
System.setProperty("test.cache.data", dir + File.separator + "hdfs" + File.separator + "cache");
System.setProperty("solr.lock.type", "hdfs");
System.setProperty("solr.hdfs.home", "/solr_hdfs_home");

View File

@ -17,12 +17,9 @@ package org.apache.solr.cloud.hdfs;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.cloud.UnloadDistributedZkTest;
import org.junit.AfterClass;
@ -40,7 +37,7 @@ public class HdfsUnloadDistributedZkTest extends UnloadDistributedZkTest {
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
}
@AfterClass

View File

@ -17,7 +17,6 @@
package org.apache.solr.cloud.hdfs;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@ -26,8 +25,6 @@ import java.util.List;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.NRTCachingDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Nightly;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrQuery;
@ -62,7 +59,7 @@ public class HdfsWriteToMultipleCollectionsTest extends BasicDistributedZkTest {
@BeforeClass
public static void setupClass() throws Exception {
schemaString = "schema15.xml"; // we need a string id
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
System.setProperty(SOLR_HDFS_HOME, dfsCluster.getURI().toString() + "/solr");
}

View File

@ -17,7 +17,6 @@
package org.apache.solr.cloud.hdfs;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@ -32,7 +31,6 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
@ -63,7 +61,7 @@ public class StressHdfsTest extends BasicDistributedZkTest {
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
System.setProperty("solr.hdfs.home", dfsCluster.getURI().toString() + "/solr");
}

View File

@ -24,8 +24,6 @@ import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.junit.After;
@ -37,9 +35,7 @@ public class CoreContainerCoreInitFailuresTest extends SolrTestCaseJ4 {
CoreContainer cc = null;
private void init(final String dirSuffix) {
// would be nice to do this in an @Before method,
// but junit doesn't let @Before methods have test names
solrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + dirSuffix);
solrHome = createTempDir(dirSuffix);
}
@After

View File

@ -30,8 +30,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@ -87,7 +85,9 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
coreNames = new ArrayList<>();
cumulativeDocs = 0;
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
solrHomeDirectory = createTempDir();
FileUtils.deleteDirectory(solrHomeDirectory); // Ensure that a failed test didn't leave something lying around.
jetty = new JettySolrRunner(solrHomeDirectory.getAbsolutePath(), "/solr", 0, null, null, true, null, sslConfig);
}

View File

@ -17,20 +17,19 @@ package org.apache.solr.core;
* limitations under the License.
*/
import java.io.File;
import java.util.Map;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.store.NativeFSLockFactory;
import org.apache.lucene.store.SimpleFSLockFactory;
import org.apache.lucene.util.Version;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.util.Map;
public class SolrCoreCheckLockOnStartupTest extends SolrTestCaseJ4 {
@Override
@ -40,11 +39,8 @@ public class SolrCoreCheckLockOnStartupTest extends SolrTestCaseJ4 {
System.setProperty("solr.directoryFactory", "org.apache.solr.core.SimpleFSDirectoryFactory");
//explicitly creates the temp dataDir so we know where the index will be located
createTempDir();
IndexWriterConfig indexWriterConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, null);
Directory directory = newFSDirectory(new File(dataDir, "index"));
Directory directory = newFSDirectory(new File(createTempDir(), "index"));
//creates a new index on the known location
new IndexWriter(
directory,
@ -56,7 +52,7 @@ public class SolrCoreCheckLockOnStartupTest extends SolrTestCaseJ4 {
@Test
public void testSimpleLockErrorOnStartup() throws Exception {
Directory directory = newFSDirectory(new File(dataDir, "index"), new SimpleFSLockFactory());
Directory directory = newFSDirectory(new File(initCoreDataDir, "index"), new SimpleFSLockFactory());
//creates a new IndexWriter without releasing the lock yet
IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
@ -80,7 +76,7 @@ public class SolrCoreCheckLockOnStartupTest extends SolrTestCaseJ4 {
@Test
public void testNativeLockErrorOnStartup() throws Exception {
File indexDir = new File(dataDir, "index");
File indexDir = new File(initCoreDataDir, "index");
log.info("Acquiring lock on {}", indexDir.getAbsolutePath());
Directory directory = newFSDirectory(indexDir, new NativeFSLockFactory());
//creates a new IndexWriter without releasing the lock yet

View File

@ -17,19 +17,6 @@
package org.apache.solr.core;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.handler.component.SpellCheckComponent;
import org.apache.solr.handler.component.QueryComponent;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.solr.util.plugin.SolrCoreAware;
import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -39,6 +26,18 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.handler.component.QueryComponent;
import org.apache.solr.handler.component.SpellCheckComponent;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.solr.util.plugin.SolrCoreAware;
import org.junit.Test;
public class SolrCoreTest extends SolrTestCaseJ4 {
private static final String COLLECTION1 = "collection1";
@ -67,8 +66,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
core.close();
SolrCore newCore = new SolrCore(COLLECTION1, dataDir + File.separator
+ "datadir2", new SolrConfig("solr/collection1", "solrconfig.xml", null), schema,
SolrCore newCore = new SolrCore(COLLECTION1, createTempDir("dataDir2").getAbsolutePath(), new SolrConfig("solr/collection1", "solrconfig.xml", null), schema,
new CoreDescriptor(cores, COLLECTION1, "solr/collection1"));
cores.register(newCore, false);

View File

@ -74,9 +74,10 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{
public void setUp() throws Exception {
super.setUp();
dataDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmpDataDir = createTempDir();
solrConfig = TestHarness.createConfig(getSolrHome(), "solrconfig.xml");
h = new TestHarness( dataDir.getAbsolutePath(),
h = new TestHarness( tmpDataDir.getAbsolutePath(),
solrConfig,
"schema12.xml");
lrf = h.getRequestFactory

View File

@ -26,8 +26,6 @@ import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.Rule;
import org.junit.Test;
@ -44,7 +42,9 @@ public class TestConfigSets extends SolrTestCaseJ4 {
public static String solrxml = "<solr><str name=\"configSetBaseDir\">${configsets:configsets}</str></solr>";
public CoreContainer setupContainer(String testName, String configSetsBaseDir) {
File testDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + "-" + testName);
File testDirectory = new File(createTempDir(), testName);
testDirectory.mkdirs();
System.setProperty("configsets", configSetsBaseDir);
SolrResourceLoader loader = new SolrResourceLoader(testDirectory.getAbsolutePath());
@ -95,7 +95,8 @@ public class TestConfigSets extends SolrTestCaseJ4 {
@Test
public void testConfigSetOnCoreReload() throws IOException {
File testDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + "-core-reload");
File testDirectory = new File(initCoreDataDir, "core-reload");
testDirectory.mkdirs();
File configSetsDir = new File(testDirectory, "configsets");
FileUtils.copyDirectory(getFile("solr/configsets"), configSetsDir);

View File

@ -69,7 +69,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
private CoreContainer init(String dirName) throws Exception {
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + dirName);
solrHomeDirectory = createTempDir(dirName);
FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME()), solrHomeDirectory);
System.out.println("Using solrconfig from " + new File(SolrTestCaseJ4.TEST_HOME()).getAbsolutePath());
@ -148,7 +148,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Test
public void testNoCores() throws IOException, ParserConfigurationException, SAXException {
//create solrHome
File solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + "_noCores");
File solrHomeDirectory = createTempDir();
boolean oldSolrXml = random().nextBoolean();

View File

@ -25,8 +25,6 @@ import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.junit.After;
@ -40,10 +38,9 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
initCore();
}
private File solrHomeDirectory;
private final File solrHomeDirectory = createTempDir();
private void setMeUp(String alternateCoreDir) throws Exception {
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
System.setProperty("solr.solr.home", solrHomeDirectory.getAbsolutePath());
String xmlStr = SOLR_XML;
if (alternateCoreDir != null) {
@ -196,7 +193,9 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
@Test
public void testAlternateCoreDir() throws Exception {
File alt = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File alt = createTempDir();
setMeUp(alt.getAbsolutePath());
addCoreWithProps(makeCorePropFile("core1", false, true, "dataDir=core1"),
new File(alt, "core1" + File.separator + CorePropertiesLocator.PROPERTIES_FILENAME));
@ -214,7 +213,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
}
@Test
public void testNoCoreDir() throws Exception {
File noCoreDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File noCoreDir = new File(createTempDir(), "noCoreDir");
setMeUp(noCoreDir.getAbsolutePath());
addCoreWithProps(makeCorePropFile("core1", false, true),
new File(noCoreDir, "core1" + File.separator + CorePropertiesLocator.PROPERTIES_FILENAME));

View File

@ -29,8 +29,6 @@ import java.util.regex.Pattern;
import org.apache.commons.codec.Charsets;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CoreAdminParams;
@ -43,7 +41,7 @@ import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.update.UpdateHandler;
import org.apache.solr.util.TestHarness;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -56,8 +54,15 @@ public class TestLazyCores extends SolrTestCaseJ4 {
private File solrHomeDirectory;
@Before
@Override
public void setUp() throws Exception {
super.setUp();
}
private CoreContainer init() throws Exception {
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
solrHomeDirectory = createTempDir();
for (int idx = 1; idx < 10; ++idx) {
copyMinConf(new File(solrHomeDirectory, "collection" + idx));
}
@ -76,12 +81,6 @@ public class TestLazyCores extends SolrTestCaseJ4 {
return cores;
}
@After
public void after() throws Exception {
if (solrHomeDirectory.exists()) {
FileUtils.deleteDirectory(solrHomeDirectory);
}
}
@Test
public void testLazyLoad() throws Exception {
CoreContainer cc = init();
@ -500,13 +499,13 @@ public class TestLazyCores extends SolrTestCaseJ4 {
// Did we get the expected message for each of the cores that failed to load? Make sure we don't run afoul of
// the dreaded slash/backslash difference on Windows and *nix machines.
testMessage(cc.getCoreInitFailures(),
"TestLazyCores" + File.separator + "badConfig1" + File.separator + "solrconfig.xml");
"badConfig1" + File.separator + "solrconfig.xml");
testMessage(cc.getCoreInitFailures(),
"TestLazyCores" + File.separator + "badConfig2" + File.separator + "solrconfig.xml");
"badConfig2" + File.separator + "solrconfig.xml");
testMessage(cc.getCoreInitFailures(),
"TestLazyCores" + File.separator + "badSchema1" + File.separator + "schema.xml");
"badSchema1" + File.separator + "schema.xml");
testMessage(cc.getCoreInitFailures(),
"TestLazyCores" + File.separator + "badSchema2" + File.separator + "schema.xml");
"badSchema2" + File.separator + "schema.xml");
// Status should report that there are failure messages for the bad cores and none for the good cores.
checkStatus(cc, true, "core1");
@ -589,15 +588,11 @@ public class TestLazyCores extends SolrTestCaseJ4 {
private CoreContainer initGoodAndBad(List<String> goodCores,
List<String> badSchemaCores,
List<String> badConfigCores) throws Exception {
solrHomeDirectory = createTempDir();
// Don't pollute the log with exception traces when they're expected.
ignoreException(Pattern.quote("SAXParseException"));
if (solrHomeDirectory.exists()) {
FileUtils.deleteDirectory(solrHomeDirectory);
}
assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs());
// Create the cores that should be fine.
for (String coreName : goodCores) {
File coreRoot = new File(solrHomeDirectory, coreName);

View File

@ -46,10 +46,10 @@ public class TestNRTOpen extends SolrTestCaseJ4 {
// add a doc
assertU(adoc("foo", "bar"));
assertU(commit());
File myDir = dataDir;
File myDir = initCoreDataDir;
deleteCore();
// boot up again over the same index
dataDir = myDir;
initCoreDataDir = myDir;
initCore("solrconfig-basic.xml", "schema-minimal.xml");
// startup
assertNRT(1);

View File

@ -51,10 +51,10 @@ public class TestNonNRTOpen extends SolrTestCaseJ4 {
// add a doc
assertU(adoc("foo", "bar"));
assertU(commit());
File myDir = dataDir;
File myDir = initCoreDataDir;
deleteCore();
// boot up again over the same index
dataDir = myDir;
initCoreDataDir = myDir;
initCore("solrconfig-basic.xml", "schema-minimal.xml");
// startup
assertNotNRT(1);

View File

@ -17,23 +17,6 @@ package org.apache.solr.core;
* limitations under the License.
*/
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.core.SolrXMLSerializer.SolrCoreXMLDef;
import org.apache.solr.core.SolrXMLSerializer.SolrXMLDef;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
@ -46,8 +29,26 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
public class TestSolrXMLSerializer extends LuceneTestCase {
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.SolrXMLSerializer.SolrCoreXMLDef;
import org.apache.solr.core.SolrXMLSerializer.SolrXMLDef;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
public class TestSolrXMLSerializer extends SolrTestCaseJ4 {
private static final XPathFactory xpathFactory = XPathFactory.newInstance();
private static final String defaultCoreNameKey = "defaultCoreName";
private static final String defaultCoreNameVal = "collection1";
@ -81,7 +82,7 @@ public class TestSolrXMLSerializer extends LuceneTestCase {
assertResults(((StringWriter) w).getBuffer().toString().getBytes("UTF-8"));
// again with default file
File tmpFile = TestUtil.createTempFile("solr.xml", null);
File tmpFile = TestUtil.createTempFile("solr.xml", null, createTempDir());
serializer.persistFile(tmpFile, solrXMLDef);

View File

@ -21,10 +21,7 @@ import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
@ -37,12 +34,7 @@ public class TestSolrXml extends SolrTestCaseJ4 {
@Rule
public TestRule solrTestRules = RuleChain.outerRule(new SystemPropertiesRestoreRule());
private File solrHome;
@Before
public void setupTest() {
solrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
}
private final File solrHome = createTempDir();
@Test
public void testAllInfoPresent() throws IOException {

View File

@ -57,7 +57,7 @@ import com.google.common.base.Charsets;
public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
private File solrHomeDirectory;
private File solrHomeDirectory = createTempDir();
@Rule
public TestRule solrTestRules =
@ -69,8 +69,6 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
}
private CoreContainer init(String solrXmlString, String... subDirs) throws Exception {
createTempDir();
solrHomeDirectory = dataDir;
for (String s : subDirs) {
copyMinConf(new File(solrHomeDirectory, s));

View File

@ -22,8 +22,6 @@ import java.io.IOException;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.Test;
@ -64,7 +62,8 @@ public class TestSolrXmlPersistor extends SolrTestCaseJ4 {
final String solrxml = "<solr><cores></cores></solr>";
final File solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
final File solrHomeDirectory = createTempDir();
try {
if (solrHomeDirectory.exists()) {
FileUtils.deleteDirectory(solrHomeDirectory);

View File

@ -17,23 +17,17 @@
package org.apache.solr.handler;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import org.apache.lucene.util.TestUtil;
import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
public class PingRequestHandlerTest extends SolrTestCaseJ4 {
@ -48,14 +42,14 @@ public class PingRequestHandlerTest extends SolrTestCaseJ4 {
@Before
public void before() throws IOException {
File tmpDir = initCoreDataDir;
// by default, use relative file in dataDir
healthcheckFile = new File(dataDir, fileName);
healthcheckFile = new File(tmpDir, fileName);
String fileNameParam = fileName;
// sometimes randomly use an absolute File path instead
if (random().nextBoolean()) {
healthcheckFile = TestUtil.createTempFile(fileName, "");
healthcheckFile = new File(tmpDir, fileName);
fileNameParam = healthcheckFile.getAbsolutePath();
}
@ -85,9 +79,10 @@ public class PingRequestHandlerTest extends SolrTestCaseJ4 {
assertEquals("OK", rsp.getValues().get("status"));
}
public void testEnablingServer() throws Exception {
assertTrue(! healthcheckFile.exists());
assertTrue(!healthcheckFile.exists());
// first make sure that ping responds back that the service is disabled
SolrQueryResponse sqr = makeRequest(handler, req());

View File

@ -1595,7 +1595,9 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
File home = TestUtil.createTempDir(getClass().getName());
File home = new File(dataDir,
getClass().getName() + "-" +
System.currentTimeMillis());
homeDir = new File(home, name);
dataDir = new File(homeDir + "/collection1", "data");

View File

@ -17,9 +17,14 @@
package org.apache.solr.handler.admin;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CoreAdminParams;
@ -30,12 +35,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
public class CoreAdminCreateDiscoverTest extends SolrTestCaseJ4 {
private static File solrHomeDirectory = null;
@ -50,7 +49,7 @@ public class CoreAdminCreateDiscoverTest extends SolrTestCaseJ4 {
public static void beforeClass() throws Exception {
useFactory(null); // I require FS-based indexes for this test.
solrHomeDirectory = TestUtil.createTempDir(CoreAdminCreateDiscoverTest.getClassName());
solrHomeDirectory = createTempDir();
if (solrHomeDirectory.exists()) {
FileUtils.deleteDirectory(solrHomeDirectory);
}

View File

@ -22,8 +22,6 @@ import java.util.Map;
import org.apache.commons.codec.Charsets;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
@ -61,7 +59,7 @@ public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
public void testCreateWithSysVars() throws Exception {
useFactory(null); // I require FS-based indexes for this test.
final File workDir = TestUtil.createTempDir(getCoreName());
final File workDir = createTempDir(getCoreName());
String coreName = "with_sys_vars";
File instDir = new File(workDir, coreName);
@ -132,7 +130,7 @@ public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
@Test
public void testCoreAdminHandler() throws Exception {
final File workDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
final File workDir = new File(initCoreDataDir, this.getClass().getName());
if (workDir.exists()) {
FileUtils.deleteDirectory(workDir);
@ -223,7 +221,9 @@ public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
@Test
public void testDeleteInstanceDir() throws Exception {
File solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File solrHomeDirectory = new File(initCoreDataDir, getClass().getName() + "-corex-"
+ System.currentTimeMillis());
solrHomeDirectory.mkdirs();
copySolrHomeToTemp(solrHomeDirectory, "corex", true);
File corex = new File(solrHomeDirectory, "corex");
FileUtils.write(new File(corex, "core.properties"), "", Charsets.UTF_8.toString());

View File

@ -20,8 +20,6 @@ package org.apache.solr.handler.admin;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.core.CoreContainer;
@ -39,7 +37,8 @@ public class CoreAdminRequestStatusTest extends SolrTestCaseJ4{
@Test
public void testCoreAdminRequestStatus() throws Exception {
final File workDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
final File workDir = createTempDir();
final CoreContainer cores = h.getCoreContainer();
final CoreAdminHandler admin = new CoreAdminHandler(cores);

View File

@ -71,7 +71,7 @@ public class CoreMergeIndexesAdminHandlerTest extends SolrTestCaseJ4 {
@Test
public void testMergeIndexesCoreAdminHandler() throws Exception {
final File workDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
final File workDir = createTempDir();
if (workDir.exists()) {
FileUtils.deleteDirectory(workDir);

View File

@ -49,7 +49,7 @@ public class DistributedDebugComponentTest extends SolrJettyTestBase {
}
private static File createSolrHome() throws Exception {
File workDir = TestUtil.createTempDir(DistributedDebugComponentTest.class.getName());
File workDir = new File(createTempDir(), DistributedDebugComponentTest.class.getName());
setupJettyTestHome(workDir, "collection1");
FileUtils.copyDirectory(new File(workDir, "collection1"), new File(workDir, "collection2"));
return workDir;

View File

@ -23,6 +23,7 @@ import java.util.List;
import junit.framework.Assert;
import org.apache.solr.SolrTestCaseJ4.SuppressTempDirCleanUp;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.SolrServer;
@ -40,6 +41,7 @@ import org.junit.BeforeClass;
* @see org.apache.solr.handler.component.SpellCheckComponent
*/
@Slow
@SuppressTempDirCleanUp(bugUrl = "https://issues.apache.org/jira/browse/SOLR-1877 Spellcheck IndexReader leak bug?")
public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTestCase {
public DistributedSpellCheckComponentTest()

View File

@ -57,10 +57,9 @@ public class QueryElevationComponentTest extends SolrTestCaseJ4 {
private void init(String config, String schema) throws Exception {
//write out elevate-data.xml to the Data dir first by copying it from conf, which we know exists, this way we can test both conf and data configurations
createTempDir();
File parent = new File(TEST_HOME() + "/collection1", "conf");
File elevateFile = new File(parent, "elevate.xml");
File elevateDataFile = new File(dataDir, "elevate-data.xml");
File elevateDataFile = new File(initCoreDataDir, "elevate-data.xml");
FileUtils.copyFile(elevateFile, elevateDataFile);

View File

@ -22,8 +22,6 @@ import java.util.TreeMap;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.util.RestTestBase;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.After;
@ -42,8 +40,7 @@ public class TestManagedSchemaFieldResource extends RestTestBase {
@Before
public void before() throws Exception {
createTempDir();
tmpSolrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
tmpSolrHome = createTempDir();
tmpConfDir = new File(tmpSolrHome, confDir);
FileUtils.copyDirectory(new File(TEST_HOME()), tmpSolrHome.getAbsoluteFile());

View File

@ -46,8 +46,8 @@ public class TestManagedStopFilterFactory extends RestTestBase {
@Before
public void before() throws Exception {
createTempDir();
tmpSolrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
tmpSolrHome = new File(createTempDir() + File.separator + TestManagedStopFilterFactory.class.getSimpleName()
+ System.currentTimeMillis());
tmpConfDir = new File(tmpSolrHome, confDir);
FileUtils.copyDirectory(new File(TEST_HOME()), tmpSolrHome.getAbsoluteFile());

View File

@ -22,8 +22,6 @@ import java.io.IOException;
import org.apache.commons.codec.Charsets;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.CoreContainer;
@ -42,7 +40,7 @@ public class ChangedSchemaMergeTest extends SolrTestCaseJ4 {
initCore();
}
private File solrHomeDirectory;
private final File solrHomeDirectory = createTempDir();
private File schemaFile = null;
private void addDoc(SolrCore core, String... fieldValues) throws IOException {
@ -53,7 +51,6 @@ public class ChangedSchemaMergeTest extends SolrTestCaseJ4 {
}
private CoreContainer init() throws Exception {
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File changed = new File(solrHomeDirectory, "changed");
copyMinConf(changed, "name=changed");
// Overlay with my local schema

View File

@ -45,7 +45,7 @@ import org.junit.rules.TestRule;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
public class ModifyConfFileTest extends SolrTestCaseJ4 {
private File solrHomeDirectory;
private File solrHomeDirectory = createTempDir();
@Rule
public TestRule solrTestRules = RuleChain.outerRule(new SystemPropertiesRestoreRule());

View File

@ -22,7 +22,6 @@ import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrQuery;
@ -36,7 +35,8 @@ public class TestBinaryField extends SolrJettyTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
File homeDir = TestUtil.createTempDir("solrtest-TestBinaryField");
File homeDir = createTempDir();
File collDir = new File(homeDir, "collection1");
File dataDir = new File(collDir, "data");
File confDir = new File(collDir, "conf");

View File

@ -48,8 +48,7 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
@Before
private void initManagedSchemaCore() throws Exception {
createTempDir();
final String tmpSolrHomePath = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
final String tmpSolrHomePath = createTempDir().getAbsolutePath();
tmpSolrHome = new File(tmpSolrHomePath).getAbsoluteFile();
tmpConfDir = new File(tmpSolrHome, confDir);
File testHomeConfDir = new File(TEST_HOME(), confDir);

View File

@ -21,8 +21,6 @@ import java.io.File;
import java.util.Collections;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
import org.junit.Before;
@ -37,8 +35,7 @@ public class TestAddFieldRealTimeGet extends TestRTGBase {
@Before
private void initManagedSchemaCore() throws Exception {
createTempDir();
final String tmpSolrHomePath = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
final String tmpSolrHomePath = createTempDir().getAbsolutePath();
tmpSolrHome = new File(tmpSolrHomePath).getAbsoluteFile();
tmpConfDir = new File(tmpSolrHome, confDir);
File testHomeConfDir = new File(TEST_HOME(), confDir);

View File

@ -40,8 +40,6 @@ import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.hdfs.HdfsBasicDistributedZk2Test;
import org.apache.solr.cloud.hdfs.HdfsTestUtil;
@ -78,7 +76,9 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(new File(createTempDir(),
HdfsBasicDistributedZk2Test.class.getName() + "_"
+ System.currentTimeMillis()).getAbsolutePath());
hdfsUri = dfsCluster.getFileSystem().getUri().toString();
try {

View File

@ -16,23 +16,17 @@
*/
package org.apache.solr.search;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.ManagedIndexSchema;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Collections;
import org.junit.BeforeClass;
import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.ManagedIndexSchema;
import org.apache.solr.schema.SchemaField;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* Requests to open a new searcher w/o any underlying change to the index exposed
@ -55,8 +49,7 @@ public class TestSearcherReuse extends SolrTestCaseJ4 {
*/
@BeforeClass
private static void setupTempDirAndCoreWithManagedSchema() throws Exception {
createTempDir();
solrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
solrHome = createTempDir();
solrHome = solrHome.getAbsoluteFile();
File confDir = new File(solrHome, confPath);

View File

@ -16,6 +16,8 @@
*/
package org.apache.solr.servlet;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
@ -43,7 +45,7 @@ public class CacheHeaderTest extends CacheHeaderTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
solrHomeDirectory = TestUtil.createTempDir("CacheHeaderTest");
solrHomeDirectory = new File(createTempDir(), "CacheHeaderTest");
setupJettyTestHome(solrHomeDirectory, "collection1");
createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
}
@ -254,7 +256,7 @@ public class CacheHeaderTest extends CacheHeaderTestBase {
protected File makeFile(String contents, String charset) {
try {
File f = TestUtil.createTempFile("cachetest_csv", null);
File f = TestUtil.createTempFile("cachetest_csv", null, initCoreDataDir);
Writer out = new OutputStreamWriter(new FileOutputStream(f), charset);
out.write(contents);
out.close();

View File

@ -23,15 +23,12 @@ import java.util.Map;
import org.apache.lucene.analysis.Token;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.SolrTestCaseJ4.SuppressTempDirCleanUp;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SpellingParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.component.SpellCheckComponent;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.util.RefCounted;
import org.apache.solr.util.TestHarness;
import org.junit.BeforeClass;
import org.junit.Test;

View File

@ -25,6 +25,7 @@ import org.apache.lucene.analysis.Token;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.SolrTestCaseJ4.SuppressTempDirCleanUp;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.search.SolrIndexSearcher;
@ -37,6 +38,7 @@ import org.junit.Test;
*
* @since solr 1.3
**/
@SuppressTempDirCleanUp(bugUrl = "https://issues.apache.org/jira/browse/SOLR-1877 Spellcheck IndexReader leak bug?")
public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
private static SpellingQueryConverter queryConverter;
@ -104,7 +106,8 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
spellchecker.add(AbstractLuceneSpellChecker.LOCATION, "spellings.txt");
spellchecker.add(AbstractLuceneSpellChecker.FIELD, "teststop");
spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8");
File indexDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File indexDir = new File(createTempDir(), "spellingIdx");
indexDir.mkdirs();
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
spellchecker.add(SolrSpellChecker.FIELD_TYPE, "teststop");
spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);

View File

@ -37,9 +37,8 @@ import org.apache.lucene.search.spell.SuggestMode;
import org.apache.lucene.search.spell.SuggestWord;
import org.apache.lucene.search.spell.SuggestWordFrequencyComparator;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.SolrTestCaseJ4.SuppressTempDirCleanUp;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.component.SpellCheckComponent;
@ -52,6 +51,7 @@ import org.junit.Test;
/**
* @since solr 1.3
*/
@SuppressTempDirCleanUp(bugUrl = "https://issues.apache.org/jira/browse/SOLR-1877 Spellcheck IndexReader leak bug?")
public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
protected static SpellingQueryConverter queryConverter;
@ -110,7 +110,8 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
NamedList spellchecker = new NamedList();
spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
File indexDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File indexDir = createTempDir();
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
spellchecker.add(AbstractLuceneSpellChecker.FIELD, "title");
spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);
@ -185,7 +186,8 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
NamedList spellchecker = new NamedList();
spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
File indexDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File indexDir = new File(createTempDir(), "spellingIdx");
indexDir.mkdirs();
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
spellchecker.add(AbstractLuceneSpellChecker.FIELD, "title");
spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);
@ -241,7 +243,8 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
NamedList spellchecker = new NamedList();
spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
File indexDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File indexDir = createTempDir();
indexDir.mkdirs();
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
spellchecker.add(AbstractLuceneSpellChecker.FIELD, "title");
spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);
@ -280,10 +283,10 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
NamedList spellchecker = new NamedList();
spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
File base = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File indexDir = new File(base, "spellingIdx");
File tmpDir = createTempDir();
File indexDir = new File(tmpDir, "spellingIdx");
//create a standalone index
File altIndexDir = new File(base, "alternateIdx");
File altIndexDir = new File(tmpDir, "alternateIdx" + new Date().getTime());
Directory dir = newFSDirectory(altIndexDir);
IndexWriter iw = new IndexWriter(
dir,

View File

@ -82,10 +82,10 @@ public class SuggesterTest extends SolrTestCaseJ4 {
System.setProperty("solr.test.leavedatadir", "true");
addDocs();
assertU(commit());
File data = dataDir;
File data = initCoreDataDir;
String config = configString;
deleteCore();
dataDir = data;
initCoreDataDir = data;
configString = config;
initCore();
assertQ(req("qt", requestUri, "q", "ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"),

View File

@ -30,14 +30,16 @@ import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.MergeInfo;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.store.hdfs.HdfsDirectory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
public class BlockDirectoryTest extends LuceneTestCase {
public class BlockDirectoryTest extends SolrTestCaseJ4 {
private class MapperCache implements Cache {
public Map<String, byte[]> map = new ConcurrentLinkedHashMap.Builder<String, byte[]>().maximumWeightedCapacity(8).build();
@ -103,7 +105,7 @@ public class BlockDirectoryTest extends LuceneTestCase {
@Before
public void setUp() throws Exception {
super.setUp();
file = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
file = createTempDir();
FSDirectory dir = FSDirectory.open(new File(file, "base"));
mapperCache = new MapperCache();
directory = new BlockDirectory("test", dir, mapperCache, null, true, true);

View File

@ -17,7 +17,6 @@ package org.apache.solr.store.hdfs;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Random;
@ -31,8 +30,6 @@ import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.hdfs.HdfsTestUtil;
import org.junit.After;
@ -60,8 +57,7 @@ public class HdfsDirectoryTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
createTempDir();
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
}
@AfterClass
@ -77,7 +73,7 @@ public class HdfsDirectoryTest extends SolrTestCaseJ4 {
Configuration conf = new Configuration();
conf.set("dfs.permissions.enabled", "false");
directory = new HdfsDirectory(new Path(dfsCluster.getURI().toString() + dataDir.getAbsolutePath() + "/hdfs"), conf);
directory = new HdfsDirectory(new Path(dfsCluster.getURI().toString() + createTempDir().getAbsolutePath() + "/hdfs"), conf);
random = random();
}

View File

@ -17,6 +17,7 @@ package org.apache.solr.store.hdfs;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import java.net.URI;
@ -24,7 +25,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.store.Lock;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.hdfs.HdfsTestUtil;
import org.junit.After;
@ -43,8 +43,7 @@ public class HdfsLockFactoryTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
createTempDir();
dfsCluster = HdfsTestUtil.setupClass();
dfsCluster = HdfsTestUtil.setupClass(createTempDir().getAbsolutePath());
}
@AfterClass

View File

@ -25,8 +25,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
@ -59,10 +57,13 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
super.setUp();
clearIndex();
assertU(commit());
File tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
indexDir1 = new File(tempDir, this.getClass().getName() + "_testSplit1");
indexDir2 = new File(tempDir, this.getClass().getName() + "_testSplit2");
indexDir3 = new File(tempDir, this.getClass().getName() + "_testSplit3");
File dataDir = createTempDir();
indexDir1 = new File(dataDir, this.getClass().getName()
+ "_testSplit1");
indexDir2 = new File(dataDir, this.getClass().getName()
+ "_testSplit2");
indexDir3 = new File(dataDir, this.getClass().getName()
+ "_testSplit3");
if (indexDir1.exists()) {
FileUtils.deleteDirectory(indexDir1);
@ -270,7 +271,11 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
@Test
public void testSplitByRouteKey() throws Exception {
File indexDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File indexDir = createTempDir();
if (indexDir.exists()) {
FileUtils.deleteDirectory(indexDir);
}
indexDir.mkdirs();
CompositeIdRouter r1 = new CompositeIdRouter();
String splitKey = "sea-line!";

View File

@ -49,8 +49,7 @@ public class AddSchemaFieldsUpdateProcessorFactoryTest extends UpdateProcessorTe
@Before
private void initManagedSchemaCore() throws Exception {
createTempDir();
final String tmpSolrHomePath = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
final String tmpSolrHomePath = createTempDir().getAbsolutePath();
tmpSolrHome = new File(tmpSolrHomePath).getAbsoluteFile();
tmpConfDir = new File(tmpSolrHome, confDir);
File testHomeConfDir = new File(TEST_HOME(), confDir);

View File

@ -21,9 +21,6 @@ import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
@ -46,6 +43,7 @@ public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
protected CoreContainer cores;
private String saveProp;
private File dataDir1;
private File dataDir2;
@Override
@ -55,9 +53,7 @@ public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
@BeforeClass
public static void beforeClass2() throws Exception {
if (dataDir == null) {
createTempDir();
}
}
protected void setupCoreContainer() {
@ -71,12 +67,11 @@ public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
saveProp = System.getProperty("solr.directoryFactory");
System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
super.setUp();
File dataDir1 = createTempDir();
// setup datadirs
System.setProperty( "solr.core0.data.dir", SolrTestCaseJ4.dataDir.getCanonicalPath() );
System.setProperty( "solr.core0.data.dir", dataDir1.getCanonicalPath() );
dataDir2 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
dataDir2.mkdirs();
dataDir2 = createTempDir();
System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );

View File

@ -57,9 +57,8 @@ public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
@Override public void setUp() throws Exception {
super.setUp();
dataDir1 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + "-core0");
dataDir2 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + "-core1");
dataDir1 = createTempDir();
dataDir2 = createTempDir();
System.setProperty( "solr.core0.data.dir", this.dataDir1.getCanonicalPath() );
System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );

View File

@ -36,9 +36,7 @@ abstract public class SolrExampleTestBase extends AbstractSolrTestCase
@BeforeClass
public static void beforeClass() throws Exception {
if (dataDir == null) {
createTempDir();
}
}
@Override
@ -49,7 +47,7 @@ abstract public class SolrExampleTestBase extends AbstractSolrTestCase
// this sets the property for jetty starting SolrDispatchFilter
System.setProperty( "solr.solr.home", this.getSolrHome() );
System.setProperty( "solr.data.dir", this.dataDir.getCanonicalPath() );
System.setProperty( "solr.data.dir", this.initCoreDataDir.getCanonicalPath() );
}
/**

View File

@ -285,7 +285,8 @@ public class TestLBHttpSolrServer extends SolrTestCaseJ4 {
public void setUp() throws Exception {
File home = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
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");

View File

@ -17,20 +17,17 @@ package org.apache.solr.client.solrj.embedded;
* limitations under the License.
*/
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import java.io.File;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.After;
import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public abstract class AbstractEmbeddedSolrServerTestCase extends LuceneTestCase {
public abstract class AbstractEmbeddedSolrServerTestCase extends SolrTestCaseJ4 {
protected static Logger log = LoggerFactory.getLogger(AbstractEmbeddedSolrServerTestCase.class);
@ -49,7 +46,7 @@ public abstract class AbstractEmbeddedSolrServerTestCase extends LuceneTestCase
System.out.println("Solr home: " + SOLR_HOME.getAbsolutePath());
//The index is always stored within a temporary directory
tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
tempDir = createTempDir();
File dataDir = new File(tempDir,"data1");
File dataDir2 = new File(tempDir,"data2");

View File

@ -59,7 +59,9 @@ public class JettyWebappTest extends SolrTestCaseJ4
System.setProperty("solr.solr.home", ExternalPaths.EXAMPLE_HOME);
System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
File dataDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File dataDir = createTempDir();
dataDir.mkdirs();
System.setProperty("solr.data.dir", dataDir.getCanonicalPath());
String path = ExternalPaths.WEBAPP_HOME;

View File

@ -99,7 +99,7 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
SolrServer server = getSolrAdmin();
File tmp = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File tmp = createTempDir();
log.info("Creating cores underneath {}", tmp);

View File

@ -23,16 +23,17 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import org.apache.commons.io.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.core.SolrResourceLoader;
/**
*/
public class ContentStreamTest extends LuceneTestCase
public class ContentStreamTest extends SolrTestCaseJ4
{
public void testStringStream() throws IOException
{
@ -47,15 +48,26 @@ public class ContentStreamTest extends LuceneTestCase
{
InputStream is = new SolrResourceLoader(null, null).openResource( "solrj/README" );
assertNotNull( is );
File file = TestUtil.createTempFile("README", "");
File file = TestUtil.createTempFile("README", "", createTempDir());
FileOutputStream os = new FileOutputStream(file);
IOUtils.copy(is, os);
os.close();
is.close();
ContentStreamBase stream = new ContentStreamBase.FileStream( file );
assertEquals( file.length(), stream.getSize().intValue() );
assertTrue( IOUtils.contentEquals( new FileInputStream( file ), stream.getStream() ) );
assertTrue( IOUtils.contentEquals( new InputStreamReader(new FileInputStream(file), "UTF-8"), stream.getReader() ) );
ContentStreamBase stream = new ContentStreamBase.FileStream(file);
InputStream s = stream.getStream();
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(
new FileInputStream(file), "UTF-8");
try {
assertEquals(file.length(), stream.getSize().intValue());
assertTrue(IOUtils.contentEquals(fis, s));
assertTrue(IOUtils.contentEquals(isr, stream.getReader()));
} finally {
s.close();
isr.close();
fis.close();
}
}
@ -63,15 +75,30 @@ public class ContentStreamTest extends LuceneTestCase
{
InputStream is = new SolrResourceLoader(null, null).openResource( "solrj/README" );
assertNotNull( is );
File file = TestUtil.createTempFile("README", "");
File file = new File(createTempDir(), "README");
FileOutputStream os = new FileOutputStream(file);
IOUtils.copy(is, os);
os.close();
is.close();
ContentStreamBase stream = new ContentStreamBase.URLStream( new URL(file.toURI().toASCIIString()) );
assertTrue( IOUtils.contentEquals( new FileInputStream( file ), stream.getStream() ) );
assertEquals( file.length(), stream.getSize().intValue() );
assertTrue( IOUtils.contentEquals( new InputStreamReader(new FileInputStream(file), "UTF-8"), stream.getReader() ) );
assertEquals( file.length(), stream.getSize().intValue() );
ContentStreamBase stream = new ContentStreamBase.URLStream(new URL(file
.toURI().toASCIIString()));
InputStream s = stream.getStream();
FileInputStream fis = new FileInputStream(file);
FileInputStream fis2 = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
Reader r = stream.getReader();
try {
assertTrue(IOUtils.contentEquals(fis2, s));
assertEquals(file.length(), stream.getSize().intValue());
assertTrue(IOUtils.contentEquals(isr, r));
assertEquals(file.length(), stream.getSize().intValue());
} finally {
r.close();
s.close();
isr.close();
fis.close();
fis2.close();
}
}
}

View File

@ -278,8 +278,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
super.setUp();
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
testDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
testDir.mkdirs();
testDir = createTempDir();
}
@Override

View File

@ -56,7 +56,7 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4
ignoreException("maxWarmingSearchers");
// this sets the property for jetty starting SolrDispatchFilter
System.setProperty( "solr.data.dir", dataDir.getCanonicalPath() );
System.setProperty( "solr.data.dir", createTempDir().getCanonicalPath() );
context = context==null ? "/solr" : context;
SolrJettyTestBase.context = context;

Some files were not shown because too many files have changed in this diff Show More