Search in sources :

Example 1 with Verifier

use of org.apache.maven.it.Verifier in project liquibase by liquibase.

the class MavenIntegrationTest method createVerifier.

//    @Before
//    public void cleanDatabase() throws Exception {
//         DatabaseConnection connection = DatabaseTestContext.getInstance().getConnection(URL);
//         assertNotNull(connection);
//         Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);
//         database.dropDatabaseObjects(CatalogAndSchema.DEFAULT);
//         database.close();
//         DatabaseFactory.reset();
//    }
//
//    @Test
//    public void testUpdate() throws Exception{
//        Verifier verifier=createVerifier();
//
//        verifier.executeGoal( "clean" );
//        verifier.executeGoal( "install" );
//
//        //Verify everithing has gone well.
//        verifier.verifyErrorFreeLog();
//
//        //Reset the streams before executing the verifier
//        verifier.resetStreams();
//    }
//
//    @Test
//    public void testRollbackTag() throws Exception {
//        Verifier verifier= createVerifier();
//
//
//        verifier.executeGoal("clean");
//        verifier.executeGoal("liquibase:tag");
//        verifier.executeGoal("package"); //runs update that is bound to test phase
//        verifier.executeGoal("liquibase:rollback");
//        //If we can reupdate rollback has succeded
//        verifier.executeGoal("liquibase:update");
//
//        //Verify everithing has gone well.
//        verifier.verifyErrorFreeLog();
//
//        //Reset the streams before executing the verifier
//        verifier.resetStreams();
//    }
private Verifier createVerifier() throws IOException, VerificationException {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/maven");
    //Clear any artifact created by the test project to avoid unstable test results
    Verifier verifier = new Verifier(testDir.getAbsolutePath());
    //Don't do clean automatically in each executeGoal
    verifier.setAutoclean(false);
    verifier.deleteArtifact("org.liquibase", "liquibase-maven-integration-tests", "1.0-SNAPSHOT", "jar");
    return verifier;
}
Also used : Verifier(org.apache.maven.it.Verifier) File(java.io.File)

Example 2 with Verifier

use of org.apache.maven.it.Verifier 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 3 with Verifier

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

the class IT_GenerateFromBundle method test.

public void test() throws IOException, URISyntaxException, VerificationException {
    File dir = TestUtils.getTestDir("generate-from-bundle");
    Verifier verifier = new Verifier(dir.getAbsolutePath());
    verifier.executeGoal("generate-resources");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();
    File output = new File(dir, "target/maven-shared-archive-resources/DEPENDENCIES");
    String content = FileUtils.fileRead(output);
    assertTrue(content.contains("Built-In:"));
}
Also used : Verifier(org.apache.maven.it.Verifier) File(java.io.File)

Example 4 with Verifier

use of org.apache.maven.it.Verifier 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 5 with Verifier

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

the class BundleCreateIT method createFromAlternativePom.

@SuppressWarnings("unchecked")
@Test
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");
    requiredEntries.add("test-1.0.jar");
    requiredEntries.add("test-1.0-sources.jar");
    assertZipContents(requiredEntries, Assertions.EMPTY_ENTRY_NAMES, bundleSource);
}
Also used : Verifier(org.apache.maven.it.Verifier) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Verifier (org.apache.maven.it.Verifier)39 Test (org.junit.Test)21 File (java.io.File)20 VerificationException (org.apache.maven.it.VerificationException)5 HashSet (java.util.HashSet)4 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 BeforeClass (org.junit.BeforeClass)1