|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.plugin.AbstractMojoTest<P>
P - type of goal to testpublic abstract class AbstractMojoTest<P extends org.nuiton.plugin.Plugin>
Base test class for a mojo.
Note: replace the previous classorg.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
mojogetBasedir() getTestBasedir() getTestDir(String, String)getPomFile(File, String, String)createMojo(File, String)setUpMojo(Plugin, File)
| Nested Class Summary | |
|---|---|
protected 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 |
| Field Summary | |
|---|---|
protected static File |
basedir
the basedir of the project |
protected static org.apache.commons.logging.Log |
log
Test logger |
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 Summary | |
|---|---|
AbstractMojoTest()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.commons.logging.Log log
protected static File basedir
protected static File testBasedir
getBasedir()/target/test-classes).
public AbstractMojoTest.MojoTestRule name
| Constructor Detail |
|---|
public AbstractMojoTest()
| Method Detail |
|---|
public File getBasedir()
public File getTestBasedir()
public String getRelativePathFromBasedir(File f)
public String getRelativePathFromTestBasedir(File f)
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 use
protected 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 goal
protected 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 lookup
Exception - if any problem while creating the mojo
protected void setUpMojo(P mojo,
File pomFile)
throws Exception
mojo - the instanciate mojopomFile - the pom file used to instanciate the mojo
Exception - 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 content
IOException - if could not read file
public void checkPattern(File file,
String content,
String pattern,
boolean required)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||