This project has retired. For details please refer to its Attic page.
TemporaryPath (Apache Crunch 0.8.0 API)

org.apache.crunch.test
Class TemporaryPath

java.lang.Object
  extended by org.junit.rules.ExternalResource
      extended by org.apache.crunch.test.TemporaryPath
All Implemented Interfaces:
org.junit.rules.TestRule

public final class TemporaryPath
extends org.junit.rules.ExternalResource

Creates a temporary directory for a test case and destroys it afterwards. This provides a temporary directory like JUnit's 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 Summary
TemporaryPath(String... confKeys)
          Construct TemporaryPath.
 
Method Summary
 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.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemporaryPath

public TemporaryPath(String... confKeys)
Construct TemporaryPath.

Parameters:
confKeys - Configuration keys containing directories to override
Method Detail

apply

public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
                                               org.junit.runner.Description description)
Specified by:
apply in interface org.junit.rules.TestRule
Overrides:
apply in class org.junit.rules.ExternalResource

getRootFile

public File getRootFile()
Get the root directory which will be deleted automatically.


getRootPath

public org.apache.hadoop.fs.Path getRootPath()
Get the root directory as a Path.


getRootFileName

public String getRootFileName()
Get the root directory as an absolute file name.


getFile

public File getFile(String fileName)
Get a File below the temporary directory.


getPath

public org.apache.hadoop.fs.Path getPath(String fileName)
Get a Path below the temporary directory.


getFileName

public String getFileName(String fileName)
Get an absolute file name below the temporary directory.


copyResourceFile

public File copyResourceFile(String resourceName)
                      throws IOException
Copy a classpath resource to File.

Throws:
IOException

copyResourcePath

public org.apache.hadoop.fs.Path copyResourcePath(String resourceName)
                                           throws IOException
Copy a classpath resource to a Path.

Throws:
IOException

copyResourceFileName

public String copyResourceFileName(String resourceName)
                            throws IOException
Copy a classpath resource returning its absolute file name.

Throws:
IOException

getDefaultConfiguration

public org.apache.hadoop.conf.Configuration getDefaultConfiguration()

overridePathProperties

public org.apache.hadoop.conf.Configuration overridePathProperties(org.apache.hadoop.conf.Configuration config)
Set all keys specified in the constructor to temporary directories.



Copyright © 2013 The Apache Software Foundation. All Rights Reserved.