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
}
@@ -44,12 +48,16 @@ class MavenITmng8230CIFriendlyTest extends AbstractMavenIntegrationTestCase {
44
48
void testitCiFriendlyWithProjectProperties () throws Exception {
45
49
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
46
50
47
- Verifier verifier = newVerifier (new File (testDir , "cif-with-project-props" ).getAbsolutePath ());
48
- verifier .addCliArguments (
49
- "org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate" , "-Dexpression=project.version" );
51
+ File basedir = new File (testDir , "cif-with-project-props" );
52
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
53
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
54
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
55
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
50
56
verifier .execute ();
51
57
verifier .verifyErrorFreeLog ();
52
- verifyExactLine (verifier , "1.0-SNAPSHOT" );
58
+ verifier .verifyFilePresent (PROPERTIES );
59
+ Properties props = verifier .loadProperties (PROPERTIES );
60
+ assertEquals (props .getProperty ("project.version" ), "1.0-SNAPSHOT" );
53
61
}
54
62
55
63
/**
@@ -61,14 +69,17 @@ void testitCiFriendlyWithProjectProperties() throws Exception {
61
69
void testitCiFriendlyWithProjectPropertiesOverride () throws Exception {
62
70
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
63
71
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" );
72
+ File basedir = new File (testDir , "cif-with-project-props" );
73
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
74
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
75
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
76
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
77
+ verifier .addCliArgument ("-Dci-version=1.1-SNAPSHOT" );
69
78
verifier .execute ();
70
79
verifier .verifyErrorFreeLog ();
71
- verifyExactLine (verifier , "1.1-SNAPSHOT" );
80
+ verifier .verifyFilePresent (PROPERTIES );
81
+ Properties props = verifier .loadProperties (PROPERTIES );
82
+ assertEquals (props .getProperty ("project.version" ), "1.1-SNAPSHOT" );
72
83
}
73
84
74
85
/**
@@ -80,14 +91,18 @@ void testitCiFriendlyWithProjectPropertiesOverride() throws Exception {
80
91
void testitCiFriendlyWithUserProperties () throws Exception {
81
92
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
82
93
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" );
94
+ File basedir = new File (testDir , "cif-with-user-props" );
95
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
96
+
97
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
98
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
99
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
100
+ verifier .addCliArgument ("-Dci-version=1.1-SNAPSHOT" );
88
101
verifier .execute ();
89
102
verifier .verifyErrorFreeLog ();
90
- verifyExactLine (verifier , "1.1-SNAPSHOT" );
103
+ verifier .verifyFilePresent (PROPERTIES );
104
+ Properties props = verifier .loadProperties (PROPERTIES );
105
+ assertEquals (props .getProperty ("project.version" ), "1.1-SNAPSHOT" );
91
106
}
92
107
93
108
/**
@@ -99,9 +114,11 @@ void testitCiFriendlyWithUserProperties() throws Exception {
99
114
void testitCiFriendlyWithUserPropertiesNotGiven () throws Exception {
100
115
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
101
116
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" );
117
+ File basedir = new File (testDir , "cif-with-user-props" );
118
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
119
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
120
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
121
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
105
122
try {
106
123
verifier .execute ();
107
124
fail ("Expected failure" );
@@ -118,8 +135,11 @@ void testitCiFriendlyWithUserPropertiesNotGiven() throws Exception {
118
135
void testitExpressionInGroupId () throws Exception {
119
136
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
120
137
121
- Verifier verifier = newVerifier (new File (testDir , "exp-in-groupid" ).getAbsolutePath ());
122
- verifier .addCliArguments ("validate" );
138
+ File basedir = new File (testDir , "exp-in-groupid" );
139
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
140
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
141
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
142
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
123
143
try {
124
144
verifier .execute ();
125
145
fail ("Expected failure" );
@@ -136,8 +156,11 @@ void testitExpressionInGroupId() throws Exception {
136
156
void testitExpressionInArtifactId () throws Exception {
137
157
File testDir = ResourceExtractor .simpleExtractResources (getClass (), "/mng-8230-ci-friendly-and-gav" );
138
158
139
- Verifier verifier = newVerifier (new File (testDir , "exp-in-artifactid" ).getAbsolutePath ());
140
- verifier .addCliArguments ("validate" );
159
+ File basedir = new File (testDir , "exp-in-artifactid" );
160
+ Verifier verifier = newVerifier (basedir .getAbsolutePath ());
161
+ verifier .addCliArgument ("-Dexpression.outputFile=" + new File (basedir , PROPERTIES ).getPath ());
162
+ verifier .addCliArgument ("-Dexpression.expressions=project/version" );
163
+ verifier .addCliArgument ("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
141
164
try {
142
165
verifier .execute ();
143
166
fail ("Expected failure" );
0 commit comments