[MNG-5608] IT for warning on ${project.basedir} use for profile

activation
This commit is contained in:
Hervé Boutemy 2014-03-23 19:59:31 +01:00
parent 2b5ee0480f
commit 8f1f240a21
3 changed files with 183 additions and 0 deletions

View File

@ -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 );

View File

@ -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 <a href="http://jira.codehaus.org/browse/MNG-5608">MNG-5608</a>:
* Profile activation warning test when file specification contains <code>${project.basedir}</code>
* instead of <code>${basedir}</code>
*/
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<String> 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<String> 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;
}
}

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng5608</groupId>
<artifactId>profile-test</artifactId>
<version>1</version>
<packaging>pom</packaging>
<name>MNG-5608 - Profile activation warning test when file specification contains ${project.basedir}</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-uses-properties</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>generate-properties</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!-- ${project.basedir} not supported for profile activation -->
<profile>
<id>mng-5608-exists-project.basedir</id>
<activation>
<file>
<exists>${project.basedir}/pom.xml</exists>
</file>
</activation>
<properties>
<mng-5608-exists-project.basedir>unexpected active profile</mng-5608-exists-project.basedir>
</properties>
</profile>
<profile>
<id>mng-5608-missing-project.basedir</id>
<activation>
<file>
<missing>${project.basedir}/pom.xml</missing>
</file>
</activation>
<properties>
<mng-5608-missing-project.basedir>expected active profile</mng-5608-missing-project.basedir>
</properties>
</profile>
<!-- for reference: ${basedir} supported for profile activation, see MNG-2363 -->
<profile>
<id>exists-basedir</id>
<activation>
<file>
<exists>${basedir}/pom.xml</exists>
</file>
</activation>
<properties>
<exists-basedir>expected active profile</exists-basedir>
</properties>
</profile>
<profile>
<id>missing-basedir</id>
<activation>
<file>
<missing>${basedir}/pom.xml</missing>
</file>
</activation>
<properties>
<missing-basedir>unexpected active profile</missing-basedir>
</properties>
</profile>
</profiles>
</project>