Package org.apache.maven.it

Examples of org.apache.maven.it.Verifier


        if ( bundleSource.exists() )
        {
            bundleSource.delete();
        }
       
        Verifier verifier = new Verifier( dir.getAbsolutePath() );
       
        verifier.setAutoclean( false );

        List<String> cliOptions = verifier.getCliOptions();
        cliOptions.add( "-DgroupId=" + groupId );
        cliOptions.add( "-DartifactId=" + artifactId );
        cliOptions.add( "-Dversion=" + version );

        verifier.executeGoal( prefix + "bundle-pack" );
        verifier.verifyErrorFreeLog();
        verifier.resetStreams();

        Set<String> requiredEntries = new HashSet<String>();
        requiredEntries.add( "pom.xml" );
        requiredEntries.add( artifactId + "-" + version + ".jar" );
       
        if ( !verifier.isMavenDebug() )
        {
            bundleSource.deleteOnExit();
        }

        assertZipContents( requiredEntries, Assertions.EMPTY_ENTRY_NAMES, bundleSource );
View Full Code Here


        if ( bundleSource.exists() )
        {
            bundleSource.delete();
        }
       
        Verifier verifier = new Verifier( dir.getAbsolutePath() );
       
        verifier.setAutoclean( false );

        List<String> cliOptions = verifier.getCliOptions();
        cliOptions.add( "-DgroupId=" + groupId );
        cliOptions.add( "-DartifactId=" + artifactId );
        cliOptions.add( "-Dversion=" + version );
        cliOptions.add( "-DscmUrl=http://foo/" );
        cliOptions.add( "-DscmConnection=scm:svn:http://foo/" );

        verifier.executeGoal( prefix + "bundle-pack" );
        verifier.verifyErrorFreeLog();
        verifier.resetStreams();

        Set<String> requiredEntries = new HashSet<String>();
        requiredEntries.add( "pom.xml" );
        requiredEntries.add( artifactId + "-" + version + ".jar" );
       
        if ( !verifier.isMavenDebug() )
        {
            bundleSource.deleteOnExit();
        }

        assertZipContents( requiredEntries, Assertions.EMPTY_ENTRY_NAMES, bundleSource );
View Full Code Here

    {
        if ( !installed )
        {
            File bootstrapDir = getTestDir( "bootstrap" );
           
            Verifier verifier = new Verifier( bootstrapDir.getAbsolutePath() );
           
            verifier.executeGoal( "install" );
           
            verifier.verifyErrorFreeLog();
            verifier.resetStreams();
           
            installed = true;
        }
    }
