org.apache.maven.it
Class Verifier

java.lang.Object
  extended by org.apache.maven.it.Verifier

public class Verifier
extends Object

Version:
$Id: Verifier.java 1421845 2012-12-14 13:25:07Z krosenvold $
Author:
Jason van Zyl, Brett Porter

Field Summary
 String localRepo
           
 
Constructor Summary
Verifier(String basedir)
           
Verifier(String basedir, boolean debug)
           
Verifier(String basedir, String settingsFile)
           
Verifier(String basedir, String settingsFile, boolean debug)
           
Verifier(String basedir, String settingsFile, boolean debug, boolean forkJvm)
           
 
Method Summary
 void addCliOption(String option)
           
 void assertArtifactContents(String org, String artifact, String version, String type, String contents)
           
 void assertArtifactNotPresent(String org, String name, String version, String ext)
           
 void assertArtifactPresent(String org, String name, String version, String ext)
           
 void assertFileMatches(String file, String regex)
          Check that given file's content matches an regular expression.
 void assertFileNotPresent(String file)
           
 void assertFilePresent(String file)
           
 void deleteArtifact(String org, String name, String version, String ext)
           
 void deleteArtifacts(String gid)
          Deletes all artifacts in the specified group id from the local repository.
 void deleteArtifacts(String gid, String aid, String version)
          Deletes all artifacts in the specified g:a:v from the local repository.
 void deleteDirectory(String path)
          Deletes the specified directory.
 void displayStreamBuffers()
           
 void executeGoal(String goal)
           
 void executeGoal(String goal, Map envVars)
           
 void executeGoals(List<String> goals)
           
 void executeGoals(List<String> goals, Map envVars)
           
 void executeHook(String filename)
           
 File filterFile(String srcPath, String dstPath, String fileEncoding, Map filterProperties)
          Filters a text file by replacing some user-defined tokens.
 List<String> getArtifactFileNameList(String org, String name, String version, String ext)
           
 String getArtifactMetadataPath(String gid, String aid)
          Gets the path to the local artifact metadata.
 String getArtifactMetadataPath(String gid, String aid, String version)
          Gets the path to the local artifact metadata.
 String getArtifactMetadataPath(String gid, String aid, String version, String filename)
          Gets the path to a file in the local artifact directory.
 String getArtifactPath(String org, String name, String version, String ext)
           
 String getArtifactPath(String gid, String aid, String version, String ext, String classifier)
          Returns the absolute path to the artifact denoted by groupId, artifactId, version, extension and classifier.
 String getBasedir()
           
 List getCliOptions()
           
 Properties getEnvironmentVariables()
           
 String getExecutable()
           
 String getLocalRepoLayout()
           
 String getLogFileName()
          Gets the name of the file used to log build output.
 String getMavenVersion()
           
 Properties getSystemProperties()
           
 Properties getVerifierProperties()
           
 boolean isAutoclean()
           
 boolean isDebugJvm()
           
 boolean isMavenDebug()
           
static void launchSubversion(String line, String basedir)
           
 List<String> loadFile(File file, boolean hasCommand)
           
 List<String> loadFile(String basedir, String filename, boolean hasCommand)
           
 List<String> loadLines(String filename, String encoding)
          Loads the (non-empty) lines of the specified text file.
 Properties loadProperties(String filename)
           
static void main(String[] args)
           
 Properties newDefaultFilterProperties()
          Gets a new copy of the default filter properties.
 void resetStreams()
           
 void setAutoclean(boolean autoclean)
           
 void setCliOptions(List<String> cliOptions)
           
 void setDebug(boolean debug)
           
 void setDebugJvm(boolean debugJvm)
           
 void setEnvironmentVariable(String key, String value)
           
 void setEnvironmentVariables(Properties environmentVariables)
           
 void setForkJvm(boolean forkJvm)
           
 void setLocalRepo(String localRepo)
           
 void setLocalRepoLayout(String localRepoLayout)
           
 void setLogFileName(String logFileName)
          Sets the name of the file used to log build output.
 void setMavenDebug(boolean mavenDebug)
           
 void setSystemProperties(Properties systemProperties)
           
 void setSystemProperty(String key, String value)
           
 void setVerifierProperties(Properties verifierProperties)
           
 void verify(boolean chokeOnErrorOutput)
           
 void verifyErrorFreeLog()
           
 void verifyTextInLog(String text)
          Throws an exception if the text is not present in the log.
 void writeFile(String path, String contents)
          Writes a text file with the specified contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localRepo

