org.eclipse.jetty.server.session.test
Class MavenTestingUtils

java.lang.Object
  extended by org.eclipse.jetty.server.session.test.MavenTestingUtils

public class MavenTestingUtils
extends Object

Common utility methods for working with JUnit tests cases in a maven friendly way.


Constructor Summary
MavenTestingUtils()
           
 
Method Summary
static File getBasedir()
           
static File getTargetDir()
          Get the directory to the /target directory for this project.
static File getTargetFile(String path)
          Create a File object for a path in the /target directory.
static File getTargetTestingDir()
           
static File getTargetTestingDir(String testname)
          Get a dir in /target/ that uses the an arbitrary name.
static File getTargetTestingDir(junit.framework.TestCase test)
          Get a dir in /target/ that uses the JUnit 3.x TestCase.getName() to make itself unique.
static String getTestID()
           
static File getTestResourceDir(String name)
          Get a dir from the src/test/resource directory.
static File getTestResourceFile(String name)
          Get a file from the src/test/resource directory.
static File getTestResourcePath(String name)
          Get a path resource (File or Dir) from the src/test/resource directory.
static File getTestResourcesDir()
          Get the directory to the src/test/resource directory
static String readToString(File file)
          Read the contents of a file into a String and return it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MavenTestingUtils

public MavenTestingUtils()
Method Detail

getBasedir

public static File getBasedir()

getTargetDir

public static File getTargetDir()
Get the directory to the /target directory for this project.

Returns:
the directory path to the target directory.

getTargetFile

public static File getTargetFile(String path)
Create a File object for a path in the /target directory.

Parameters:
path - the path desired, no validation of existence is performed.
Returns:
the File to the path.

getTargetTestingDir

public static File getTargetTestingDir()

getTargetTestingDir

public static File getTargetTestingDir(junit.framework.TestCase test)
Get a dir in /target/ that uses the JUnit 3.x TestCase.getName() to make itself unique.

Parameters:
test - the junit 3.x testcase to base this new directory on.
Returns:
the File path to the testcase specific testing directory underneath the ${basedir}/target sub directory

getTargetTestingDir

public static File getTargetTestingDir(String testname)
Get a dir in /target/ that uses the an arbitrary name.

Parameters:
testname - the testname to create directory against.
Returns:
the File path to the testname sepecific testing directory underneath the ${basedir}/target sub directory

getTestResourceDir

public static File getTestResourceDir(String name)
Get a dir from the src/test/resource directory.

Parameters:
name - the name of the path to get (it must exist as a dir)
Returns:
the dir in src/test/resource

getTestResourceFile

public static File getTestResourceFile(String name)
Get a file from the src/test/resource directory.

Parameters:
name - the name of the path to get (it must exist as a file)
Returns:
the file in src/test/resource

getTestResourcePath

public static File getTestResourcePath(String name)
Get a path resource (File or Dir) from the src/test/resource directory.

Parameters:
name - the name of the path to get (it must exist)
Returns:
the path in src/test/resource

getTestResourcesDir

public static File getTestResourcesDir()
Get the directory to the src/test/resource directory

Returns:
the directory File to the src/test/resources directory

readToString

public static String readToString(File file)
                           throws IOException
Read the contents of a file into a String and return it.

Parameters:
file - the file to read.
Returns:
the contents of the file.
Throws:
IOException - if unable to read the file.

getTestID

public static String getTestID()


Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.