public final class MavenTestingUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static File |
getBasedir()
Deprecated.
use
getBaseDir() instead |
static File |
getBaseDir()
Obtain a
File reference to the maven ${basedir} for the module. |
static java.nio.file.Path |
getBasePath()
Obtain a
Path reference to the maven ${basedir} for the module. |
static URI |
getBaseURI()
Get the Basedir for the project as a URI
|
static File |
getProjectDir(String path)
Get a directory reference to a required directory in the project module path, based on relative
path references from maven ${basedir}.
|
static java.nio.file.Path |
getProjectDirPath(String path)
Get a
Path reference to a required directory in the project module path, based on relative
path references from maven ${basedir}. |
static File |
getProjectFile(String path)
Get a
File reference to a required file in the project module path, based on relative
path references from maven ${basedir}. |
static java.nio.file.Path |
getProjectFilePath(String path)
Get a
Path reference to a required file in the project module path, based on relative
path references from maven ${basedir}. |
static File |
getTargetDir()
Get the
File reference to the /target directory for this project. |
static File |
getTargetFile(String path)
Create a
File object for a path in the /target directory. |
static java.nio.file.Path |
getTargetPath()
Get the
Path reference to the /target directory for this project. |
static java.nio.file.Path |
getTargetPath(String path)
Create a
Path object for a path in the /target directory. |
static File |
getTargetTestingDir()
Get a
File reference to the maven ${basedir}/target/tests/ directory. |
static File |
getTargetTestingDir(Class<?> testclass,
String testmethodname)
Obtain a testing directory reference in maven
${basedir}/target/tests/${condensed-classname}/${methodname} path that uses an condensed directory
name based on the testclass and subdirectory based on the testmethod being run. |
static File |
getTargetTestingDir(String testname)
Get a
File reference to the maven ${basedir}/target/tests/test-${testname} using
the supplied testname |
static File |
getTargetTestingDir(junit.framework.TestCase test)
Get a
File reference to the ${basedir}/target/tests/test-${testname} directory. |
static java.nio.file.Path |
getTargetTestingPath()
Get a
Path reference to the maven ${basedir}/target/tests/ path. |
static java.nio.file.Path |
getTargetTestingPath(Class<?> testclass,
String testmethodname)
Obtain a testing directory reference in maven
${basedir}/target/tests/${condensed-classname}/${methodname} path that uses an condensed directory
name based on the testclass and subdirectory based on the testmethod being run. |
static java.nio.file.Path |
getTargetTestingPath(String testname)
Get a
Path reference to the maven ${basedir}/target/tests/test-${testname} using
the supplied testname |
static java.nio.file.Path |
getTargetTestingPath(junit.framework.TestCase test)
Get a
Path reference to the ${basedir}/target/tests/test-${testname} directory. |
static URI |
getTargetURI(String path)
Get a URI reference to a path (File or Dir) within the maven "${basedir}/target" directory.
|
static URL |
getTargetURL(String path)
Get a URL reference to a path (File or Dir) within the maven "${basedir}/target" directory.
|
static String |
getTestIDAsPath()
Deprecated.
Upgrade to Junit 4.x and use the
TestingDir @Rule instead |
static File |
getTestResourceDir(String name)
Get a dir from the maven
${basedir}/src/test/resource directory. |
static File |
getTestResourceFile(String name)
Get a file from the maven
${basedir}/src/test/resource directory. |
static java.nio.file.Path |
getTestResourcePath(String name)
Get a path resource (File or Dir) from the maven
${basedir}/src/test/resource directory. |
static java.nio.file.Path |
getTestResourcePathDir(String name)
Get a dir from the maven
${basedir}/src/test/resource directory. |
static java.nio.file.Path |
getTestResourcePathFile(String name)
Get a file from the maven
${basedir}/src/test/resource directory. |
static File |
getTestResourcesDir()
Get the
File reference to the maven ${basedir}/src/test/resources directory |
static java.nio.file.Path |
getTestResourcesPath()
Get the
Path reference to the maven ${basedir}/src/test/resources directory |
@Deprecated public static File getBasedir()
getBaseDir() insteadFile reference to the maven ${basedir} for the module.
Convenience method for MavenTestingUtils.getBasePath().toFile()
getBasePath()public static File getBaseDir()
File reference to the maven ${basedir} for the module.
Convenience method for MavenTestingUtils.getBasePath().toFile()
getBasePath()public static java.nio.file.Path getBasePath()
Path reference to the maven ${basedir} for the module.
Note: while running in maven, the ${basedir} is populated by maven and used by the surefire-plugin.
While running in eclipse, the ${basedir} property is unset, resulting in this method falling back to ${user.dir}
equivalent use.
public static URI getBaseURI()
public static File getTargetDir()
File reference to the /target directory for this project.
Convenience method for MavenTestingUtils.getTargetPath().toFile()
getTargetPath()public static java.nio.file.Path getTargetPath()
Path reference to the /target directory for this project.
This is roughly equivalent to the ${project.build.directory} property.
Note: this implementation does not inspect the pom.xml for non-standard locations
of the ${project.build.directory} property. (it always assumes /target)
/target directory.public static File getTargetFile(String path)
File object for a path in the /target directory.
Convenience method for MavenTestingUtils.getTargetPath("foo").toFile()
path - the path desired, no validation of existence is performed.getTargetPath(String)public static java.nio.file.Path getTargetPath(String path)
Path object for a path in the /target directory.path - the path desired, no validation of existence is performed.public static File getTargetTestingDir()
File reference to the maven ${basedir}/target/tests/ directory.
Convenience method for MavenTestingUtils.getTargetTestingPath().toFile()
${basedir}/target/tests/ directory.
Note: will not validate that the directory exists, or create the directory)public static java.nio.file.Path getTargetTestingPath()
Path reference to the maven ${basedir}/target/tests/ path.${basedir}/target/tests/ directory.
Note: will not validate that the directory exists, or create the directory)public static File getTargetTestingDir(String testname)
File reference to the maven ${basedir}/target/tests/test-${testname} using
the supplied testname
Convenience method for MavenTestingUtils.getTargetTestingPath(testname).toFile()
testname - the testname to create directory against.${basedir}/target/tests/test-${testname} directorypublic static java.nio.file.Path getTargetTestingPath(String testname)
Path reference to the maven ${basedir}/target/tests/test-${testname} using
the supplied testnametestname - the testname to create directory against.${basedir}/target/tests/test-${testname} directorypublic static File getTargetTestingDir(junit.framework.TestCase test)
File reference to the ${basedir}/target/tests/test-${testname} directory.
Uses the JUnit 3.x TestCase.getName() to make a unique directory name per test.
Convenience method for MavenTestingUtils.getTargetTestingPath(TestCase.getName()).toFile()
test - the junit 3.x testcase to base this new directory on.${basedir}/target/tests/test-${testname} directory.public static java.nio.file.Path getTargetTestingPath(junit.framework.TestCase test)
Path reference to the ${basedir}/target/tests/test-${testname} directory.
Uses the JUnit 3.x TestCase.getName() to make a unique directory name per test.
Convenience method for MavenTestingUtils.getTargetTestingPath(TestCase.getName())
test - the junit 3.x testcase to base this new directory on.${basedir}/target/tests/test-${testname} directory.getTargetTestingPath(String)public static URI getTargetURI(String path)
Convenience method for MavenTestingUtils.getTargetPath(path).toUri()
path - the relative path to usepublic static URL getTargetURL(String path) throws MalformedURLException
Convenience method for MavenTestingUtils.getTargetURI(path).toURL()
path - the relative path to useMalformedURLException - if unable to create a new target url due to URL error.public static File getTargetTestingDir(Class<?> testclass, String testmethodname)
${basedir}/target/tests/${condensed-classname}/${methodname} path that uses an condensed directory
name based on the testclass and subdirectory based on the testmethod being run.
Note: the @Rule TestingDir is a better choice in most cases.
Convenience method for MavenTestingUtils.getTargetTestingDir(testclass, testmethodname).toFile()
testclass - the class for the test casetestmethodname - the test method name${basedir}/target/tests/ sub directoryFS,
TestingDirpublic static java.nio.file.Path getTargetTestingPath(Class<?> testclass, String testmethodname)
${basedir}/target/tests/${condensed-classname}/${methodname} path that uses an condensed directory
name based on the testclass and subdirectory based on the testmethod being run.
Note: the @Rule TestingDir is a better choice in most cases.
testclass - the class for the test casetestmethodname - the test method name${basedir}/target/tests/ sub directoryFS,
TestingDir@Deprecated public static String getTestIDAsPath()
TestingDir @Rule insteadpublic static File getProjectFile(String path)
File reference to a required file in the project module path, based on relative
path references from maven ${basedir}.
Note: will throw assertion error if path does point to an existing file
Convenience method for MavenTestingUtils.getProjectFilePath(path).toFile()
path - the relative path to referencepublic static java.nio.file.Path getProjectFilePath(String path)
Path reference to a required file in the project module path, based on relative
path references from maven ${basedir}.
Note: will throw assertion error if path does point to an existing file
path - the relative path to referencepublic static File getProjectDir(String path)
Note: will throw assertion error if path does point to an existing directory
Convenience method for MavenTestingUtils.getProjectDirPath(path).toFile()
path - the relative path to referencepublic static java.nio.file.Path getProjectDirPath(String path)
Path reference to a required directory in the project module path, based on relative
path references from maven ${basedir}.
Note: will throw assertion error if path does point to an existing directory
path - the relative path to referencepublic static File getTestResourcesDir()
File reference to the maven ${basedir}/src/test/resources directory
Convenience method for MavenTestingUtils.getTestResourcesPath().toFile()
File to the maven ${basedir}/src/test/resources directorypublic static java.nio.file.Path getTestResourcesPath()
Path reference to the maven ${basedir}/src/test/resources directoryPath to the maven ${basedir}/src/test/resources directorypublic static File getTestResourceDir(String name)
${basedir}/src/test/resource directory.
Note: will throw assertion error if path does point to an existing directory
Convenience method for MavenTestingUtils.getTestResourcesPathDir(name).toFile()
name - the name of the path to get (it must exist as a dir)${basedir}/src/test/resource pathpublic static java.nio.file.Path getTestResourcePathDir(String name)
${basedir}/src/test/resource directory.
Note: will throw assertion error if path does point to an existing directory
name - the name of the path to get (it must exist as a dir)${basedir}/src/test/resource pathpublic static File getTestResourceFile(String name)
${basedir}/src/test/resource directory.
Note: will throw assertion error if path does point to an existing file
name - the name of the path to get (it must exist as a file)${basedir}/src/test/resourcepublic static java.nio.file.Path getTestResourcePathFile(String name)
${basedir}/src/test/resource directory.
Note: will throw assertion error if path does point to an existing file
name - the name of the path to get (it must exist as a file)${basedir}/src/test/resourcepublic static java.nio.file.Path getTestResourcePath(String name)
${basedir}/src/test/resource directory.name - the name of the path to get (it must exist)${basedir}/src/test/resourceCopyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.