SOLR-8610: Fix temporary dir usage in DIH

This commit is contained in:
Uwe Schindler 2016-06-07 10:51:41 +02:00
parent a9dea9a983
commit 3c9e36b1e1
3 changed files with 14 additions and 13 deletions

View File

@ -253,7 +253,7 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTestCase {
@Test @Test
@Ignore("Fix Me. See SOLR-4103.") @Ignore("Fix Me. See SOLR-4103.")
public void testFileListEntityProcessor_lastIndexTime() throws Exception { public void testFileListEntityProcessor_lastIndexTime() throws Exception {
File tmpdir = File.createTempFile("test", "tmp", createTempDir().toFile()); File tmpdir = createTempDir().toFile();
Map<String, String> params = createMap("baseDir", tmpdir.getAbsolutePath()); Map<String, String> params = createMap("baseDir", tmpdir.getAbsolutePath());

View File

@ -15,18 +15,23 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.solr.handler.dataimport; package org.apache.solr.handler.dataimport;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.common.util.SuppressForbidden;
import org.junit.Ignore;
import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.solr.common.util.SuppressForbidden;
import org.junit.Test;
/** /**
* <p> * <p>
@ -65,9 +70,7 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test @Test
public void testBiggerSmallerFiles() throws IOException { public void testBiggerSmallerFiles() throws IOException {
File tmpdir = File.createTempFile("test", "tmp", createTempDir().toFile()); File tmpdir = createTempDir().toFile();
Files.delete(tmpdir.toPath());
tmpdir.mkdir();
long minLength = Long.MAX_VALUE; long minLength = Long.MAX_VALUE;
String smallestFile = ""; String smallestFile = "";

View File

@ -465,9 +465,7 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
} }
private String createEncryptionKeyFile() throws IOException { private String createEncryptionKeyFile() throws IOException {
File tmpdir = File.createTempFile("test", "tmp", createTempDir().toFile()); File tmpdir = createTempDir().toFile();
Files.delete(tmpdir.toPath());
tmpdir.mkdir();
byte[] content = "secret".getBytes(StandardCharsets.UTF_8); byte[] content = "secret".getBytes(StandardCharsets.UTF_8);
createFile(tmpdir, "enckeyfile.txt", content, false); createFile(tmpdir, "enckeyfile.txt", content, false);
return new File(tmpdir, "enckeyfile.txt").getAbsolutePath(); return new File(tmpdir, "enckeyfile.txt").getAbsolutePath();