Java Code Examples for org.apache.maven.it.Verifier#executeGoal()

The following examples show how to use org.apache.maven.it.Verifier#executeGoal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XtendCompilerMojoIT.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void readXtendPrefs() throws Exception {
	Verifier verifier = MavenVerifierUtil.newVerifier(ROOT + "/xtend-prefs");
	verifier.setDebug(true);
	verifier.executeGoal("test");
	verifier.verifyErrorFreeLog();
	String xtendOutputDirFromPrefs = "generated-sources/xtend-from-pref";

	String xtendGenDir = verifier.getBasedir() + "/src/main/" + xtendOutputDirFromPrefs;
	verifier.assertFilePresent(xtendGenDir + "/test/XtendA.java");
	verifier.assertFilePresent(xtendGenDir + "/test/XtendC.java");

	String xtendTestGenDir = verifier.getBasedir() + "/src/test/" + xtendOutputDirFromPrefs;
	verifier.assertFilePresent(xtendTestGenDir + "/tests/XtendA.java");
	verifier.assertFilePresent(xtendTestGenDir + "/tests/XtendC.java");
}
 
Example 2
Source File: DevelopBranchIT.java    From gitflow-helper-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Attaching existing artifacts from the develop branch should pass.
 *
 * @throws Exception
 */
@Test
public void attachExistingArtifacts() throws Exception {
	Verifier verifier = createVerifier("/project-stub", "origin/develop", "1.0.0-SNAPSHOT");

	try {
		verifier.executeGoal("deploy");

		verifier.verifyErrorFreeLog();
	} finally {
		verifier.resetStreams();
	}


	// New verifier to attach existing artifacts
	verifier = createVerifier("/project-stub", "origin/develop", "1.0.0-SNAPSHOT");

	try {
		verifier.executeGoal("gitflow-helper:attach-deployed");

		verifier.verifyErrorFreeLog();
	} finally {
		verifier.resetStreams();
	}
}
 
Example 3
Source File: RetargetDeployIT.java    From gitflow-helper-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void devTargetsSnapshot() throws Exception {
	Verifier verifier = createVerifier("/project-stub", "origin/develop", "3.0.0-SNAPSHOT");

	try {
		verifier.executeGoal("deploy");

		verifier.verifyErrorFreeLog();
	} finally {
		verifier.resetStreams();
	}

	// Ensure the file exists in the repo.
	File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/snapshots/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.0.0-SNAPSHOT");
	Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0);
}
 
Example 4
Source File: DeployMojoIntegrationTest.java    From app-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployStandard()
    throws IOException, VerificationException, CloudSdkNotFoundException,
        ProcessHandlerException {

  Verifier verifier = new StandardVerifier("testDeployStandard");

  // execute with staging directory not present
  verifier.executeGoal("package");
  verifier.executeGoal("appengine:deploy");

  // verify
  verifier.verifyErrorFreeLog();
  verifier.verifyTextInLog("Detected App Engine standard environment application");
  verifier.verifyTextInLog("GCLOUD: Deployed service");

  // cleanup
  deleteService("standard-project");
}
 
Example 5
Source File: StopMojoIntegrationTest.java    From app-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testStopStandard() throws IOException, VerificationException, InterruptedException {

  Verifier verifier = new StandardVerifier("testStopStandard_start");

  verifier.setSystemProperty("app.devserver.port", Integer.toString(serverPort));

  // start dev app server
  verifier.executeGoals(Arrays.asList("package", "appengine:start"));

  // verify dev app server is up
  verifier.verifyErrorFreeLog();
  assertNotNull(UrlUtils.getUrlContentWithRetries(getServerUrl(), 60000, 100));

  // stop dev app server
  verifier.setLogFileName("testStopStandard.txt");
  verifier.setAutoclean(false);
  verifier.executeGoal("appengine:stop");

  // verify dev app server is down
  verifier.verifyErrorFreeLog();
  // wait up to 5 seconds for the server to stop
  assertTrue(UrlUtils.isUrlDownWithRetries(getServerUrl(), 5000, 100));
}
 
Example 6
Source File: GitVersioningExtensionIT.java    From maven-git-versioning-extension with MIT License 6 votes vote down vote up
@Test
void outsideGitVersioning() throws Exception {
    // Given

    writeModel(projectDir.resolve("pom.xml").toFile(), pomModel);
    writeExtensionsFile(projectDir);
    writeExtensionConfigFile(projectDir, new Configuration());

    // When
    Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath());
    verifier.executeGoal("verify");

    // Then
    String log = getLog(verifier);
    assertThat(log).doesNotContain("[ERROR]", "[FATAL]");
    String expectedVersion = "0.0.0";
    assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion);

    assertThat(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile().exists()).isEqualTo(false);
    assertThat(log).contains("[WARNING] skip - project is not part of a git repository");
}
 
