Search in sources :

Example 1 with VerificationException

use of org.apache.maven.it.VerificationException in project maven-plugins by apache.

the class IT_BadDependencyPoms method test.

public void test() throws IOException, URISyntaxException, VerificationException {
    File dir = TestUtils.getTestDir("bad-dependency-poms");
    Verifier verifier;
    verifier = new Verifier(dir.getAbsolutePath());
    verifier.deleteArtifacts("test");
    verifier.getSystemProperties().setProperty("it.dir", dir.getAbsolutePath());
    try {
        verifier.executeGoal("generate-resources");
    } catch (VerificationException e) {
        verifier.resetStreams();
        // We will get an exception from harness in case
        // of execution failure (return code non zero).
        // This is the case if we have missing artifacts
        // as in this test case.
        // This means we can't test the created file which will never
        // contain the appropriate data we wan't to check for. 
        // So the only reliable way is to check the log output 
        // from maven which will print out message according to
        // the missing artifacts.
        File output = new File(dir, "log.txt");
        String content = FileUtils.fileRead(output);
        assertTrue(content.contains("mvn install:install-file -DgroupId=test -DartifactId=pom -Dversion=0.2 -Dpackaging=jar"));
        assertTrue(content.contains("mvn install:install-file -DgroupId=test -DartifactId=missing -Dversion=0.1 -Dpackaging=jar"));
        assertTrue(content.contains("mvn install:install-file -DgroupId=test -DartifactId=invalid -Dversion=0.1 -Dpackaging=jar"));
    }
}
Also used : VerificationException(org.apache.maven.it.VerificationException) Verifier(org.apache.maven.it.Verifier) File(java.io.File)

Example 2 with VerificationException

use of org.apache.maven.it.VerificationException in project maven-plugins by apache.

the class AbstractEarPluginIT method executeMojo.

/**
     * Execute the EAR plugin for the specified project.
     * 
     * @param projectName the name of the project
     * @param properties extra properties to be used by the embedder
     * @return the base directory of the project
     * @throws Exception if an error occurred
     */
@SuppressWarnings("unchecked")
protected File executeMojo(final String projectName, final Properties properties, boolean expectNoError) 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;
}
Also used : VerificationException(org.apache.maven.it.VerificationException) Verifier(org.apache.maven.it.Verifier) File(java.io.File)

Example 3 with VerificationException

use of org.apache.maven.it.VerificationException in project maven-plugins by apache.

the class IT_GetDependencyProjects method test.

public void test() throws IOException, URISyntaxException, VerificationException {
    File dir = TestUtils.getTestDir("get-dependency-projects");
    Verifier verifier;
    verifier = new Verifier(dir.getAbsolutePath());
    verifier.executeGoal("deploy");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();
    verifier = new Verifier(new File(dir, "project").getAbsolutePath());
    verifier.deleteArtifacts("org.apache.maven.plugin.rresource.it.gdp");
    try {
        verifier.executeGoal("generate-resources");
    } catch (VerificationException e) {
        verifier.resetStreams();
        // We will get an exception from harness in case
        // of execution failure (return code non zero).
        // This is the case if we have missing artifacts
        // as in this test case.
        // This means we can't test the created file which will never
        // contain the appropriate data we wan't to check for. 
        // So the only reliable way is to check the log output 
        // from maven which will print out message according to
        // the missing artifacts.
        File output = new File(verifier.getBasedir(), "log.txt");
        String content = FileUtils.fileRead(output);
        assertTrue(content.contains("mvn install:install-file -DgroupId=org.apache.maven.plugin.rresource.it.gdp -DartifactId=release -Dversion=1.0 -Dpackaging=jar"));
        assertTrue(content.contains("mvn install:install-file -DgroupId=org.apache.maven.plugin.rresource.it.gdp -DartifactId=snapshot -Dversion=1.0-SNAPSHOT -Dpackaging=jar"));
    }
}
Also used : VerificationException(org.apache.maven.it.VerificationException) Verifier(org.apache.maven.it.Verifier) File(java.io.File)

Example 4 with VerificationException

use of org.apache.maven.it.VerificationException in project maven-plugins by apache.

the class BundleCreateIT method createWithSCMInfoMissing.

@SuppressWarnings("unchecked")
@Test
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();
    }
}
Also used : VerificationException(org.apache.maven.it.VerificationException) Verifier(org.apache.maven.it.Verifier) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)4 VerificationException (org.apache.maven.it.VerificationException)4 Verifier (org.apache.maven.it.Verifier)4 Test (org.junit.Test)1