Examples of VerificationException


Examples of org.apache.maven.it.VerificationException

                break;
            }
        }
        if ( !result )
        {
            throw new VerificationException( "Text not found in log: " + text );
        }
    }
View Full Code Here

Examples of org.apache.maven.it.VerificationException

                }
            }
        }
        catch ( FileNotFoundException e )
        {
            throw new VerificationException( "Error reading properties file", e );
        }
        catch ( IOException e )
        {
            throw new VerificationException( "Error reading properties file", e );
        }

        return properties;
    }
View Full Code Here

Examples of org.apache.maven.it.VerificationException

                reader.close();
            }
            catch ( FileNotFoundException e )
            {
                throw new VerificationException( e );
            }
            catch ( IOException e )
            {
                throw new VerificationException( e );
            }
        }

        return lines;
    }
View Full Code Here

Examples of org.apache.maven.it.VerificationException

        {
            throw e;
        }
        catch ( Exception e )
        {
            throw new VerificationException( e );
        }
    }
View Full Code Here

Examples of org.apache.maven.it.VerificationException

            File f = new File( args );

            if ( f.exists() && !f.delete() )
            {
                throw new VerificationException( "Error removing file - delete failed" );
            }
        }
        else if ( "rmdir".equals( cmd ) )
        {
            System.out.println( "Removing directory: " + args );

            try
            {
                File f = new File( args );

                FileUtils.deleteDirectory( f );
            }
            catch ( IOException e )
            {
                throw new VerificationException( "Error removing directory - delete failed" );
            }
        }
        else if ( "svn".equals( cmd ) )
        {
            launchSubversion( line, getBasedir() );
        }
        else
        {
            throw new VerificationException( "unknown command: " + cmd );
        }
    }
View Full Code Here

Examples of org.apache.maven.it.VerificationException

            if ( ret > 0 )
            {
                System.err.println( "Exit code: " + ret );

                throw new VerificationException();
            }
        }
        catch ( CommandLineException e )
        {
            throw new VerificationException( e );
        }
        catch ( IOException e )
        {
            throw new VerificationException( e );
        }
    }
View Full Code Here

