21
21
import java .io .File ;
22
22
import java .util .List ;
23
23
import java .util .Objects ;
24
+ import java .util .Properties ;
24
25
25
26
import org .apache .maven .shared .verifier .VerificationException ;
26
27
import org .apache .maven .shared .verifier .Verifier ;
31
32
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8230">MNG-8230</a>.
32
33
*/
33
34
class MavenITmng8230CIFriendlyTest extends AbstractMavenIntegrationTestCase {
35
+
36
+ private static final String PROPERTIES = "target/expression.properties" ;
37
+
34
38
MavenITmng8230CIFriendlyTest () {
35
39
super ("[4.0.0-beta-5,)" );
36
40
}
@@ -61,14 +65,17 @@ void testitCiFriendlyWithProjectProperties() throws Exception {
61
65
void testitCiFriendlyWithProjectPropertiesOverride () throws Exception {
62
66
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
63
67
64
- Verifier verifier = newVerifier (new File (testDir , "cif-with-project-props" ).getAbsolutePath ());
65
- verifier .addCliArguments (
66
- "org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate" ,
67
- "-Dexpression=project.version" ,
68
- "-Dci-version=1.1-SNAPSHOT" );
68
+ File basedir = new File (testDir , "cif-with-project-props" );
69
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
70
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
71
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
72
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
73
+ verifier .addCliArgument ("-Dci-version=1.1-SNAPSHOT" );
69
74
verifier .execute ();
70
75
verifier .verifyErrorFreeLog ();
71
- verifyExactLine (verifier , "1.1-SNAPSHOT" );
76
+ verifier .verifyFilePresent (PROPERTIES );
77
+ Properties props = verifier .loadProperties (PROPERTIES );
78
+ assertEquals (props .getProperty ("project.version" ), "1.1-SNAPSHOT" );
72
79
}
73
80
74
81
/**
@@ -80,14 +87,18 @@ void testitCiFriendlyWithProjectPropertiesOverride() throws Exception {
80
87
void testitCiFriendlyWithUserProperties () throws Exception {
81
88
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
82
89
83
- Verifier verifier = newVerifier (new File (testDir , "cif-with-user-props" ).getAbsolutePath ());
84
- verifier .addCliArguments (
85
- "org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate" ,
86
- "-Dexpression=project.version" ,
87
- "-Dci-version=1.1-SNAPSHOT" );
90
+ File basedir = new File (testDir , "cif-with-user-props" );
91
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
92
+
93
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
94
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
95
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
96
+ verifier .addCliArgument ("-Dci-version=1.1-SNAPSHOT" );
88
97
verifier .execute ();
89
98
verifier .verifyErrorFreeLog ();
90
- verifyExactLine (verifier , "1.1-SNAPSHOT" );
99
+ verifier .verifyFilePresent (PROPERTIES );
100
+ Properties props = verifier .loadProperties (PROPERTIES );
101
+ assertEquals (props .getProperty ("project.version" ), "1.1-SNAPSHOT" );
91
102
}
92
103
93
104
/**
@@ -99,9 +110,11 @@ void testitCiFriendlyWithUserProperties() throws Exception {
99
110
void testitCiFriendlyWithUserPropertiesNotGiven () throws Exception {
100
111
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
101
112
102
- Verifier verifier = newVerifier (new File (testDir , "cif-with-user-props" ).getAbsolutePath ());
103
- verifier .addCliArguments (
104
- "org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate" , "-Dexpression=project.version" );
113
+ File basedir = new File (testDir , "cif-with-user-props" );
114
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
115
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
116
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
117
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
105
118
try {
106
119
verifier .execute ();
107
120
fail ("Expected failure" );
@@ -118,8 +131,11 @@ void testitCiFriendlyWithUserPropertiesNotGiven() throws Exception {
118
131
void testitExpressionInGroupId () throws Exception {
119
132
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
120
133
121
- Verifier verifier = newVerifier (new File (testDir , "exp-in-groupid" ).getAbsolutePath ());
122
- verifier .addCliArguments ("validate" );
134
+ File basedir = new File (testDir , "exp-in-groupid" );
135
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
136
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
137
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
138
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
123
139
try {
124
140
verifier .execute ();
125
141
fail ("Expected failure" );
@@ -136,8 +152,11 @@ void testitExpressionInGroupId() throws Exception {
136
152
void testitExpressionInArtifactId () throws Exception {
137
153
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
138
154
139
- Verifier verifier = newVerifier (new File (testDir , "exp-in-artifactid" ).getAbsolutePath ());
140
- verifier .addCliArguments ("validate" );
155
+ File basedir = new File (testDir , "exp-in-artifactid" );
156
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
157
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
158
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
159
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
141
160
try {
142
161
verifier .execute ();
143
162
fail ("Expected failure" );
0 commit comments