From b44ce2effda637368e8af12fba4641253539dadf Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 30 Sep 2024 13:42:03 +0200 Subject: [PATCH 1/4] [MNG-8230] Add tests for CI-friendly versions --- .../it/MavenITmng8230CIFriendlyTest.java | 152 ++++++++++++++++++ .../apache/maven/it/TestSuiteOrdering.java | 1 + .../cif-with-project-props/child/pom.xml | 6 + .../cif-with-project-props/pom.xml | 13 ++ .../cif-with-user-props/child/pom.xml | 6 + .../cif-with-user-props/pom.xml | 9 ++ .../exp-in-artifactid/pom.xml | 8 + .../exp-in-groupid/pom.xml | 8 + 8 files changed, 203 insertions(+) create mode 100644 core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java create mode 100644 core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-project-props/child/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-project-props/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-user-props/child/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-user-props/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/exp-in-artifactid/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/exp-in-groupid/pom.xml diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java new file mode 100644 index 000000000..980eb3a9c --- /dev/null +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.it; + +import java.io.File; +import java.util.List; +import java.util.Objects; + +import org.apache.maven.shared.verifier.VerificationException; +import org.apache.maven.shared.verifier.Verifier; +import org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.junit.jupiter.api.Test; + +/** + * This is a test set for MNG-8230. + */ +class MavenITmng8230CIFriendlyTest extends AbstractMavenIntegrationTestCase { + MavenITmng8230CIFriendlyTest() { + super("[4.0.0-beta-5,)"); + } + + /** + * Verify that CI friendly version work when using project properties + * + * @throws Exception in case of failure + */ + @Test + 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("help:evaluate", "-Dexpression=project.version"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + verifyExactLine(verifier, "1.0-SNAPSHOT"); + } + + /** + * Verify that CI friendly version work when using project properties + * + * @throws Exception in case of failure + */ + @Test + 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("help:evaluate", "-Dexpression=project.version", "-Dci-version=1.1-SNAPSHOT"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + verifyExactLine(verifier, "1.1-SNAPSHOT"); + } + + /** + * Verify that CI friendly version work when using user properties + * + * @throws Exception in case of failure + */ + @Test + 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("help:evaluate", "-Dexpression=project.version", "-Dci-version=1.1-SNAPSHOT"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + verifyExactLine(verifier, "1.1-SNAPSHOT"); + } + + /** + * Verify that CI friendly version fails if the properties are not given + * + * @throws Exception in case of failure + */ + @Test + 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("help:evaluate", "-Dexpression=project.version"); + try { + verifier.execute(); + fail("Expected failure"); + } catch (VerificationException e) { + assertTrue( + e.getMessage(), + e.getMessage() + .contains( + "'version' contains an expression but should be a constant. @ myGroup:parent:${ci-version}")); + } + } + + @Test + 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"); + try { + verifier.execute(); + fail("Expected failure"); + } catch (VerificationException e) { + assertTrue( + e.getMessage(), + e.getMessage() + .contains( + "'groupId' contains an expression but should be a constant. @ ${foo}:myArtifact:1.0-SNAPSHOT")); + } + } + + @Test + 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"); + try { + verifier.execute(); + fail("Expected failure"); + } catch (VerificationException e) { + assertTrue( + e.getMessage(), + e.getMessage() + .contains( + "'artifactId' contains an expression but should be a constant. @ myGroup:${foo}:1.0-SNAPSHOT")); + } + } + + void verifyExactLine(Verifier verifier, String line) throws Exception { + List lines = verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false); + if (lines.stream().noneMatch(s -> Objects.equals(s, line))) { + throw new VerificationException( + "Could not find line: '" + line + "' in output log:\n" + String.join("\n", lines)); + } + } +} diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java index 3524aae65..1619516d8 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java @@ -120,6 +120,7 @@ public TestSuiteOrdering() { * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. */ + suite.addTestSuite(MavenITmng8230CIFriendlyTest.class); suite.addTestSuite(MavenITmng7255InferredGroupIdTest.class); suite.addTestSuite(MavenITmng8220ExtensionWithDITest.class); suite.addTestSuite(MavenITmng8181CentralRepoTest.class); diff --git a/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-project-props/child/pom.xml b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-project-props/child/pom.xml new file mode 100644 index 000000000..6d3d27d61 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-project-props/child/pom.xml @@ -0,0 +1,6 @@ + + + 4.1.0 + + child + diff --git a/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-project-props/pom.xml b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-project-props/pom.xml new file mode 100644 index 000000000..32b20471a --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-project-props/pom.xml @@ -0,0 +1,13 @@ + + + 4.1.0 + + myGroup + parent + ${ci-version} + pom + + + 1.0-SNAPSHOT + + diff --git a/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-user-props/child/pom.xml b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-user-props/child/pom.xml new file mode 100644 index 000000000..6d3d27d61 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-user-props/child/pom.xml @@ -0,0 +1,6 @@ + + + 4.1.0 + + child + diff --git a/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-user-props/pom.xml b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-user-props/pom.xml new file mode 100644 index 000000000..6d2c7e542 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/cif-with-user-props/pom.xml @@ -0,0 +1,9 @@ + + + 4.1.0 + + myGroup + parent + ${ci-version} + pom + diff --git a/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/exp-in-artifactid/pom.xml b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/exp-in-artifactid/pom.xml new file mode 100644 index 000000000..5952bd898 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/exp-in-artifactid/pom.xml @@ -0,0 +1,8 @@ + + + 4.1.0 + + myGroup + ${foo} + 1.0-SNAPSHOT + diff --git a/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/exp-in-groupid/pom.xml b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/exp-in-groupid/pom.xml new file mode 100644 index 000000000..0e0cbede9 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8230-ci-friendly-and-gav/exp-in-groupid/pom.xml @@ -0,0 +1,8 @@ + + + 4.1.0 + + ${foo} + myArtifact + 1.0-SNAPSHOT + From 7c3b5ae04c8bc3a827ab251061e76d3ed6fa8446 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 30 Sep 2024 14:49:00 +0200 Subject: [PATCH 2/4] Fix --- .../org/apache/maven/it/MavenITmng8230CIFriendlyTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java index 980eb3a9c..712f4369b 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java @@ -45,7 +45,7 @@ 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("help:evaluate", "-Dexpression=project.version"); + verifier.addCliArguments("org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", "-Dexpression=project.version"); verifier.execute(); verifier.verifyErrorFreeLog(); verifyExactLine(verifier, "1.0-SNAPSHOT"); @@ -61,7 +61,7 @@ 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("help:evaluate", "-Dexpression=project.version", "-Dci-version=1.1-SNAPSHOT"); + verifier.addCliArguments("org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", "-Dexpression=project.version", "-Dci-version=1.1-SNAPSHOT"); verifier.execute(); verifier.verifyErrorFreeLog(); verifyExactLine(verifier, "1.1-SNAPSHOT"); @@ -77,7 +77,7 @@ 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("help:evaluate", "-Dexpression=project.version", "-Dci-version=1.1-SNAPSHOT"); + verifier.addCliArguments("org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", "-Dexpression=project.version", "-Dci-version=1.1-SNAPSHOT"); verifier.execute(); verifier.verifyErrorFreeLog(); verifyExactLine(verifier, "1.1-SNAPSHOT"); @@ -93,7 +93,7 @@ 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("help:evaluate", "-Dexpression=project.version"); + verifier.addCliArguments("org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", "-Dexpression=project.version"); try { verifier.execute(); fail("Expected failure"); From 950800a2147cc965e1e2d1ca8844ebd778b080d3 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 30 Sep 2024 14:51:53 +0200 Subject: [PATCH 3/4] Codestyle --- .../maven/it/MavenITmng8230CIFriendlyTest.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java index 712f4369b..b82bbdd1b 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java @@ -45,7 +45,8 @@ 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"); + verifier.addCliArguments( + "org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", "-Dexpression=project.version"); verifier.execute(); verifier.verifyErrorFreeLog(); verifyExactLine(verifier, "1.0-SNAPSHOT"); @@ -61,7 +62,10 @@ 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"); + verifier.addCliArguments( + "org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", + "-Dexpression=project.version", + "-Dci-version=1.1-SNAPSHOT"); verifier.execute(); verifier.verifyErrorFreeLog(); verifyExactLine(verifier, "1.1-SNAPSHOT"); @@ -77,7 +81,10 @@ 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"); + verifier.addCliArguments( + "org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", + "-Dexpression=project.version", + "-Dci-version=1.1-SNAPSHOT"); verifier.execute(); verifier.verifyErrorFreeLog(); verifyExactLine(verifier, "1.1-SNAPSHOT"); @@ -93,7 +100,8 @@ 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"); + verifier.addCliArguments( + "org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate", "-Dexpression=project.version"); try { verifier.execute(); fail("Expected failure"); From e6ddb82e857f0736cf97b97bb82b649f1c554fa3 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 1 Oct 2024 01:05:27 +0200 Subject: [PATCH 4/4] Use org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval instead of m-help-p --- .../it/MavenITmng8230CIFriendlyTest.java | 69 ++++++++++++------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java index b82bbdd1b..271bd7fba 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8230CIFriendlyTest.java @@ -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; @@ -31,6 +32,9 @@ * This is a test set for MNG-8230. */ class MavenITmng8230CIFriendlyTest extends AbstractMavenIntegrationTestCase { + + private static final String PROPERTIES = "target/expression.properties"; + MavenITmng8230CIFriendlyTest() { super("[4.0.0-beta-5,)"); } @@ -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"); } /** @@ -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"); } /** @@ -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"); } /** @@ -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"); @@ -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"); @@ -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");