You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/10/24 18:32:30 UTC
[26/50] [abbrv] lucene-solr:jira/solr-8542-v2: SOLR-9570: Fix test
failures and start using SolrTestCaseJ4's createTempDir mm
SOLR-9570: Fix test failures and start using SolrTestCaseJ4's createTempDir mm
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/af88e7f5
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/af88e7f5
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/af88e7f5
Branch: refs/heads/jira/solr-8542-v2
Commit: af88e7f54d2042a2ff5c3bef7b6016084ad15cec
Parents: a4952b1
Author: Jan H�ydahl <ja...@apache.org>
Authored: Thu Oct 20 20:58:52 2016 +0200
Committer: Jan H�ydahl <ja...@apache.org>
Committed: Thu Oct 20 20:58:52 2016 +0200
----------------------------------------------------------------------
.../src/java/org/apache/solr/util/SolrCLI.java | 6 +++---
.../org/apache/solr/util/UtilsToolTest.java | 22 ++++++++++----------
2 files changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/af88e7f5/solr/core/src/java/org/apache/solr/util/SolrCLI.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
index 39bf548..c5a359e 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
@@ -3362,7 +3362,7 @@ public class SolrCLI {
public UtilsTool(PrintStream stdout) { super(stdout); }
public String getName() {
- return "prestart";
+ return "utils";
}
@SuppressWarnings("static-access")
@@ -3482,7 +3482,7 @@ public class SolrCLI {
-> a.isRegularFile() && String.valueOf(f.getFileName()).endsWith("-console.log"))
.collect(Collectors.toList());
if (files.size() > 0) {
- out("Archiving " + files.size() + " console log files");
+ out("Archiving " + files.size() + " console log files to " + archivePath);
for (Path p : files) {
Files.move(p, archivePath.resolve(p.getFileName()), StandardCopyOption.REPLACE_EXISTING);
}
@@ -3570,7 +3570,7 @@ public class SolrCLI {
throw new Exception("Command requires the -l <log-directory> option");
}
if (!logsPath.isAbsolute()) {
- if (serverPath != null && serverPath.isAbsolute() && serverPath.toFile().exists()) {
+ if (serverPath != null && serverPath.isAbsolute() && Files.exists(serverPath)) {
logsPath = serverPath.resolve(logsPath);
} else {
throw new Exception("Logs directory must be an absolute path, or -s must be supplied");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/af88e7f5/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java b/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java
index fa39620..6b2d31c 100644
--- a/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java
+++ b/solr/core/src/test/org/apache/solr/util/UtilsToolTest.java
@@ -28,20 +28,18 @@ import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.cli.CommandLine;
+import org.apache.solr.SolrTestCaseJ4;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.apache.solr.util.SolrCLI.findTool;
import static org.apache.solr.util.SolrCLI.parseCmdLine;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
/**
* Unit test for SolrCLI's UtilsTool
*/
-public class UtilsToolTest {
+public class UtilsToolTest extends SolrTestCaseJ4 {
private Path dir;
private SolrCLI.UtilsTool tool;
@@ -60,19 +58,21 @@ public class UtilsToolTest {
"solr_gc_log_2");
@Before
- public void setUp() throws IOException {
- dir = Files.createTempDirectory("Utils Tool Test");
- files.stream().forEach(f -> {
+ public void setUp() throws Exception {
+ super.setUp();
+ dir = createTempDir("Utils Tool Test").toAbsolutePath();
+ files.forEach(f -> {
try {
- dir.resolve(f).toFile().createNewFile();
+ Files.createFile(dir.resolve(f));
} catch (IOException e) {
- assertTrue(false);
+ fail("Error when creating temporary file " + dir.resolve(f));
}
});
}
@After
- public void tearDown() throws IOException {
+ public void tearDown() throws Exception {
+ super.tearDown();
org.apache.commons.io.FileUtils.deleteDirectory(dir.toFile());
}
@@ -128,7 +128,7 @@ public class UtilsToolTest {
} catch (Exception e) {
return;
}
- assertTrue(false);
+ fail("Should have thrown exception if using relative path without -s");
}
@Test