Example 7
Source File: XtendCompilerMojoIT.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void haltOnXtendValidationErrors() throws Exception {
	Verifier verifier = MavenVerifierUtil.newVerifier(ROOT + "/xtenderrors");
	try {
		verifier.executeGoal("verify");
		Assert.fail("expected org.apache.maven.plugin.MojoExecutionException");
	} catch (Exception e) {
		verifier.verifyTextInLog("3: Superclass must be a class");
		verifier.verifyTextInLog("BUILD FAILURE");
	}
}
 
Example 8
Source File: EnforceVersionsIT.java    From gitflow-helper-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void featureAllowsNonSnapshot() throws Exception {
	Verifier verifier = createVerifier("/project-stub", "origin/feature/aFeatureBranch", "1.0.0");

	try {
		verifier.executeGoal("gitflow-helper:enforce-versions");
		verifier.verifyErrorFreeLog();
	} finally {
		verifier.resetStreams();
	}
}
 
Example 9
Source File: OtherBranchIT.java    From gitflow-helper-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void noOtherDeployMatch() throws Exception {
	Verifier verifier = createVerifier("/project-stub", "origin/feature/my-feature-branch", "5.0.1-SNAPSHOT");
	try {
		verifier.executeGoal("deploy");

		verifier.verifyTextInLog("Un-Setting artifact repositories.");
		verifier.verifyErrorFreeLog();
	} finally {
		verifier.resetStreams();
	}
}
 
Example 10
Source File: GitVersioningExtensionIT.java    From maven-git-versioning-extension with MIT License 5 votes vote down vote up
@Test
void tagVersioning_cliOption_gitTag() throws Exception {
    // Given
    Git git = Git.init().setDirectory(projectDir.toFile()).call();
    RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
    String givenTag = "v1";

    writeModel(projectDir.resolve("pom.xml").toFile(), pomModel);
    writeExtensionsFile(projectDir);

    Configuration extensionConfig = new Configuration();
    extensionConfig.tag.add(createTagVersionDescription());
    writeExtensionConfigFile(projectDir, extensionConfig);

    // When
    Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath());
    verifier.addCliOption("-Dgit.tag=" + givenTag);
    verifier.executeGoal("verify");

    // Then
    String log = getLog(verifier);
    assertThat(log).doesNotContain("[ERROR]", "[FATAL]");
    String expectedVersion = givenTag + "-gitVersioning";
    assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion);
    Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile());
    assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> {
        softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion());
        softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId());
        softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId());
        softly.assertThat(it.getVersion()).isEqualTo(expectedVersion);
        softly.assertThat(it.getProperties()).doesNotContainKeys(
                "git.commit",
                "git.ref",
                "git.tag"
        );
    }));
}
 
Example 11
Source File: EnforceVersionsIT.java    From gitflow-helper-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test(expected=VerificationException.class)
public void pluginSnapshotFail() throws Exception {
	// Stage the repository with version 1.0.0 of the stub.

	// Create a release version and get it deployed.
	Verifier verifier = createVerifier("/project-stub", "origin/release/1.0.0", "1.0.0");
	try {
		verifier.executeGoal("deploy");

		verifier.verifyErrorFreeLog();
	} finally {
		verifier.resetStreams();
	}

	// Promote (deploy) from /origin/master
	verifier = createVerifier("/project-stub", "origin/master", "1.0.0");
	try {
		verifier.executeGoal("deploy");

		verifier.verifyErrorFreeLog();
	} finally {
		verifier.resetStreams();
	}

	// Build a project that depends upon the upstream project.
	verifier = createVerifier("/project-alt1-stub", "origin/release/1.0.0", "1.0.0");
	verifier.getCliOptions().add("-Ddependency.stub.version=1.0.0");
	verifier.getCliOptions().add("-Dplugin.stub.version=1.0.0-SNAPSHOT");

	try {
		verifier.executeGoal("deploy");
	} finally {
		verifier.resetStreams();
	}
}
 
