public final class TemporaryPath
extends org.junit.rules.ExternalResource
TemporaryFolder
but
geared towards Hadoop applications. Unlike TemporaryFolder
, it
doesn't create any files or directories except for the root directory itself.
Also, getDefaultConfiguration()
provides you with a configuration that
overrides path properties with temporary directories. You have to specify these
properties via the constructor.Constructor and Description |
---|
TemporaryPath(String... confKeys)
Construct
TemporaryPath . |
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
File |
copyResourceFile(String resourceName)
Copy a classpath resource to
File . |
String |
copyResourceFileName(String resourceName)
Copy a classpath resource returning its absolute file name.
|
org.apache.hadoop.fs.Path |
copyResourcePath(String resourceName)
Copy a classpath resource to a
Path . |
void |
create() |
void |
delete() |
org.apache.hadoop.conf.Configuration |
getDefaultConfiguration() |
File |
getFile(String fileName)
Get a
File below the temporary directory. |
String |
getFileName(String fileName)
Get an absolute file name below the temporary directory.
|
org.apache.hadoop.fs.Path |
getPath(String fileName)
Get a
Path below the temporary directory. |
File |
getRootFile()
Get the root directory which will be deleted automatically.
|
String |
getRootFileName()
Get the root directory as an absolute file name.
|
org.apache.hadoop.fs.Path |
getRootPath()
Get the root directory as a
Path . |
org.apache.hadoop.conf.Configuration |
overridePathProperties(org.apache.hadoop.conf.Configuration config)
Set all keys specified in the constructor to temporary directories.
|
public TemporaryPath(String... confKeys)
TemporaryPath
.confKeys
- Configuration
keys containing directories to overridepublic void delete()
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
apply
in interface org.junit.rules.TestRule
apply
in class org.junit.rules.ExternalResource
public File getRootFile()
public org.apache.hadoop.fs.Path getRootPath()
Path
.public String getRootFileName()
public org.apache.hadoop.fs.Path getPath(String fileName)
Path
below the temporary directory.public String getFileName(String fileName)
public File copyResourceFile(String resourceName) throws IOException
File
.IOException
public org.apache.hadoop.fs.Path copyResourcePath(String resourceName) throws IOException
Path
.IOException
public String copyResourceFileName(String resourceName) throws IOException
IOException
public org.apache.hadoop.conf.Configuration getDefaultConfiguration()
public org.apache.hadoop.conf.Configuration overridePathProperties(org.apache.hadoop.conf.Configuration config)
Copyright © 2016 The Apache Software Foundation. All rights reserved.