Class 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
      void addCliOption​(java.lang.String option)  
      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 deleteArtifacts​(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.
      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<java.lang.String,​java.lang.String> envVars)  
      void executeGoals​(java.util.List<java.lang.String> goals)  
      void executeGoals​(java.util.List<java.lang.String> goals, java.util.Map<java.lang.String,​java.lang.String> 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<java.lang.String,​java.lang.String> filterProperties)
      Filters a text file by replacing some user-defined tokens.
      java.io.File filterFile​(java.lang.String srcPath, java.lang.String dstPath, java.lang.String fileEncoding, java.util.Properties filterProperties)
      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.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 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.
      java.lang.String getArtifactPath​(java.lang.String org, java.lang.String name, java.lang.String version, java.lang.String ext)  
      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.
      java.lang.String getBasedir()  
      java.util.List<java.lang.String> getCliOptions()  
      java.util.Map<java.lang.String,​java.lang.String> getEnvironmentVariables()  
      java.lang.String getExecutable()  
      java.lang.String getLocalRepoLayout()  
      java.lang.String getLocalRepository()  
      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 isDebugJvm()  
      boolean isMavenDebug()  
      static void launchSubversion​(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.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<java.lang.String> cliOptions)  
      void setDebug​(boolean debug)  
      void setDebugJvm​(boolean debugJvm)  
      void setEnvironmentVariable​(java.lang.String key, java.lang.String value)  
      void setEnvironmentVariables​(java.util.Map<java.lang.String,​java.lang.String> environmentVariables)  
      void setForkJvm​(boolean forkJvm)  
      void setLocalRepo​(java.lang.String localRepo)  
      void setLocalRepoLayout​(java.lang.String localRepoLayout)  
      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 setSystemProperty​(java.lang.String key, java.lang.String value)  
      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
    • Method Detail

      • setLocalRepo

        public void setLocalRepo​(java.lang.String localRepo)
      • resetStreams

        public void resetStreams()
      • displayStreamBuffers

        public void displayStreamBuffers()
      • verifyTextInLog

        public void verifyTextInLog​(java.lang.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
      • loadLines

        public java.util.List<java.lang.String> 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
      • 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 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 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 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 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.
      • 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
      • deleteArtifacts

        public void deleteArtifacts​(java.lang.String gid,
                                    java.lang.String aid,
                                    java.lang.String version)
                             throws java.io.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:
        java.io.IOException - If the artifacts could not be deleted.
        Since:
        1.3
      • 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<java.lang.String,​java.lang.String> 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
      • 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.IOException
        There are 226 references to this method in Maven core ITs. In most (all?) cases it is used together with newDefaultFilterProperties(). 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 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)
      • getExecutable

        public java.lang.String getExecutable()
      • 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 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 java.lang.String getLocalRepoLayout()
      • setLocalRepoLayout

        public void setLocalRepoLayout​(java.lang.String localRepoLayout)
      • getLocalRepository

        public java.lang.String getLocalRepository()