public String localRepo
Constructor Detail

Verifier

public Verifier(String basedir)
         throws VerificationException
Throws:
VerificationException

Verifier

public Verifier(String basedir,
                boolean debug)
         throws VerificationException
Throws:
VerificationException

Verifier

public Verifier(String basedir,
                String settingsFile)
         throws VerificationException
Throws:
VerificationException

Verifier

public Verifier(String basedir,
                String settingsFile,
                boolean debug)
         throws VerificationException
Throws:
VerificationException

Verifier

public Verifier(String basedir,
                String settingsFile,
                boolean debug,
                boolean forkJvm)
         throws VerificationException
Throws:
VerificationException
Method Detail

setLocalRepo

public void setLocalRepo(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(String text)
                     throws VerificationException
Throws an exception if the text is not present in the log.

Parameters:
text - the text to assert present
Throws:
VerificationException

loadProperties

public Properties loadProperties(String filename)
                          throws VerificationException
Throws:
VerificationException

loadLines

public List<String> loadLines(String filename,
                              String encoding)
                       throws IOException
Loads 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 be null.
encoding - The character encoding of the file, may be null or 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:
IOException - If the file could not be loaded.
Since:
1.2

loadFile

public List<String> loadFile(String basedir,
                             String filename,
                             boolean hasCommand)
                      throws VerificationException
Throws:
VerificationException

loadFile

public List<String> loadFile(File file,
                             boolean hasCommand)
                      throws VerificationException
Throws:
VerificationException

getArtifactPath

public String getArtifactPath(String org,
                              String name,
                              String version,
                              String ext)

getArtifactPath

public String getArtifactPath(String gid,
                              String aid,
                              String version,
                              String ext,
                              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 List<String> getArtifactFileNameList(String org,
                                            String name,
                                            String version,
                                            String ext)

getArtifactMetadataPath

public String getArtifactMetadataPath(String gid,
                                      String aid,
                                      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 be null.
aid - The artifact id, must not be null.
version - The artifact version, may be null.
Returns:
The (absolute) path to the local artifact metadata, never null.

getArtifactMetadataPath

public String getArtifactMetadataPath(String gid,
                                      String aid,
                                      String version,
                                      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 be null.
aid - The artifact id, may be null.
version - The artifact version, may be null.
filename - The filename to use, must not be null.
Returns:
The (absolute) path to the local artifact metadata, never null.

getArtifactMetadataPath

public String getArtifactMetadataPath(String gid,
                                      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 be null.
aid - The artifact id, must not be null.
Returns:
The (absolute) path to the local artifact metadata, never null.

executeHook

public void executeHook(String filename)
                 throws VerificationException
Throws:
VerificationException

launchSubversion

public static void launchSubversion(String line,
                                    String basedir)
                             throws VerificationException
Throws:
VerificationException

deleteArtifact

public void deleteArtifact(String org,
                           String name,
                           String version,
                           String ext)
                    throws IOException
Throws:
IOException

deleteArtifacts

public void deleteArtifacts(String gid)
                     throws IOException
Deletes all artifacts in the specified group id from the local repository.

Parameters:
gid - The group id whose artifacts should be deleted, must not be null.
Throws:
IOException - If the artifacts could not be deleted.
Since:
1.2

deleteArtifacts

public void deleteArtifacts(String gid,
                            String aid,
                            String version)
                     throws IOException
Deletes all artifacts in the specified g:a:v from the local repository.

Parameters:
gid - The group id whose artifacts should be deleted, must not be null.
aid - The artifact id whose artifacts should be deleted, must not be null.
version - The (base) version whose artifacts should be deleted, must not be null.
Throws:
IOException - If the artifacts could not be deleted.
Since:
1.3

deleteDirectory

public void deleteDirectory(String path)
                     throws IOException
Deletes the specified directory.

Parameters:
path - The path to the directory to delete, relative to the base directory, must not be null.
Throws:
IOException - If the directory could not be deleted.
Since:
1.2

writeFile

public void writeFile(String path,
                      String contents)
               throws IOException
Writes 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 be null.
contents - The contents to write, must not be null.
Throws:
IOException - If the file could not be written.
Since:
1.2

filterFile

public File filterFile(String srcPath,
                       String dstPath,
                       String fileEncoding,
                       Map filterProperties)
                throws IOException
Filters a text file by replacing some user-defined tokens.

Parameters:
srcPath - The path to the input file, relative to the base directory, must not be null.
dstPath - The path to the output file, relative to the base directory and possibly equal to the input file, must not be null.
fileEncoding - The file encoding to use, may be null or empty to use the platform's default encoding.
filterProperties - The mapping from tokens to replacement values, must not be null.
Returns:
The path to the filtered output file, never null.
Throws:
IOException - If the file could not be filtered.
Since:
1.2

newDefaultFilterProperties

public 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 base file: URL, respectively.

Returns:
The (modifiable) map with the default filter properties, never null.
Since:
1.2

assertFilePresent

public void assertFilePresent(String file)

assertFileMatches

public void assertFileMatches(String file,
                              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(String file)

assertArtifactPresent

public void assertArtifactPresent(String org,
                                  String name,
                                  String version,
                                  String ext)

assertArtifactNotPresent

public void assertArtifactNotPresent(String org,
                                     String name,
                                     String version,
                                     String ext)

executeGoal

public void executeGoal(String goal)
                 throws VerificationException
Throws:
VerificationException

executeGoal

public void executeGoal(String goal,
                        Map envVars)
                 throws VerificationException
Throws:
VerificationException

executeGoals

public void executeGoals(List<String> goals)
                  throws VerificationException
Throws:
VerificationException

getExecutable

public String getExecutable()

executeGoals

public void executeGoals(List<String> goals,
                         Map envVars)
                  throws VerificationException
Throws:
VerificationException

getMavenVersion

public String getMavenVersion()
                       throws VerificationException
Throws:
VerificationException

main

public static void main(String[] args)
                 throws VerificationException
Throws:
VerificationException

assertArtifactContents

public void assertArtifactContents(String org,
                                   String artifact,
                                   String version,
                                   String type,
                                   String contents)
                            throws IOException
Throws:
IOException

getCliOptions

public List getCliOptions()

setCliOptions

public void setCliOptions(List<String> cliOptions)

addCliOption

public void addCliOption(String option)

getSystemProperties

public Properties getSystemProperties()

setSystemProperties

public void setSystemProperties(Properties systemProperties)

setSystemProperty

public void setSystemProperty(String key,
                              String value)

getEnvironmentVariables

public Properties getEnvironmentVariables()

setEnvironmentVariables

public void setEnvironmentVariables(Properties environmentVariables)

setEnvironmentVariable

public void setEnvironmentVariable(String key,
                                   String value)

getVerifierProperties

public Properties getVerifierProperties()

setVerifierProperties

public void setVerifierProperties(Properties verifierProperties)

isAutoclean

public boolean isAutoclean()

setAutoclean

public void setAutoclean(boolean autoclean)

getBasedir

public String getBasedir()

getLogFileName

public 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(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 or null.
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 String getLocalRepoLayout()

setLocalRepoLayout

public void setLocalRepoLayout(String localRepoLayout)


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.