Example 12
Source File: MasterSupportBranchIT.java    From gitflow-helper-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void releaseVersionSuccess() throws Exception {
	Verifier verifier = createVerifier("/project-stub", "origin/master", "1.0.0");

	try {
		verifier.executeGoal("gitflow-helper:enforce-versions");

		verifier.verifyErrorFreeLog();
		verifier.verifyTextInLog("GitBranchInfo:");
	} finally {
		verifier.resetStreams();
	}
}
 
Example 13
Source File: XtendCompilerMojoIT.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void emptyDirWarningDefault() throws Exception {
	Verifier verifier = MavenVerifierUtil.newVerifier(ROOT + "/emptydir-warning-default");
	verifier.setDebug(true);
	verifier.executeGoal("test");
	verifier.verifyErrorFreeLog();
	verifier.verifyTextInLog("is empty. Can't process.");
}
 
Example 14
Source File: DownstreamParentTest.java    From brooklyn-library with Apache License 2.0 5 votes vote down vote up
/**
 * Asserts that a trivial project using brooklyn-downstream-parent can be
 * loaded into Brooklyn's catalogue and its entities deployed.
 */
@Test(groups = "Integration")
public void testDownstreamProjectsCanBeLoadedIntoBrooklynCatalogByDefault() throws Exception {
    int port = Networking.nextAvailablePort(57000);
    File dir = getBasedir("downstream-parent-test");
    Verifier verifier = new Verifier(dir.getAbsolutePath());
    verifier.setMavenDebug(true);
    verifier.executeGoal("post-integration-test", ImmutableMap.of(
            "bindPort", String.valueOf(port)));
    verifier.verifyErrorFreeLog();
    verifier.verifyTextInLog("Hello from the init method of the HelloEntity");
}
 
Example 15
Source File: VertxMojoTestBase.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
void runPackage(Verifier verifier) throws VerificationException {
    verifier.setLogFileName("build-package.log");
    verifier.executeGoal("package", getEnv());

    verifier.assertFilePresent("target/vertx-demo-start-0.0.1.BUILD-SNAPSHOT.jar");
    verifier.resetStreams();
}
 
Example 16
Source File: EnforceVersionsIT.java    From gitflow-helper-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test(expected = VerificationException.class)
public void versionStartswithMismatch() throws Exception {
	Verifier verifier = createVerifier("/project-stub", "origin/release/1.2", "1.3.0");
	verifier.getCliOptions().add("-DreleaseBranchMatchType=startsWith");

	try {
		verifier.executeGoal("gitflow-helper:enforce-versions");
	} finally {
		verifier.resetStreams();
	}
}
 
Example 17
Source File: GitVersioningExtensionIT.java    From maven-git-versioning-extension with MIT License 5 votes vote down vote up
@Test
void tagVersioning_nonAnnotatedTagNotDetached() throws Exception {
    // Given
    Git git = Git.init().setDirectory(projectDir.toFile()).call();
    RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
    String givenTag = "v1";

    git.tag().setAnnotated(false).setName(givenTag).call();

    writeModel(projectDir.resolve("pom.xml").toFile(), pomModel);
    writeExtensionsFile(projectDir);

    Configuration extensionConfig = new Configuration();
    extensionConfig.preferTags = true;
    extensionConfig.branch.add(createBranchVersionDescription());
    extensionConfig.tag.add(createTagVersionDescription());
    writeExtensionConfigFile(projectDir, extensionConfig);

    // When
    Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath());
    verifier.executeGoal("verify");

    // Then
    String log = getLog(verifier);
    assertThat(log).doesNotContain("[ERROR]", "[FATAL]");
    String expectedVersion = givenTag + "-gitVersioning";
    assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion);
    Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile());
    assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> {
        softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion());
        softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId());
        softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId());
        softly.assertThat(it.getVersion()).isEqualTo(expectedVersion);
        softly.assertThat(it.getProperties()).doesNotContainKeys(
                "git.commit",
                "git.ref",
                "git.tag"
        );
    }));
}
 
