diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 1ea1362706..72bc0300f1 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -105,6 +105,8 @@ public class IntegrationTestSuite // Tests that don't run stable and need to be fixed // ------------------------------------------------------------------------------------------------------------- // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137 + + suite.addTestSuite( MavenITmng5608ProfileActivationWarningTest.class ); suite.addTestSuite( MavenITmng5591WorkspaceReader.class ); suite.addTestSuite( MavenITmng5581LifecycleMappingDelegate.class ); suite.addTestSuite( MavenITmng5572ReactorPluginExtensionsTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java new file mode 100644 index 0000000000..a98f659bdd --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java @@ -0,0 +1,82 @@ +package org.apache.maven.it; + +/* + * 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. + */ + +import java.io.File; +import java.util.List; +import java.util.Properties; +import java.util.regex.Pattern; + +import org.apache.maven.it.util.ResourceExtractor; + +/** + * This is a test set for MNG-5608: + * Profile activation warning test when file specification contains ${project.basedir} + * instead of ${basedir} + */ +public class MavenITmng5608ProfileActivationWarningTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng5608ProfileActivationWarningTest() + { + super( "(3.2.1,)" ); + } + + public void testitMNG5608() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5608" ); + + Verifier verifier = newVerifier( testDir.getAbsolutePath() ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + // check expected profiles activated, just for sanity + Properties props = verifier.loadProperties( "target/project.properties" ); + assertEquals( "expected 2 active profiles", 2, props.size() ); + assertEquals( "expected profile exists-basedir", "expected active profile", + props.getProperty( "exists-basedir" ) ); + assertEquals( "expected profile mng-5608-missing-project.basedir", "expected active profile", + props.getProperty( "mng-5608-missing-project.basedir" ) ); + + // check that the 2 profiles using ${project.basedir} caused warnings + List logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false ); + assertNotNull( findWarning( logFile, "mng-5608-exists-project.basedir" ) ); + assertNotNull( findWarning( logFile, "mng-5608-missing-project.basedir" ) ); + } + + private String findWarning( List logLines, String profileId ) + { + Pattern pattern = Pattern.compile( "(?i).*Failed to interpolate file location ..project.basedir./pom.xml for profile " + profileId + ": .*" ); + + for ( String logLine : logLines ) + { + if ( pattern.matcher( logLine ).matches() ) + { + return logLine; + } + } + + return null; + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-5608/pom.xml b/its/core-it-suite/src/test/resources/mng-5608/pom.xml new file mode 100644 index 0000000000..dbd836f118 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5608/pom.xml @@ -0,0 +1,99 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5608 + profile-test + 1 + pom + + MNG-5608 - Profile activation warning test when file specification contains ${project.basedir} + + + + + org.apache.maven.its.plugins + maven-it-plugin-uses-properties + 2.1-SNAPSHOT + + + validate + + generate-properties + + + + + + + + + + + mng-5608-exists-project.basedir + + + ${project.basedir}/pom.xml + + + + unexpected active profile + + + + mng-5608-missing-project.basedir + + + ${project.basedir}/pom.xml + + + + expected active profile + + + + + + exists-basedir + + + ${basedir}/pom.xml + + + + expected active profile + + + + missing-basedir + + + ${basedir}/pom.xml + + + + unexpected active profile + + + +