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

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

public class MavenTestingUtils
extends java.lang.Object

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


Constructor Summary
MavenTestingUtils()
           
 
Method Summary
static java.io.File getBasedir()
           
static java.io.File getTargetDir()
          Get the directory to the /target directory for this project.
static java.io.File getTargetFile(java.lang.String path)
          Create a File object for a path in the /target directory.
static java.io.File getTargetTestingDir()
           
static java.io.File getTargetTestingDir(java.lang.String testname)
          Get a dir in /target/ that uses the an arbitrary name.
static java.io.File getTargetTestingDir(junit.framework.TestCase test)
          Get a dir in /target/ that uses the JUnit 3.x TestCase.getName() to make itself unique.
static java.lang.String getTestID()
           
static java.io.File getTestResourceDir(java.lang.String name)
          Get a dir from the src/test/resource directory.
static java.io.File getTestResourceFile(java.lang.String name)
          Get a file from the src/test/resource directory.
static java.io.File getTestResourcePath(java.lang.String name)
          Get a path resource (File or Dir) from the src/test/resource directory.
static java.io.File getTestResourcesDir()
          Get the directory to the src/test/resource directory
static java.lang.String readToString(java.io.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 java.io.File getBasedir()

getTargetDir

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

Returns:
the directory path to the target directory.

getTargetFile

public static java.io.File getTargetFile(java.lang.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 java.io.File getTargetTestingDir()

getTargetTestingDir

public static java.io.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 java.io.File getTargetTestingDir(java.lang.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 java.io.File getTestResourceDir(java.lang.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 java.io.File getTestResourceFile(java.lang.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 java.io.File getTestResourcePath(java.lang.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 java.io.File getTestResourcesDir()
Get the directory to the src/test/resource directory

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

readToString

public static java.lang.String readToString(java.io.File file)
                                     throws java.io.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:
java.io.IOException - if unable to read the file.

getTestID

public static java.lang.String getTestID()


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