Package org.apache.maven.it
Class Verifier
- java.lang.Object
-
- org.apache.maven.it.Verifier
-
public class Verifier extends java.lang.Object- Version:
- $Id: Verifier.java 1683864 2015-06-05 20:41:57Z tibordigana $
- Author:
- Jason van Zyl, Brett Porter
-
-
Constructor Summary
Constructors Constructor Description Verifier(java.lang.String basedir)Verifier(java.lang.String basedir, boolean debug)Verifier(java.lang.String basedir, java.lang.String settingsFile)Verifier(java.lang.String basedir, java.lang.String settingsFile, boolean debug)Verifier(java.lang.String basedir, java.lang.String settingsFile, boolean debug, boolean forkJvm)Verifier(java.lang.String basedir, java.lang.String settingsFile, boolean debug, boolean forkJvm, java.lang.String[] defaultCliOptions)Verifier(java.lang.String basedir, java.lang.String settingsFile, boolean debug, java.lang.String[] defaultCliOptions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCliOption(java.lang.String option)voidassertArtifactContents(java.lang.String org, java.lang.String artifact, java.lang.String version, java.lang.String type, java.lang.String contents)voidassertArtifactNotPresent(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)voidassertArtifactPresent(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)voidassertFileMatches(java.lang.String file, java.lang.String regex)Check that given file's content matches an regular expression.voidassertFileNotPresent(java.lang.String file)voidassertFilePresent(java.lang.String file)voiddeleteArtifact(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)voiddeleteArtifacts(java.lang.String gid)Deletes all artifacts in the specified group id from the local repository.voiddeleteArtifacts(java.lang.String gid, java.lang.String aid, java.lang.String version)Deletes all artifacts in the specified g:a:v from the local repository.voiddeleteDirectory(java.lang.String path)Deletes the specified directory.voiddisplayStreamBuffers()voidexecuteGoal(java.lang.String goal)voidexecuteGoal(java.lang.String goal, java.util.Map<java.lang.String,java.lang.String> envVars)voidexecuteGoals(java.util.List<java.lang.String> goals)voidexecuteGoals(java.util.List<java.lang.String> goals, java.util.Map<java.lang.String,java.lang.String> envVars)voidexecuteHook(java.lang.String filename)java.io.FilefilterFile(java.lang.String srcPath, java.lang.String dstPath, java.lang.String fileEncoding, java.util.Map<java.lang.String,java.lang.String> filterProperties)Filters a text file by replacing some user-defined tokens.java.io.FilefilterFile(java.lang.String srcPath, java.lang.String dstPath, java.lang.String fileEncoding, java.util.Properties filterProperties)Deprecated.java.util.List<java.lang.String>getArtifactFileNameList(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)java.lang.StringgetArtifactMetadataPath(java.lang.String gid, java.lang.String aid)Gets the path to the local artifact metadata.java.lang.StringgetArtifactMetadataPath(java.lang.String gid, java.lang.String aid, java.lang.String version)Gets the path to the local artifact metadata.java.lang.StringgetArtifactMetadataPath(java.lang.String gid, java.lang.String aid, java.lang.String version, java.lang.String filename)Gets the path to a file in the local artifact directory.java.lang.StringgetArtifactPath(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)java.lang.StringgetArtifactPath(java.lang.String gid, java.lang.String aid, java.lang.String version, java.lang.String ext, java.lang.String classifier)Returns the absolute path to the artifact denoted by groupId, artifactId, version, extension and classifier.java.lang.StringgetBasedir()java.util.List<java.lang.String>getCliOptions()java.util.Map<java.lang.String,java.lang.String>getEnvironmentVariables()java.lang.StringgetExecutable()java.lang.StringgetLocalRepoLayout()java.lang.StringgetLocalRepository()java.lang.StringgetLogFileName()Gets the name of the file used to log build output.java.lang.StringgetMavenVersion()java.util.PropertiesgetSystemProperties()java.util.PropertiesgetVerifierProperties()booleanisAutoclean()booleanisDebugJvm()booleanisMavenDebug()static voidlaunchSubversion(java.lang.String line, java.lang.String basedir)java.util.List<java.lang.String>loadFile(java.io.File file, boolean hasCommand)java.util.List<java.lang.String>loadFile(java.lang.String basedir, java.lang.String filename, boolean hasCommand)java.util.List<java.lang.String>loadLines(java.lang.String filename, java.lang.String encoding)Loads the (non-empty) lines of the specified text file.java.util.PropertiesloadProperties(java.lang.String filename)static voidmain(java.lang.String[] args)java.util.PropertiesnewDefaultFilterProperties()Gets a new copy of the default filter properties.voidresetStreams()voidsetAutoclean(boolean autoclean)voidsetCliOptions(java.util.List<java.lang.String> cliOptions)voidsetDebug(boolean debug)voidsetDebugJvm(boolean debugJvm)voidsetEnvironmentVariable(java.lang.String key, java.lang.String value)voidsetEnvironmentVariables(java.util.Map<java.lang.String,java.lang.String> environmentVariables)voidsetForkJvm(boolean forkJvm)voidsetLocalRepo(java.lang.String localRepo)voidsetLocalRepoLayout(java.lang.String localRepoLayout)voidsetLogFileName(java.lang.String logFileName)Sets the name of the file used to log build output.voidsetMavenDebug(boolean mavenDebug)voidsetSystemProperties(java.util.Properties systemProperties)voidsetSystemProperty(java.lang.String key, java.lang.String value)voidsetVerifierProperties(java.util.Properties verifierProperties)voidverify(boolean chokeOnErrorOutput)voidverifyErrorFreeLog()voidverifyTextInLog(java.lang.String text)Throws an exception if the text is not present in the log.voidwriteFile(java.lang.String path, java.lang.String contents)Writes a text file with the specified contents.
-
-
-
Constructor Detail
-
Verifier
public Verifier(java.lang.String basedir) throws VerificationException- Throws:
VerificationException
-
Verifier
public Verifier(java.lang.String basedir, boolean debug) throws VerificationException- Throws:
VerificationException
-
Verifier
public Verifier(java.lang.String basedir, java.lang.String settingsFile) throws VerificationException- Throws:
VerificationException
-
Verifier
public Verifier(java.lang.String basedir, java.lang.String settingsFile, boolean debug) throws VerificationException- Throws:
VerificationException
-
Verifier
public Verifier(java.lang.String basedir, java.lang.String settingsFile, boolean debug, java.lang.String[] defaultCliOptions) throws VerificationException- Throws:
VerificationException
-
Verifier
public Verifier(java.lang.String basedir, java.lang.String settingsFile, boolean debug, boolean forkJvm) throws VerificationException- Throws:
VerificationException
-
Verifier
public Verifier(java.lang.String basedir, java.lang.String settingsFile, boolean debug, boolean forkJvm, java.lang.String[] defaultCliOptions) throws VerificationException- Throws:
VerificationException
-
-
Method Detail
-
setLocalRepo
public void setLocalRepo(java.lang.String localRepo)
-
resetStreams
public void resetStreams()
-
displayStreamBuffers
public void displayStreamBuffers()
-
verify
public void verify(boolean chokeOnErrorOutput) throws VerificationException- Throws:
VerificationException
-
verifyErrorFreeLog
public void verifyErrorFreeLog() throws VerificationException- Throws:
VerificationException
-
verifyTextInLog
public void verifyTextInLog(java.lang.String text) throws VerificationExceptionThrows an exception if the text is not present in the log.- Parameters:
text- the text to assert present- Throws:
VerificationException
-
loadProperties
public java.util.Properties loadProperties(java.lang.String filename) throws VerificationException- Throws:
VerificationException
-
loadLines
public java.util.List<java.lang.String> loadLines(java.lang.String filename, java.lang.String encoding) throws java.io.IOExceptionLoads the (non-empty) lines of the specified text file.- Parameters:
filename- The path to the text file to load, relative to the base directory, must not benull.encoding- The character encoding of the file, may benullor empty to use the platform default encoding.- Returns:
- The list of (non-empty) lines from the text file, can be empty but never
null. - Throws:
java.io.IOException- If the file could not be loaded.- Since:
- 1.2
-
loadFile
public java.util.List<java.lang.String> loadFile(java.lang.String basedir, java.lang.String filename, boolean hasCommand) throws VerificationException- Throws:
VerificationException
-
loadFile
public java.util.List<java.lang.String> loadFile(java.io.File file, boolean hasCommand) throws VerificationException- Throws:
VerificationException
-
getArtifactPath
public java.lang.String getArtifactPath(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
-
getArtifactPath
public java.lang.String getArtifactPath(java.lang.String gid, java.lang.String aid, java.lang.String version, java.lang.String ext, java.lang.String classifier)Returns the absolute path to the artifact denoted by groupId, artifactId, version, extension and classifier.- Parameters:
gid- The groupId, must not be null.aid- The artifactId, must not be null.version- The version, must not be null.ext- The extension, must not be null.classifier- The classifier, may be null to be omitted.- Returns:
- the absolute path to the artifact denoted by groupId, artifactId, version, extension and classifier, never null.
-
getArtifactFileNameList
public java.util.List<java.lang.String> getArtifactFileNameList(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
-
getArtifactMetadataPath
public java.lang.String getArtifactMetadataPath(java.lang.String gid, java.lang.String aid, java.lang.String version)Gets the path to the local artifact metadata. Note that the method does not check whether the returned path actually points to existing metadata.- Parameters:
gid- The group id, must not benull.aid- The artifact id, must not benull.version- The artifact version, may benull.- Returns:
- The (absolute) path to the local artifact metadata, never
null.
-
getArtifactMetadataPath
public java.lang.String getArtifactMetadataPath(java.lang.String gid, java.lang.String aid, java.lang.String version, java.lang.String filename)Gets the path to a file in the local artifact directory. Note that the method does not check whether the returned path actually points to an existing file.- Parameters:
gid- The group id, must not benull.aid- The artifact id, may benull.version- The artifact version, may benull.filename- The filename to use, must not benull.- Returns:
- The (absolute) path to the local artifact metadata, never
null.
-
getArtifactMetadataPath
public java.lang.String getArtifactMetadataPath(java.lang.String gid, java.lang.String aid)Gets the path to the local artifact metadata. Note that the method does not check whether the returned path actually points to existing metadata.- Parameters:
gid- The group id, must not benull.aid- The artifact id, must not benull.- Returns:
- The (absolute) path to the local artifact metadata, never
null.
-
executeHook
public void executeHook(java.lang.String filename) throws VerificationException- Throws:
VerificationException
-
launchSubversion
public static void launchSubversion(java.lang.String line, java.lang.String basedir) throws VerificationException- Throws:
VerificationException
-
deleteArtifact
public void deleteArtifact(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext) throws java.io.IOException- Throws:
java.io.IOException
-
deleteArtifacts
public void deleteArtifacts(java.lang.String gid) throws java.io.IOExceptionDeletes all artifacts in the specified group id from the local repository.- Parameters:
gid- The group id whose artifacts should be deleted, must not benull.- Throws:
java.io.IOException- If the artifacts could not be deleted.- Since:
- 1.2
-
deleteArtifacts
public void deleteArtifacts(java.lang.String gid, java.lang.String aid, java.lang.String version) throws java.io.IOExceptionDeletes all artifacts in the specified g:a:v from the local repository.- Parameters:
gid- The group id whose artifacts should be deleted, must not benull.aid- The artifact id whose artifacts should be deleted, must not benull.version- The (base) version whose artifacts should be deleted, must not benull.- Throws:
java.io.IOException- If the artifacts could not be deleted.- Since:
- 1.3
-
deleteDirectory
public void deleteDirectory(java.lang.String path) throws java.io.IOExceptionDeletes the specified directory.- Parameters:
path- The path to the directory to delete, relative to the base directory, must not benull.- Throws:
java.io.IOException- If the directory could not be deleted.- Since:
- 1.2
-
writeFile
public void writeFile(java.lang.String path, java.lang.String contents) throws java.io.IOExceptionWrites a text file with the specified contents. The contents will be encoded using UTF-8.- Parameters:
path- The path to the file, relative to the base directory, must not benull.contents- The contents to write, must not benull.- Throws:
java.io.IOException- If the file could not be written.- Since:
- 1.2
-
filterFile
public java.io.File filterFile(java.lang.String srcPath, java.lang.String dstPath, java.lang.String fileEncoding, java.util.Map<java.lang.String,java.lang.String> filterProperties) throws java.io.IOExceptionFilters a text file by replacing some user-defined tokens.- Parameters:
srcPath- The path to the input file, relative to the base directory, must not benull.dstPath- The path to the output file, relative to the base directory and possibly equal to the input file, must not benull.fileEncoding- The file encoding to use, may benullor empty to use the platform's default encoding.filterProperties- The mapping from tokens to replacement values, must not benull.- Returns:
- The path to the filtered output file, never
null. - Throws:
java.io.IOException- If the file could not be filtered.- Since:
- 1.2
-
filterFile
public java.io.File filterFile(java.lang.String srcPath, java.lang.String dstPath, java.lang.String fileEncoding, java.util.Properties filterProperties) throws java.io.IOExceptionDeprecated.There are 226 references to this method in Maven core ITs. In most (all?) cases it is used together withnewDefaultFilterProperties(). Need to remove both methods and update all clients eventually/- Throws:
java.io.IOException
-
newDefaultFilterProperties
public java.util.Properties newDefaultFilterProperties()
Gets a new copy of the default filter properties. These default filter properties map the tokens "@basedir@" and "@baseurl@" to the test's base directory and its basefile:URL, respectively.- Returns:
- The (modifiable) map with the default filter properties, never
null. - Since:
- 1.2
-
assertFilePresent
public void assertFilePresent(java.lang.String file)
-
assertFileMatches
public void assertFileMatches(java.lang.String file, java.lang.String regex)Check that given file's content matches an regular expression. Note this method also checks that the file exists and is readable.- Parameters:
file- the file to check.regex- a regular expression.- See Also:
Pattern
-
assertFileNotPresent
public void assertFileNotPresent(java.lang.String file)
-
assertArtifactPresent
public void assertArtifactPresent(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
-
assertArtifactNotPresent
public void assertArtifactNotPresent(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
-
executeGoal
public void executeGoal(java.lang.String goal) throws VerificationException- Throws:
VerificationException
-
executeGoal
public void executeGoal(java.lang.String goal, java.util.Map<java.lang.String,java.lang.String> envVars) throws VerificationException- Throws:
VerificationException
-
executeGoals
public void executeGoals(java.util.List<java.lang.String> goals) throws VerificationException- Throws:
VerificationException
-
getExecutable
public java.lang.String getExecutable()
-
executeGoals
public void executeGoals(java.util.List<java.lang.String> goals, java.util.Map<java.lang.String,java.lang.String> envVars) throws VerificationException- Throws:
VerificationException
-
getMavenVersion
public java.lang.String getMavenVersion() throws VerificationException- Throws:
VerificationException
-
main
public static void main(java.lang.String[] args) throws VerificationException- Throws:
VerificationException
-
assertArtifactContents
public void assertArtifactContents(java.lang.String org, java.lang.String artifact, java.lang.String version, java.lang.String type, java.lang.String contents) throws java.io.IOException- Throws:
java.io.IOException
-
getCliOptions
public java.util.List<java.lang.String> getCliOptions()
-
setCliOptions
public void setCliOptions(java.util.List<java.lang.String> cliOptions)
-
addCliOption
public void addCliOption(java.lang.String option)
-
getSystemProperties
public java.util.Properties getSystemProperties()
-
setSystemProperties
public void setSystemProperties(java.util.Properties systemProperties)
-
setSystemProperty
public void setSystemProperty(java.lang.String key, java.lang.String value)
-
getEnvironmentVariables
public java.util.Map<java.lang.String,java.lang.String> getEnvironmentVariables()
-
setEnvironmentVariables
public void setEnvironmentVariables(java.util.Map<java.lang.String,java.lang.String> environmentVariables)
-
setEnvironmentVariable
public void setEnvironmentVariable(java.lang.String key, java.lang.String value)
-
getVerifierProperties
public java.util.Properties getVerifierProperties()
-
setVerifierProperties
public void setVerifierProperties(java.util.Properties verifierProperties)
-
isAutoclean
public boolean isAutoclean()
-
setAutoclean
public void setAutoclean(boolean autoclean)
-
getBasedir
public java.lang.String getBasedir()
-
getLogFileName
public java.lang.String getLogFileName()
Gets the name of the file used to log build output.- Returns:
- The name of the log file, relative to the base directory, never
null. - Since:
- 1.2
-
setLogFileName
public void setLogFileName(java.lang.String logFileName)
Sets the name of the file used to log build output.- Parameters:
logFileName- The name of the log file, relative to the base directory, must not be empty ornull.- Since:
- 1.2
-
setDebug
public void setDebug(boolean debug)
-
isMavenDebug
public boolean isMavenDebug()
-
setMavenDebug
public void setMavenDebug(boolean mavenDebug)
-
setForkJvm
public void setForkJvm(boolean forkJvm)
-
isDebugJvm
public boolean isDebugJvm()
-
setDebugJvm
public void setDebugJvm(boolean debugJvm)
-
getLocalRepoLayout
public java.lang.String getLocalRepoLayout()
-
setLocalRepoLayout
public void setLocalRepoLayout(java.lang.String localRepoLayout)
-
getLocalRepository
public java.lang.String getLocalRepository()
-
-