Examples of org.apache.maven.it.VerificationException

                if ( is == null )
                {
                    if ( wanted )
                    {
                        throw new VerificationException( "Expected JAR resource was not found: " + line );
                    }
                }
                else
                {
                    if ( !wanted )
                    {
                        throw new VerificationException( "Unwanted JAR resource was found: " + line );
                    }
                }
            }
            catch ( MalformedURLException e )
            {
                throw new VerificationException( "Error looking for JAR resource", e );
            }
            catch ( IOException e )
            {
                throw new VerificationException( "Error looking for JAR resource", e );
            }
            finally
            {
                if ( is != null )
                {
                    try
                    {
                        is.close();
                    }
                    catch ( IOException e )
                    {
                        System.err.println( "WARN: error closing stream: " + e );
                    }
                }
            }
        }
        else
        {
            File expectedFile = new File( line );

            // NOTE: On Windows, a path with a leading (back-)slash is relative to the current drive
            if ( !expectedFile.isAbsolute() && !expectedFile.getPath().startsWith( File.separator ) )
            {
                expectedFile = new File( getBasedir(), line );
            }

            if ( line.indexOf( '*' ) > -1 )
            {
                File parent = expectedFile.getParentFile();

                if ( !parent.exists() )
                {
                    if ( wanted )
                    {
                        throw new VerificationException( "Expected file pattern was not found: "
                            + expectedFile.getPath() );
                    }
                }
                else
                {
                    String shortNamePattern = expectedFile.getName().replaceAll( "\\*", ".*" );

                    String[] candidates = parent.list();

                    boolean found = false;

                    if ( candidates != null )
                    {
                        for ( int i = 0; i < candidates.length; i++ )
                        {
                            if ( candidates[i].matches( shortNamePattern ) )
                            {
                                found = true;
                                break;
                            }
                        }
                    }

                    if ( !found && wanted )
                    {
                        throw new VerificationException( "Expected file pattern was not found: "
                            + expectedFile.getPath() );
                    }
                    else if ( found && !wanted )
                    {
                        throw new VerificationException( "Unwanted file pattern was found: " + expectedFile.getPath() );
                    }
                }
            }
            else
            {
                if ( !expectedFile.exists() )
                {
                    if ( wanted )
                    {
                        throw new VerificationException( "Expected file was not found: " + expectedFile.getPath() );
                    }
                }
                else
                {
                    if ( !wanted )
                    {
                        throw new VerificationException( "Unwanted file was found: " + expectedFile.getPath() );
                    }
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.maven.it.VerificationException

    public void executeGoals( List<String> goals, Map<String, String> envVars )
        throws VerificationException
    {
        if ( goals.size() == 0 )
        {
            throw new VerificationException( "No goals specified" );
        }

        List<String> allGoals = new ArrayList<String>();

        if ( autoclean )
        {
            /*
             * NOTE: Neither test lifecycle binding nor prefix resolution here but call the goal directly.
             */
            allGoals.add( "org.apache.maven.plugins:maven-clean-plugin:clean" );
        }

        allGoals.addAll( goals );

        Commandline cli = null;
        int ret;

        File logFile = new File( getBasedir(), getLogFileName() );
        try
        {
            cli = createCommandLine();

            for ( Iterator<String> i = envVars.keySet().iterator(); i.hasNext(); )
            {
                String key = i.next();

                cli.addEnvironment( key, envVars.get( key ) );

                /*
                 * What was the point of this? It doesn't work on windows. try { FileUtils.fileWrite( "/tmp/foo.txt",
                 * "setting envar[ " + key + " = " + envVars.get( key ) ); } catch ( IOException e ) {
                 * e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. }
                 */

                // System.out.println();
            }

            if ( envVars.get( "JAVA_HOME" ) == null )
            {
                cli.addEnvironment( "JAVA_HOME", System.getProperty( "java.home" ) );
            }

            cli.addEnvironment( "MAVEN_TERMINATE_CMD", "on" );

            cli.setWorkingDirectory( getBasedir() );

            for ( Iterator<String> it = cliOptions.iterator(); it.hasNext(); )
            {
                String key = String.valueOf( it.next() );

                String resolvedArg = resolveCommandLineArg( key );

                cli.createArgument().setLine( resolvedArg );
            }

            cli.createArgument().setValue( "-e" );

            cli.createArgument().setValue( "--batch-mode" );

            if ( this.mavenDebug )
            {
                cli.createArgument().setValue( "--debug" );
            }

            for ( Iterator<String> i = systemProperties.stringPropertyNames().iterator(); i.hasNext(); )
            {
                String key = (String) i.next();
                String value = systemProperties.getProperty( key );
                cli.createArgument().setValue( "-D" + key + "=" + value );
            }

            /*
             * NOTE: Unless explicitly requested by the caller, the forked builds should use the current local
             * repository. Otherwise, the forked builds would in principle leave the sandbox environment which has been
             * setup for the current build. In particular, using "maven.repo.local" will make sure the forked builds use
             * the same local repo as the parent build even if a custom user settings is provided.
             */
            boolean useMavenRepoLocal =
                Boolean.valueOf( verifierProperties.getProperty( "use.mavenRepoLocal", "true" ) ).booleanValue();

            if ( useMavenRepoLocal )
            {
                cli.createArgument().setValue( "-Dmaven.repo.local=" + localRepo );
            }

            for ( Iterator<String> i = allGoals.iterator(); i.hasNext(); )
            {
                cli.createArgument().setValue( i.next() );
            }

            // System.out.println( "Command: " + Commandline.toString( cli.getCommandline() ) );

            ret = runCommandLine( cli, logFile );
        }
        catch ( CommandLineException e )
        {
            throw new VerificationException( "Failed to execute Maven: " + cli, e );
        }
        catch ( IOException e )
        {
            throw new VerificationException( e );
        }

        if ( ret > 0 )
        {
            System.err.println( "Exit code: " + ret );

            throw new VerificationException( "Exit code was non-zero: " + ret + "; command line and log = \n" + cli
                + "\n" + getLogContents( logFile, 75 ) );
        }
    }
View Full Code Here

Examples of org.apache.maven.it.VerificationException

        {
            log = File.createTempFile( "maven", "log" );
        }
        catch ( IOException e )
        {
            throw new VerificationException( "Error creating temp file", e );
        }

        try
        {
            runCommandLine( cmd, log );
        }
        catch ( CommandLineException e )
        {
            throw new VerificationException( "Error running commandline " + cmd.toString(), e );
        }
        catch ( IOException e )
        {
            throw new VerificationException( "IO Error communicating with commandline " + cmd.toString(), e );
        }

        String version = null;

        List<String> logLines = loadFile( log, false );
        log.delete();

        for ( Iterator<String> it = logLines.iterator(); version == null && it.hasNext(); )
        {
            String line = it.next();

            final String MAVEN_VERSION = "Maven version: ";

            // look out for "Maven version: 3.0-SNAPSHOT built on unknown"
            if ( line.regionMatches( true, 0, MAVEN_VERSION, 0, MAVEN_VERSION.length() ) )
            {
                version = line.substring( MAVEN_VERSION.length() ).trim();
                if ( version.indexOf( ' ' ) >= 0 )
                {
                    version = version.substring( 0, version.indexOf( ' ' ) );
                }
            }

            final String NEW_MAVEN_VERSION = "Apache Maven ";

            // look out for "Apache Maven 2.1.0-M2-SNAPSHOT (rXXXXXX; date)"
            if ( line.regionMatches( true, 0, NEW_MAVEN_VERSION, 0, NEW_MAVEN_VERSION.length() ) )
            {
                version = line.substring( NEW_MAVEN_VERSION.length() ).trim();
                if ( version.indexOf( ' ' ) >= 0 )
                {
                    version = version.substring( 0, version.indexOf( ' ' ) );
                }
            }
        }

        if ( version == null )
        {
            throw new VerificationException(
                                             "Illegal maven output: String 'Maven version: ' not found in the following output:\n"
                                                 + StringUtils.join( logLines.iterator(), "\n" ) );
        }
        else
        {
View Full Code Here

Examples of org.jbehave.core.exception.VerificationException

    public void specify() {
       
    }

    public void run() {
        throw new VerificationException("Failed");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.