Package org.apache.maven.it

Examples of org.apache.maven.it.Verifier


  private void deployPrivWithWagon(Gav gav, String repoUrl)
      throws Exception
  {
    this.resetTestUserPrivs();

    Verifier verifier = null;

    this.deleteFromRepository(getTestRepositoryId(), this.getTestId());

    // file to deploy
    File fileToDeploy = this.getTestFile(gav.getArtifactId() + "." + gav.getExtension());

    // we need to delete the files...
    this.deleteFromRepository(getTestRepositoryId(), this.getTestId() + "/");

    // deploy
    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);

    // with pom should fail

    try {
      verifier =
          MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy,
              this.getOverridableFile("settings.xml"));
      failTest(verifier);
    }
    catch (VerificationException e) {
      // expected 403
    }

    // give deployment role
    TestContainer.getInstance().getTestContext().useAdminForRequests();

    // try again
    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);

    // if this fails it will throw an error
    try {
      verifier =
          MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy,
              this.getOverridableFile("settings.xml"));
      failTest(verifier);
    }
    catch (VerificationException e) {
      // expected 403
    }

    // try again
    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);

    TestContainer.getInstance().getTestContext().useAdminForRequests();
    this.giveUserPrivilege("test-user", "T5");

    // if this fails it will throw an error
    verifier =
        MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy, this.getOverridableFile("settings.xml"));
    verifier.verifyErrorFreeLog();

    // do it again as an update, this should fail

    // if this fails it will throw an error
    try {
      verifier =
          MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy,
              this.getOverridableFile("settings.xml"));
      failTest(verifier);
    }
    catch (VerificationException e) {
      // expected 403
    }

    // now the user should be able to redeploy
    TestContainer.getInstance().getTestContext().useAdminForRequests();
    this.giveUserPrivilege("test-user", "T3");

    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);
    // if this fails it will throw an error
    verifier =
        MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy, this.getOverridableFile("settings.xml"));
    verifier.verifyErrorFreeLog();

    // check the services url too, ( just the GET for now )
    // just check the parent dir, incase this is a SNAPSHOT repo
    Response response =
        RequestFacade.sendMessage(new URL(
View Full Code Here


  private void deployWithMavenExpectSuccess(File mavenProject, String targetRepoId)
      throws VerificationException, IOException
  {
    // deploy using maven
    Verifier verifier = mavenVerifierHelper.createMavenVerifier(mavenProject, getOverridableFile("settings.xml"), getTestId());
    try {
      verifier.setSystemProperty("altDeploymentRepository", "repo::default::" + createUrl(targetRepoId));
      verifier.executeGoal("deploy");
      verifier.verifyErrorFreeLog();
    }

    catch (VerificationException e) {
      File logs = new File(nexusLogDir);
      File bkp = new File("./target/logs/nexus2351-bkp");
View Full Code Here

  private void deployWithMavenExpectFailure(File mavenProject, String targetRepoId)
      throws VerificationException, IOException
  {
    // deploy using maven
    Verifier verifier = mavenVerifierHelper.createMavenVerifier(mavenProject, getOverridableFile("settings.xml"), getTestId());
    try {
      verifier.setSystemProperty("altDeploymentRepository", "repo::default::" + createUrl(targetRepoId));
      verifier.executeGoal("deploy");

      verifier.verifyErrorFreeLog();

      Assert.fail("Should return 401 error");
    }
    catch (VerificationException e) {
      // expect error
View Full Code Here

  public void testIt(Gav gav)
      throws VerificationException, IOException, Exception
  {
    final File file = getTestFile("artifact.jar");
    Verifier v =
        MavenDeployer.deployAndGetVerifier(gav, getRepositoryUrl(REPO_TEST_HARNESS_REPO), file,
            getOverridableFile("settings.xml"));
    v.verifyErrorFreeLog();

    getEventInspectorsUtil().waitForCalmPeriod();
    TaskScheduleUtil.waitForAllTasksToStop();

    // direct download
View Full Code Here

    private void doExecute(ProcessorTestCase child, Description description) throws Exception {
        File destination = extractTest( child, description );
        PrintStream originalOut = System.out;

        final Verifier verifier;
        if ( Boolean.getBoolean( SYS_PROP_DEBUG ) ) {
            if ( child.processor.getToolchain() == null ) {
                // when not using toolchains for a test, then the compiler is executed within the Maven JVM. So make
                // sure we fork a new JVM for that, and let that new JVM use the command 'mvnDebug' instead of 'mvn'
                verifier = new Verifier( destination.getCanonicalPath(), null, true, true );
                verifier.setDebugJvm( true );
            }
            else {
                verifier = new Verifier( destination.getCanonicalPath() );
                verifier.addCliOption( "-Pdebug-forked-javac" );
            }
        }
        else {
            verifier = new Verifier( destination.getCanonicalPath() );
        }

        List<String> goals = new ArrayList<String>( 3 );

        goals.add( "clean" );

        try {
            configureToolchains( child, verifier, goals, originalOut );
            configureProcessor( child, verifier );

            verifier.addCliOption( "-Dcompiler-source-target-version=" + child.processor.getSourceTargetVersion() );

            if ( "1.8".equals( child.processor.getSourceTargetVersion() ) ) {
                verifier.addCliOption( "-Dmapstruct-artifact-id=mapstruct-jdk8" );
            }
            else {
                verifier.addCliOption( "-Dmapstruct-artifact-id=mapstruct" );
            }

            if ( Boolean.getBoolean( SYS_PROP_DEBUG ) ) {
                originalOut.print( "Processor Integration Test: " );
                originalOut.println( "Listening for transport dt_socket at address: 8000 (in some seconds)" );
            }

            goals.add( "test" );

            originalOut.println( "executing " + child.processor.name().toLowerCase() );

            verifier.executeGoals( goals );
            verifier.verifyErrorFreeLog();
        }
        finally {
            verifier.resetStreams();
        }
    }
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().indexOf( "Exit code was non-zero" ) == -1 )
            {
                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

    public OutputValidator getSubProjectValidator( String subProject )
        throws VerificationException
    {
        final File subFile = getValidator().getSubFile( subProject );
        return new OutputValidator( new Verifier( subFile.getAbsolutePath() ) );
    }
View Full Code Here

    {
        if ( verifier == null )
        {
            try
            {
                this.verifier = new Verifier( ensureUnpacked().getAbsolutePath() );
            }
            catch ( VerificationException e )
            {
                throw new RuntimeException( e );
            }
View Full Code Here

    protected abstract void addArchetypeData(Properties properties);

    @Test
    public void testArchetype_shouldSucceed() throws VerificationException {
        // generates a test project for the given archetype
        Verifier verifier = new Verifier(TEST_ROOT.getAbsolutePath(), getMavenSettings());

        verifier.setSystemProperties(systemProperties);
        verifier.setAutoclean(false);
        verifier.executeGoal("archetype:generate");
        verifier.verifyErrorFreeLog();

        // calls method to apply certain changes to the generated
        // project (changing imports, etc)
        try {
            applyProjectModifications();
        } catch (Exception e) {
            throw new VerificationException("Error applying project modifications", e);
        }

        // attempts to perform 'mvn compile' on the generated
        // archetype to verify it's working without errors
        verifier = new Verifier(
            TEST_ROOT.getAbsolutePath()
                    + File.separator
                    + systemProperties.getProperty("artifactId", DEFAULT_TEST_ARTIFACT_ID), getMavenSettings());

        verifier.setAutoclean(false);
        verifier.executeGoal("compile");
        verifier.verifyErrorFreeLog();
    }
View Full Code Here

        addArchetypeData(systemProperties);

        // need to make sure old test artifacts that have been
        // created are being deleted since this can lead to
        // unstable test behavior
        Verifier verifier = new Verifier(TEST_ROOT.getAbsolutePath(), getMavenSettings());

        verifier.deleteArtifact(
            systemProperties.getProperty("groupId", DEFAULT_TEST_GROUP_ID),
            systemProperties.getProperty("artifactId", DEFAULT_TEST_ARTIFACT_ID),
            systemProperties.getProperty("version", DEFAULT_TEST_VERSION),
            null);
        verifier.deleteDirectory(systemProperties.getProperty("artifactId", DEFAULT_TEST_ARTIFACT_ID));
    }
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.