|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jetty.toolchain.test.MavenTestingUtils
public final class MavenTestingUtils
Common utility methods for working with JUnit tests cases in a maven friendly way.
Method Summary | |
---|---|
protected static String |
condensePackageString(String classname)
Condenses a classname by stripping down the package name to just the first character of each package name segment. |
static File |
getBasedir()
|
static URI |
getBaseURI()
Get the Basedir for the project as a URI |
static File |
getProjectDir(String path)
|
static File |
getProjectFile(String path)
|
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()
Get the in /target/tests/ code that uses the an arbitrary name. |
static File |
getTargetTestingDir(Class<?> testclass,
String testmethodname)
Get a dir in /target/ that uses the an arbitrary name. |
static File |
getTargetTestingDir(String testname)
Get a dir in /target/ that uses the an arbitrary name. |
static File |
getTargetTestingDir(TestCase test)
Get a dir in /target/ that uses the JUnit 3.x TestCase.getName() to make itself unique. |
static URI |
getTargetURI(String path)
|
static URL |
getTargetURL(String path)
|
static String |
getTestIDAsPath()
|
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 |
protected static String |
maxStringLength(int max,
String raw)
Smash a long string to fit within the max string length, by taking the middle section of the string and replacing them with an ellipsis "..." |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static File getBasedir()
public static URI getBaseURI()
public static File getTargetDir()
public static File getTargetFile(String path)
File
object for a path in the /target directory.
path
- the path desired, no validation of existence is performed.
public static File getTargetTestingDir()
/target/tests/
code that uses the an arbitrary name.
/target/tests/
that uses the an arbitrary name.public static File getTargetTestingDir(String testname)
testname
- the testname to create directory against.
public static File getTargetTestingDir(TestCase test)
TestCase.getName()
to make itself unique.
test
- the junit 3.x testcase to base this new directory on.
TestCase.getName()
to make itself unique.public static URI getTargetURI(String path) throws MalformedURLException
MalformedURLException
public static URL getTargetURL(String path) throws MalformedURLException
MalformedURLException
public static File getTargetTestingDir(Class<?> testclass, String testmethodname)
Best if used with TestingDir
junit rule.
@Rule public TestingDir testdir = new TestingDir(); @Test public void testFoo() { Assert.assertTrue("Testing dir exists",testdir.getDir().exists()); }
testclass
- the class for the test casetestmethodname
- the test method name
${basedir}/target
sub directorypublic static String getTestIDAsPath()
public static File getProjectFile(String path)
public static File getProjectDir(String path)
protected static String condensePackageString(String classname)
Examples: "org.eclipse.jetty.test.FooTest" = "oejt.FooTest" "org.eclipse.jetty.server.logging.LogTest" = "orjsl.LogTest"
classname
- the fully qualified class name
protected static String maxStringLength(int max, String raw)
Examples: .maxStringLength("Eatagramovabits", 5)
max
- the maximum size of the stringraw
- the raw string to smash
public static File getTestResourceDir(String name)
src/test/resource
directory.
name
- the name of the path to get (it must exist as a dir)
src/test/resource
public static File getTestResourceFile(String name)
src/test/resource
directory.
name
- the name of the path to get (it must exist as a file)
src/test/resource
public static File getTestResourcePath(String name)
src/test/resource
directory.
name
- the name of the path to get (it must exist)
src/test/resource
public static File getTestResourcesDir()
src/test/resource
directory
File
to the src/test/resources
directory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |