P - type of goal to testpublic abstract class AbstractMojoTest<P extends org.nuiton.plugin.Plugin> extends Object
org.nuiton.util.BasePluginTestCase.
Inside each test method, we can use the following objects :
getTestDir() : location of mojo resources (where the pom
file for example)getPomFile() : location of the pom
filegetMojo() : the instanciated and ready to execute
mojo| Modifier and Type | Class and Description |
|---|---|
class |
AbstractMojoTest.MojoTestRule
To offer inside each test method (annotated by a
Test) the
following properties :
AbstractMojoTest.MojoTestRule.testDir : location where to find resources for the
test AbstractMojoTest.MojoTestRule.pomFile : location of the pom file to use to build
the mojo AbstractMojoTest.MojoTestRule.mojo : the instanciated and initialized
mojo |
| Modifier and Type | Field and Description |
|---|---|
protected static File |
basedir
the basedir of the project
|
AbstractMojoTest.MojoTestRule |
name
Your test rule which offers methodName, testDir, pomFile and mojo inside
test methods.
|
protected static File |
testBasedir
the basedir of all tests (by convention
getBasedir()/target/test-classes). |
| Constructor and Description |
|---|
AbstractMojoTest() |
| Modifier and Type | Method and Description |
|---|---|
void |
checkExistsPattern(File file,
String pattern,
String encoding,
boolean required)
Checks on the given
file that :
file exists
the given pattern exists required = true
(or not required = false) in the content of the file.
|
void |
checkPattern(File file,
String content,
String pattern,
boolean required) |
protected void |
clearMojo(P mojo) |
protected P |
createMojo(File pomFile,
String goalName)
Create the mojo base on the given
pomFile for the given goalName. |
File |
getBasedir() |
protected abstract String |
getGoalName(String methodName)
Obtain the name of the goal according to the methodName.
|
protected String |
getMethodName() |
protected P |
getMojo() |
protected File |
getPomFile() |
protected File |
getPomFile(File testDir,
String methodName,
String goalName)
Obtain the location of the pom file to use for next mojo test.
|
String |
getRelativePathFromBasedir(File f) |
String |
getRelativePathFromTestBasedir(File f) |
File |
getTestBasedir() |
protected File |
getTestDir() |
protected File |
getTestDir(String methodName,
String goalName)
Obtain the location of the directory where to find resources for the next
test.
|
protected boolean |
isVerbose() |
protected void |
setUpMojo(P mojo,
File pomFile)
Initialize the given mojo.
|
protected static File basedir
protected static File testBasedir
getBasedir()/target/test-classes).public AbstractMojoTest.MojoTestRule name
public File getBasedir()
public File getTestBasedir()
protected abstract String getGoalName(String methodName)
methodName - the name of the next test to execute.protected File getTestDir(String methodName, String goalName)
getTestBasedir().methodName - the method of the next test to executegoalName - the common goal name to useprotected File getPomFile(File testDir, String methodName, String goalName)
methodName+".xml"
in the testDir.testDir - the location of resources for the next test (is the
result of the method getTestDir(String,
String).methodName - the name of the next testgoalName - the name of the common goalprotected P createMojo(File pomFile, String goalName) throws Exception
pomFile for the given goalName.pomFile - the location of the pom filegoalName - the name of the goal to lookupException - if any problem while creating the mojoprotected void setUpMojo(P mojo, File pomFile) throws Exception
mojo - the instanciate mojopomFile - the pom file used to instanciate the mojoException - if any pbprotected P getMojo()
protected String getMethodName()
protected File getPomFile()
protected File getTestDir()
protected boolean isVerbose()
protected void clearMojo(P mojo)
public void checkExistsPattern(File file, String pattern, String encoding, boolean required) throws IOException
file that :
pattern exists required = true
(or not required = false) in the content of the file.file - the file to testpattern - the pattern to searchencoding - encoding of the file to readrequired - flag to says if pattern should (or not) be found in
file's contentIOException - if could not read filepublic void checkPattern(File file, String content, String pattern, boolean required) throws IOException
IOExceptionCopyright © 2009-2012 CodeLutin. All Rights Reserved.