org.apache.maven.it
Class Verifier

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

public class Verifier
extends java.lang.Object

Version:
$Id: Verifier.java 805828 2009-08-19 14:57:23Z bentmann $
Author:
Jason van Zyl, Brett Porter

Field Summary
 java.lang.String localRepo
           
 
Constructor Summary
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)
           
 
Method Summary
 void assertArtifactContents(java.lang.String org, java.lang.String artifact, java.lang.String version, java.lang.String type, java.lang.String contents)
           
 void assertArtifactNotPresent(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
           
 void assertArtifactPresent(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
           
 void assertFileMatches(java.lang.String file, java.lang.String regex)
          Check that given file's content matches an regular expression.
 void assertFileNotPresent(java.lang.String file)
           
 void assertFilePresent(java.lang.String file)
           
 void deleteArtifact(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
           
 void deleteArtifacts(java.lang.String gid)
          Deletes all artifacts in the specified group id from the local repository.
 void deleteDirectory(java.lang.String path)
          Deletes the specified directory.
 void displayStreamBuffers()
           
 void executeGoal(java.lang.String goal)
           
 void executeGoal(java.lang.String goal, java.util.Map envVars)
           
 void executeGoals(java.util.List goals)
           
 void executeGoals(java.util.List goals, java.util.Map envVars)
           
 void executeHook(java.lang.String filename)
           
 java.io.File filterFile(java.lang.String srcPath, java.lang.String dstPath, java.lang.String fileEncoding, java.util.Map filterProperties)
          Filters a text file by replacing some user-defined tokens.
 java.util.List getArtifactFileNameList(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
           
 java.lang.String getArtifactMetadataPath(java.lang.String gid, java.lang.String aid)
          Gets the path to the local artifact metadata.
 java.lang.String getArtifactMetadataPath(java.lang.String gid, java.lang.String aid, java.lang.String version)
          Gets the path to the local artifact metadata.
 java.lang.String getArtifactPath(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)
           
 java.lang.String getBasedir()
           
 java.util.List getCliOptions()
           
 java.lang.String getExecutable()
           
 java.lang.String getLogFileName()
          Gets the name of the file used to log build output.
 java.lang.String getMavenVersion()
           
 java.util.Properties getSystemProperties()
           
 java.util.Properties getVerifierProperties()
           
 boolean isAutoclean()
           
 boolean isMavenDebug()
           
static void launchSubversion(java.lang.String line, java.lang.String basedir)
           
 java.util.List loadFile(java.io.File file, boolean hasCommand)
           
 java.util.List loadFile(java.lang.String basedir, java.lang.String filename, boolean hasCommand)
           
 java.util.List loadLines(java.lang.String filename, java.lang.String encoding)
          Loads the (non-empty) lines of the specified text file.
 java.util.Properties loadProperties(java.lang.String filename)
           
static void main(java.lang.String[] args)
           
 java.util.Properties newDefaultFilterProperties()
          Gets a new copy of the default filter properties.
 void resetStreams()
           
 void setAutoclean(boolean autoclean)
           
 void setCliOptions(java.util.List cliOptions)
           
 void setDebug(boolean debug)
           
 void setLocalRepo(java.lang.String localRepo)
           
 void setLogFileName(java.lang.String logFileName)
          Sets the name of the file used to log build output.
 void setMavenDebug(boolean mavenDebug)
           
 void setSystemProperties(java.util.Properties systemProperties)
           
 void setVerifierProperties(java.util.Properties verifierProperties)
           
 void verify(boolean chokeOnErrorOutput)
           
 void verifyErrorFreeLog()
           
 void verifyTextInLog(java.lang.String text)
          Throws an exception if the text is not present in the log.
 void writeFile(java.lang.String path, java.lang.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 java.lang.String localRepo
Constructor Detail

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,
                boolean forkJvm)
         throws VerificationException
Throws:
VerificationException

Verifier

public Verifier(java.lang.String basedir)
         throws VerificationException
Throws:
VerificationException

Verifier

public Verifier(java.lang.String basedir,
                boolean debug)
         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 VerificationException
Throws an exception if the text is not present in the log.

Parameters:
text -
Throws:
VerificationException

loadProperties

public java.util.Properties loadProperties(java.lang.String filename)
                                    throws VerificationException
Throws:
VerificationException

loadLines

public java.util.List loadLines(java.lang.String filename,
                                java.lang.String encoding)
                         throws java.io.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:
java.io.IOException - If the file could not be loaded.
Since:
1.2

loadFile

public java.util.List loadFile(java.lang.String basedir,
                               java.lang.String filename,
                               boolean hasCommand)
                        throws VerificationException
Throws:
VerificationException

loadFile

public java.util.List 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)

getArtifactFileNameList

public java.util.List 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 be null.
aid - The artifact id, must not be null.
version - The artifact version, must not be null.
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 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(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.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:
java.io.IOException - If the artifacts could not be deleted.
Since:
1.2

deleteDirectory

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

Parameters:
path - The path to the directory to delete, relative to the base directory, must not be null.
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.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:
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 filterProperties)
                        throws java.io.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:
java.io.IOException - If the file could not be filtered.
Since:
1.2

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 base file: 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 envVars)
                 throws VerificationException
Throws:
VerificationException

executeGoals

public void executeGoals(java.util.List goals)
                  throws VerificationException
Throws:
VerificationException

getExecutable

public java.lang.String getExecutable()

executeGoals

public void executeGoals(java.util.List goals,
                         java.util.Map 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 getCliOptions()

setCliOptions

public void setCliOptions(java.util.List cliOptions)

getSystemProperties

public java.util.Properties getSystemProperties()

setSystemProperties

public void setSystemProperties(java.util.Properties systemProperties)

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 or null.
Since:
1.2

setDebug

public void setDebug(boolean debug)

isMavenDebug

public boolean isMavenDebug()

setMavenDebug

public void setMavenDebug(boolean mavenDebug)


Copyright © 2011. All Rights Reserved.