Skip to content

Commit

Permalink
Use org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPS…
Browse files Browse the repository at this point in the history
…HOT:eval instead of m-help-p
  • Loading branch information
gnodet committed Sep 30, 2024
1 parent 950800a commit e6ddb82
Showing 1 changed file with 46 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.File;
import java.util.List;
import java.util.Objects;
import java.util.Properties;

import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
Expand All @@ -31,6 +32,9 @@
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8230">MNG-8230</a>.
*/
class MavenITmng8230CIFriendlyTest extends AbstractMavenIntegrationTestCase {

private static final String PROPERTIES = "target/expression.properties";

MavenITmng8230CIFriendlyTest() {
super("[4.0.0-beta-5,)");
}
Expand All @@ -44,12 +48,16 @@ class MavenITmng8230CIFriendlyTest extends AbstractMavenIntegrationTestCase {
void testitCiFriendlyWithProjectProperties() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8230-ci-friendly-and-gav");

Verifier verifier = newVerifier(new File(testDir, "cif-with-project-props").getAbsolutePath());
verifier.addCliArguments(
"org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", "-Dexpression=project.version");
File basedir = new File(testDir, "cif-with-project-props");
Verifier verifier = newVerifier(basedir.getAbsolutePath());
verifier.addCliArgument("-Dexpression.outputFile=" + new File(basedir, PROPERTIES).getPath());
verifier.addCliArgument("-Dexpression.expressions=project/version");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
verifier.execute();
verifier.verifyErrorFreeLog();
verifyExactLine(verifier, "1.0-SNAPSHOT");
verifier.verifyFilePresent(PROPERTIES);
Properties props = verifier.loadProperties(PROPERTIES);
assertEquals(props.getProperty("project.version"), "1.0-SNAPSHOT");
}

/**
Expand All @@ -61,14 +69,17 @@ void testitCiFriendlyWithProjectProperties() throws Exception {
void testitCiFriendlyWithProjectPropertiesOverride() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8230-ci-friendly-and-gav");

Verifier verifier = newVerifier(new File(testDir, "cif-with-project-props").getAbsolutePath());
verifier.addCliArguments(
"org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate",
"-Dexpression=project.version",
"-Dci-version=1.1-SNAPSHOT");
File basedir = new File(testDir, "cif-with-project-props");
Verifier verifier = newVerifier(basedir.getAbsolutePath());
verifier.addCliArgument("-Dexpression.outputFile=" + new File(basedir, PROPERTIES).getPath());
verifier.addCliArgument("-Dexpression.expressions=project/version");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
verifier.addCliArgument("-Dci-version=1.1-SNAPSHOT");
verifier.execute();
verifier.verifyErrorFreeLog();
verifyExactLine(verifier, "1.1-SNAPSHOT");
verifier.verifyFilePresent(PROPERTIES);
Properties props = verifier.loadProperties(PROPERTIES);
assertEquals(props.getProperty("project.version"), "1.1-SNAPSHOT");
}

/**
Expand All @@ -80,14 +91,18 @@ void testitCiFriendlyWithProjectPropertiesOverride() throws Exception {
void testitCiFriendlyWithUserProperties() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8230-ci-friendly-and-gav");

Verifier verifier = newVerifier(new File(testDir, "cif-with-user-props").getAbsolutePath());
verifier.addCliArguments(
"org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate",
"-Dexpression=project.version",
"-Dci-version=1.1-SNAPSHOT");
File basedir = new File(testDir, "cif-with-user-props");
Verifier verifier = newVerifier(basedir.getAbsolutePath());

verifier.addCliArgument("-Dexpression.outputFile=" + new File(basedir, PROPERTIES).getPath());
verifier.addCliArgument("-Dexpression.expressions=project/version");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
verifier.addCliArgument("-Dci-version=1.1-SNAPSHOT");
verifier.execute();
verifier.verifyErrorFreeLog();
verifyExactLine(verifier, "1.1-SNAPSHOT");
verifier.verifyFilePresent(PROPERTIES);
Properties props = verifier.loadProperties(PROPERTIES);
assertEquals(props.getProperty("project.version"), "1.1-SNAPSHOT");
}

/**
Expand All @@ -99,9 +114,11 @@ void testitCiFriendlyWithUserProperties() throws Exception {
void testitCiFriendlyWithUserPropertiesNotGiven() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8230-ci-friendly-and-gav");

Verifier verifier = newVerifier(new File(testDir, "cif-with-user-props").getAbsolutePath());
verifier.addCliArguments(
"org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", "-Dexpression=project.version");
File basedir = new File(testDir, "cif-with-user-props");
Verifier verifier = newVerifier(basedir.getAbsolutePath());
verifier.addCliArgument("-Dexpression.outputFile=" + new File(basedir, PROPERTIES).getPath());
verifier.addCliArgument("-Dexpression.expressions=project/version");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
try {
verifier.execute();
fail("Expected failure");
Expand All @@ -118,8 +135,11 @@ void testitCiFriendlyWithUserPropertiesNotGiven() throws Exception {
void testitExpressionInGroupId() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8230-ci-friendly-and-gav");

Verifier verifier = newVerifier(new File(testDir, "exp-in-groupid").getAbsolutePath());
verifier.addCliArguments("validate");
File basedir = new File(testDir, "exp-in-groupid");
Verifier verifier = newVerifier(basedir.getAbsolutePath());
verifier.addCliArgument("-Dexpression.outputFile=" + new File(basedir, PROPERTIES).getPath());
verifier.addCliArgument("-Dexpression.expressions=project/version");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
try {
verifier.execute();
fail("Expected failure");
Expand All @@ -136,8 +156,11 @@ void testitExpressionInGroupId() throws Exception {
void testitExpressionInArtifactId() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8230-ci-friendly-and-gav");

Verifier verifier = newVerifier(new File(testDir, "exp-in-artifactid").getAbsolutePath());
verifier.addCliArguments("validate");
File basedir = new File(testDir, "exp-in-artifactid");
Verifier verifier = newVerifier(basedir.getAbsolutePath());
verifier.addCliArgument("-Dexpression.outputFile=" + new File(basedir, PROPERTIES).getPath());
verifier.addCliArgument("-Dexpression.expressions=project/version");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
try {
verifier.execute();
fail("Expected failure");
Expand Down

0 comments on commit e6ddb82

Please sign in to comment.