View Full Code Here

    public void createWithSCMInfoProvided()
        throws IOException, URISyntaxException, VerificationException
    {
        File dir = getTestDir( "bundle-create" );
       
        Verifier verifier = new Verifier( dir.getAbsolutePath() );
       
        verifier.getCliOptions().add( "--settings ../settings.xml" );
       
        String prefix = IntegrationTestUtils.getCliPluginPrefix();
       
        verifier.executeGoal( prefix + "bundle-create" );
        verifier.verifyErrorFreeLog();
        verifier.resetStreams();
       
        File bundleSource = new File( dir, "target/test-1.0-bundle.jar" );
       
        Set<String> requiredEntries = new HashSet<String>();
        requiredEntries.add( "pom.xml" );
View Full Code Here

    public void createWithSCMInfoMissing()
        throws IOException, URISyntaxException, VerificationException
    {
        File dir = getTestDir( "bundle-create-no-scm" );
       
        Verifier verifier = new Verifier( dir.getAbsolutePath() );
       
        List<String> cliOptions = verifier.getCliOptions();
        cliOptions.add( "--settings ../settings.xml" );
       
        String prefix = IntegrationTestUtils.getCliPluginPrefix();
       
        try
        {
            verifier.executeGoal( prefix + "bundle-create" );
            verifier.verifyErrorFreeLog();
           
            fail( "No SCM Section provided, build should fail." );
        }
        catch( VerificationException e )
        {
            // expected, since POM doesn't supply a SCM section.
        }
        finally
        {
            verifier.resetStreams();
        }
    }
View Full Code Here

    public void createFromAlternativePom()
        throws Exception
    {
        File dir = getTestDir( "bundle-create-alt-pom" );
       
        Verifier verifier = new Verifier( dir.getAbsolutePath() );
       
        verifier.getCliOptions().add( "-f alternative-pom.xml --settings ../settings.xml" );
       
        String prefix = IntegrationTestUtils.getCliPluginPrefix();
       
        verifier.executeGoal( prefix + "bundle-create" );
        verifier.verifyErrorFreeLog();
        verifier.resetStreams();
       
        File bundleSource = new File( dir, "target/test-1.0-bundle.jar" );
       
        Set<String> requiredEntries = new HashSet<String>();
        requiredEntries.add( "pom.xml" );
View Full Code Here

        throws Exception
    {
        System.out.println( "  Building: " + projectName );

        File testDir = getTestDir( projectName );
        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
        // Let's add alternate settings.xml setting so that the latest dependencies are used
        String localRepo = System.getProperty( "localRepositoryPath" );
        verifier.setLocalRepo( localRepo );

        verifier.getCliOptions().add( "-s \"" + settingsFile.getAbsolutePath() + "\"" );//
        verifier.getCliOptions().add( "-X" );
        verifier.localRepo = localRepo;

        // On linux and macOSX, an exception is thrown if a build failure occurs underneath
        try
        {
            verifier.executeGoal( "package" );
        }
        catch ( VerificationException e )
        {
            // @TODO needs to be handled nicely in the verifier
            if ( expectNoError || !e.getMessage().contains( "Exit code was non-zero" ) )
            {
                throw e;
            }
        }

        // If no error is expected make sure that error logs are free
        if ( expectNoError )
        {
            verifier.verifyErrorFreeLog();
        }
        verifier.resetStreams();
        return testDir;
    }
View Full Code Here

    final File localRepo = util.resolveFile("target/apache-maven-local-repository");

    tasks().chmod(file(new File(mavenHome, "bin"))).include("mvn").permissions("755").run();

    System.setProperty("maven.home", mavenHome.getAbsolutePath());
    final Verifier verifier = new Verifier(projectToBuildTarget.getAbsolutePath(), false);
    verifier.setAutoclean(true);

    verifier.setLocalRepo(localRepo.getAbsolutePath());
    verifier.setMavenDebug(true);
    verifier.setCliOptions(Arrays.asList("-s " + mavenSettingsTarget.getAbsolutePath()));

    verifier.resetStreams();

    verifier.setLogFileName("maven.log");
    verifier.executeGoals(Arrays.asList(goals));
    verifier.verifyErrorFreeLog();
    testIndex().recordLink(
        verifier.getLogFileName(), new File(projectToBuildTarget, verifier.getLogFileName())
    );

    return projectToBuildTarget;
  }
View Full Code Here

  public Verifier createMavenVerifier(final MavenDeployment mavenDeployment)
      throws VerificationException, IOException
  {
    log.info("Maven home: {}", mavenDeployment.getMavenHomeFile().getAbsolutePath());
    System.setProperty("maven.home", mavenDeployment.getMavenHomeFile().getAbsolutePath());
    Verifier verifier = new Verifier(mavenDeployment.getMavenProjectFile().getAbsolutePath())
    {
      @Override
      public void executeGoals(List<String> goals, Map envVars) throws VerificationException {
        log.info("Executing goals: {}", goals);

        try {
          super.executeGoals(goals, envVars);
        }
        catch (VerificationException e) {
          // HACK: Log details, to avoid loosing them by hack below
          log.error("Failed to execute goals", e);

          // HACK: Strip out the entire log which is included in the message by default! :-(
          File logFile = new File(getBasedir(), getLogFileName());
          if (logFile.exists()) {
            throw new VerificationException(
                "Goals execution failed: " + goals + "; see log for more details: " + logFile.getAbsolutePath(),
                e.getCause());
          }
          else {
            // HACK: seems like maven-verifier is pretty bad about ensure there is a log file for the execution
            throw new VerificationException("Goals execution failed: " + goals + "; log file missing!", e.getCause());
          }
        }
      }
    };
    verifier.setLogFileName(mavenDeployment.getLogFileName());
    verifier.setLocalRepo(mavenDeployment.getLocalRepositoryFile().getAbsolutePath());
    verifier.resetStreams();

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

    // FIXME: This is way too loud, perhaps we need a system property to turn this on...
    // FIXME: though we really need to rewrite how we run Maven (or other tools)
    //options.add("-X");

    options.add("-Dmaven.repo.local=" + mavenDeployment.getLocalRepositoryFile().getAbsolutePath());
    options.add("-s " + mavenDeployment.getSettingsXmlFile().getAbsolutePath());
    verifier.setCliOptions(options);
    return verifier;
  }
View Full Code Here

    final File localRepo = util.resolveFile("target/apache-maven-local-repository");

    tasks().chmod(file(new File(mavenHome, "bin"))).include("mvn").permissions("755").run();

    System.setProperty("maven.home", mavenHome.getAbsolutePath());
    final Verifier verifier = new Verifier(projectToBuildTarget.getAbsolutePath(), false);
    verifier.setAutoclean(true);

    verifier.setLocalRepo(localRepo.getAbsolutePath());
    verifier.setMavenDebug(true);
    verifier.setCliOptions(Arrays.asList("-s " + mavenSettingsTarget.getAbsolutePath()));

    verifier.resetStreams();

    verifier.setLogFileName("maven.log");
    verifier.executeGoals(Arrays.asList(goals));
    verifier.verifyErrorFreeLog();
    testIndex().recordLink(
        verifier.getLogFileName(), new File(projectToBuildTarget, verifier.getLogFileName())
    );

    return projectToBuildTarget;
  }
View Full Code Here

TOP

Related Classes of org.apache.maven.it.Verifier

Copyright © 2018 www.massapicom. 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.