Example 18
Source File: GitVersioningExtensionIT.java    From maven-git-versioning-extension with MIT License 4 votes vote down vote up
@Test
void tagVersioning_cliOption_preferTags_false() throws Exception {
    // Given
    Git git = Git.init().setDirectory(projectDir.toFile()).call();
    RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
    String givenTag = "v1";

    git.tag().setAnnotated(false).setName(givenTag).call();

    writeModel(projectDir.resolve("pom.xml").toFile(), pomModel);
    writeExtensionsFile(projectDir);

    Configuration extensionConfig = new Configuration();
    extensionConfig.branch.add(createBranchVersionDescription());
    extensionConfig.tag.add(createTagVersionDescription());
    extensionConfig.preferTags = true;
    writeExtensionConfigFile(projectDir, extensionConfig);

    // When
    Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath());
    verifier.addCliOption("-Dversioning.preferTags=false");
    verifier.executeGoal("verify");

    // Then
    String log = getLog(verifier);
    assertThat(log).doesNotContain("[ERROR]", "[FATAL]");
    String expectedVersion = "master-gitVersioning";
    assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion);
    Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile());
    assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> {
        softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion());
        softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId());
        softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId());
        softly.assertThat(it.getVersion()).isEqualTo(expectedVersion);
        softly.assertThat(it.getProperties()).doesNotContainKeys(
                "git.commit",
                "git.ref",
                "git.tag"
        );
    }));
}
 
Example 19
Source File: GitVersioningExtensionIT.java    From maven-git-versioning-extension with MIT License 4 votes vote down vote up
@Test
void branchVersioning_multiModuleProject_withAggregationAndParent() throws Exception {
    // Given

    try (Git git = Git.init().setDirectory(projectDir.toFile()).call()) {
        RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call();
        String givenBranch = "feature/test";
        git.branchCreate().setName(givenBranch).call();
        git.checkout().setName(givenBranch).call();

        pomModel.setPackaging("pom");
        pomModel.addModule("parent");

        writeModel(projectDir.resolve("pom.xml").toFile(), pomModel);
        writeExtensionsFile(projectDir);

        Configuration extensionConfig = new Configuration();
        extensionConfig.branch.add(createBranchVersionDescription());
        writeExtensionConfigFile(projectDir, extensionConfig);

        final Path parentProjectDir = Files.createDirectories(projectDir.resolve("parent"));
        Model parentPomModel = writeModel(parentProjectDir.resolve("pom.xml").toFile(), new Model() {{
            setModelVersion(pomModel.getModelVersion());
            setGroupId(pomModel.getGroupId());
            setArtifactId("parent");
            setVersion(pomModel.getVersion());

            setPackaging("pom");
            addModule("../logic");
        }});

        final Path logicProjectDir = Files.createDirectories(projectDir.resolve("logic"));
        Model logicPomModel = writeModel(logicProjectDir.resolve("pom.xml").toFile(), new Model() {{
            setModelVersion(parentPomModel.getModelVersion());
            setParent(new Parent() {{
                setGroupId(parentPomModel.getGroupId());
                setArtifactId(parentPomModel.getArtifactId());
                setVersion(parentPomModel.getVersion());
                setRelativePath("../parent");
            }});
            setArtifactId("logic");
            setVersion(parentPomModel.getVersion());
        }});

        // When
        Verifier installVerifier = new Verifier(projectDir.toFile().getAbsolutePath());
        installVerifier.executeGoal("install");

        Verifier verifier = new Verifier(logicProjectDir.toFile().getAbsolutePath());
        verifier.executeGoal("verify");

        // Then
        assertThat(getLog(installVerifier)).doesNotContain("[ERROR]", "[FATAL]");
        assertThat(getLog(verifier)).doesNotContain("[ERROR]", "[FATAL]");
        String expectedVersion = givenBranch.replace("/", "-") + "-gitVersioning";
        //        assertThat(log).contains("Building " + logicPomModel.getArtifactId() + " " + expectedVersion);
        Model gitVersionedLogicPomModel = readModel(logicProjectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile());
        assertThat(gitVersionedLogicPomModel).satisfies(it -> assertSoftly(softly -> {
            softly.assertThat(it.getModelVersion()).isEqualTo(logicPomModel.getModelVersion());
            softly.assertThat(it.getGroupId()).isEqualTo(logicPomModel.getGroupId());
            softly.assertThat(it.getArtifactId()).isEqualTo(logicPomModel.getArtifactId());
            softly.assertThat(it.getVersion()).isEqualTo(expectedVersion);
            softly.assertThat(it.getProperties()).doesNotContainKeys(
                    "git.commit",
                    "git.ref"
            );
        }));
    }
}
 
Example 20
Source File: StartStopMojoIT.java    From vertx-maven-plugin with Apache License 2.0 4 votes vote down vote up
private void runStart(Verifier verifier) throws VerificationException, IOException {
    verifier.setLogFileName("build-start.log");
    verifier.executeGoal("vertx:start", getEnv());
    assertInLog(verifier, "BUILD SUCCESS", "Starting vert.x application...");
    verifier.resetStreams();
}