[
https://issues.apache.org/jira/browse/ZOOKEEPER-1825?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
chendihao updated ZOOKEEPER-1825:
---------------------------------
Description:
{code}
static final File BASETEST = new File(System.getProperty("build.test.dir",
"build"));
{code}
{code}
public static File createTmpDir() throws IOException {
return createTmpDir(BASETEST);
}
static File createTmpDir(File parentDir) throws IOException {
File tmpFile = File.createTempFile("test", ".junit", parentDir);
// don't delete tmpFile - this ensures we don't attempt to create
// a tmpDir with a duplicate name
File tmpDir = new File(tmpFile + ".dir");
Assert.assertFalse(tmpDir.exists()); // never true if tmpfile does it's
job
Assert.assertTrue(tmpDir.mkdirs());
return tmpDir;
}
{code}
Because the default directory "build" may not exist, createTmpDir() will throws
IOException and show "No such file or directory". I think replace "build" as
"." is more reasonable.
was:
{code}
static final File BASETEST = new File(System.getProperty("build.test.dir",
"build"));
public static File createTmpDir() throws IOException {
return createTmpDir(BASETEST);
}
static File createTmpDir(File parentDir) throws IOException {
File tmpFile = File.createTempFile("test", ".junit", parentDir);
// don't delete tmpFile - this ensures we don't attempt to create
// a tmpDir with a duplicate name
File tmpDir = new File(tmpFile + ".dir");
Assert.assertFalse(tmpDir.exists()); // never true if tmpfile does it's
job
Assert.assertTrue(tmpDir.mkdirs());
return tmpDir;
}
{code}
Because the default directory "build" may not exist, createTmpDir() will throws
IOException and show "No such file or directory". I think replace "build" as
"." is reasonable as well.
> In ClientBase, if not set "build.test.dir" will throw IOException
> -----------------------------------------------------------------
>
> Key: ZOOKEEPER-1825
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1825
> Project: ZooKeeper
> Issue Type: Test
> Components: tests
> Reporter: chendihao
>
> {code}
> static final File BASETEST = new
> File(System.getProperty("build.test.dir", "build"));
> {code}
> {code}
> public static File createTmpDir() throws IOException {
> return createTmpDir(BASETEST);
> }
> static File createTmpDir(File parentDir) throws IOException {
> File tmpFile = File.createTempFile("test", ".junit", parentDir);
> // don't delete tmpFile - this ensures we don't attempt to create
> // a tmpDir with a duplicate name
> File tmpDir = new File(tmpFile + ".dir");
> Assert.assertFalse(tmpDir.exists()); // never true if tmpfile does
> it's job
> Assert.assertTrue(tmpDir.mkdirs());
> return tmpDir;
> }
> {code}
> Because the default directory "build" may not exist, createTmpDir() will
> throws IOException and show "No such file or directory". I think replace
> "build" as "." is more reasonable.
--
This message was sent by Atlassian JIRA
(v6.1#6144)