mirror of https://github.com/apache/maven.git
[MNG-3057] integration test to check that POM/POM-parent versions are resolved...other versions (dependencies, plugins, report plugins) are also interpolated, but these are verified in a series of unit tests...if the ones in this IT are working, all should work fine.
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@745676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
20c28efc68
commit
9455216560
|
@ -214,6 +214,7 @@ public class IntegrationTestSuite
|
||||||
suite.addTestSuite( MavenITmng3217InterPluginDependencyTest.class );
|
suite.addTestSuite( MavenITmng3217InterPluginDependencyTest.class );
|
||||||
suite.addTestSuite( MavenITmng3106ProfileMultipleActivatorsTest.class );
|
suite.addTestSuite( MavenITmng3106ProfileMultipleActivatorsTest.class );
|
||||||
suite.addTestSuite( MavenITmng3099SettingsProfilesWithNoPomTest.class );
|
suite.addTestSuite( MavenITmng3099SettingsProfilesWithNoPomTest.class );
|
||||||
|
suite.addTestSuite( MavenITmng3057VersionExprTransformations.class );
|
||||||
suite.addTestSuite( MavenITmng3052DepRepoAggregationTest.class );
|
suite.addTestSuite( MavenITmng3052DepRepoAggregationTest.class );
|
||||||
suite.addTestSuite( MavenITmng3023ReactorDependencyResolutionTest.class );
|
suite.addTestSuite( MavenITmng3023ReactorDependencyResolutionTest.class );
|
||||||
suite.addTestSuite( MavenITmng3012CoreClassImportTest.class );
|
suite.addTestSuite( MavenITmng3012CoreClassImportTest.class );
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
/*
|
||||||
|
* 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.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||||
|
import org.apache.maven.it.Verifier;
|
||||||
|
import org.apache.maven.it.util.IOUtil;
|
||||||
|
import org.apache.maven.it.util.ResourceExtractor;
|
||||||
|
import org.apache.maven.it.util.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3057">MNG-3057</a>.
|
||||||
|
*
|
||||||
|
* @todo Fill in a better description of what this test verifies!
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||||
|
* @author jdcasey
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MavenITmng3057VersionExprTransformations
|
||||||
|
extends AbstractMavenIntegrationTestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final List VERIFICATION_EXPRESSIONS;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
List exprs = new ArrayList();
|
||||||
|
|
||||||
|
exprs.add( "project.parent.version" );
|
||||||
|
exprs.add( "project.version" );
|
||||||
|
|
||||||
|
VERIFICATION_EXPRESSIONS = exprs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MavenITmng3057VersionExprTransformations()
|
||||||
|
throws InvalidVersionSpecificationException
|
||||||
|
{
|
||||||
|
super( "(2.1.0-M1,2.99.99)" ); // only test in 2.0.9+
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testitMNG3057 ()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3057" );
|
||||||
|
|
||||||
|
File localRepo = new File( testDir, "target/local" );
|
||||||
|
String remoteRepo = new File( testDir, "target/deployment" ).toURL().toExternalForm();
|
||||||
|
|
||||||
|
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||||
|
verifier.deleteArtifact( "org.apache.maven.its.mng3057", "mng-3057", "1", "pom" );
|
||||||
|
verifier.deleteArtifact( "org.apache.maven.its.mng3057", "level2", "1", "pom" );
|
||||||
|
verifier.deleteArtifact( "org.apache.maven.its.mng3057", "level3", "1", "pom" );
|
||||||
|
verifier.deleteArtifact( "org.apache.maven.its.mng3057", "level3", "1", "jar" );
|
||||||
|
|
||||||
|
Properties properties = verifier.newDefaultFilterProperties();
|
||||||
|
properties.setProperty( "deployTo", remoteRepo );
|
||||||
|
|
||||||
|
verifier.filterFile( "pom.xml", "pom.xml", "UTF-8", properties );
|
||||||
|
|
||||||
|
List cliOptions = new ArrayList();
|
||||||
|
cliOptions.add( "-DtestVersion=1" );
|
||||||
|
cliOptions.add( "-Dmaven.repo.local=" + localRepo.getAbsolutePath() );
|
||||||
|
|
||||||
|
verifier.setCliOptions( cliOptions );
|
||||||
|
verifier.executeGoal( "deploy" );
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
verifier.resetStreams();
|
||||||
|
|
||||||
|
assertVersionExpressions( new File( localRepo, "org/apache/maven/its/mng3057/mng-3057/1/mng-3057-1.pom" ) );
|
||||||
|
assertVersionExpressions( new File( localRepo, "org/apache/maven/its/mng3057/level2/1/level2-1.pom" ) );
|
||||||
|
assertVersionExpressions( new File( localRepo, "org/apache/maven/its/mng3057/level3/1/level3-1.pom" ) );
|
||||||
|
|
||||||
|
assertVersionExpressions( new File( remoteRepo, "org/apache/maven/its/mng3057/mng-3057/1/mng-3057-1.pom" ) );
|
||||||
|
assertVersionExpressions( new File( remoteRepo, "org/apache/maven/its/mng3057/level2/1/level2-1.pom" ) );
|
||||||
|
assertVersionExpressions( new File( remoteRepo, "org/apache/maven/its/mng3057/level3/1/level3-1.pom" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertVersionExpressions( File pomFile )
|
||||||
|
throws VerificationException, IOException
|
||||||
|
{
|
||||||
|
Verifier verifier = new Verifier( pomFile.getParentFile().getAbsolutePath() );
|
||||||
|
|
||||||
|
List cliOptions = new ArrayList();
|
||||||
|
cliOptions.add( "-f" );
|
||||||
|
cliOptions.add( "-Dexpression.outputFile=expressions.properties" );
|
||||||
|
cliOptions.add( "-Dexpression.expressions=" + StringUtils.join( VERIFICATION_EXPRESSIONS.iterator(), "," ) );
|
||||||
|
cliOptions.add( pomFile.getName() );
|
||||||
|
|
||||||
|
verifier.setCliOptions( cliOptions );
|
||||||
|
|
||||||
|
verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-expression:eval" );
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
verifier.resetStreams();
|
||||||
|
|
||||||
|
File propsFile = new File( pomFile.getParentFile(), "expressions.properties" );
|
||||||
|
InputStream is = null;
|
||||||
|
Properties props = new Properties();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
is = new FileInputStream( propsFile );
|
||||||
|
props.load( is );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( is );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator it = VERIFICATION_EXPRESSIONS.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
String expr = (String ) it.next();
|
||||||
|
String value = props.getProperty( expr );
|
||||||
|
if ( value != null )
|
||||||
|
{
|
||||||
|
assertEquals( "POM expression not interpolated: '" + expr + "'\nin: '" + pomFile + "'.", "1", value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<artifactId>level2</artifactId>
|
||||||
|
<groupId>org.apache.maven.its.mng3057</groupId>
|
||||||
|
<version>${testVersion}</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>level3</artifactId>
|
||||||
|
<version>${testVersion}</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.apache.maven.its.mng3057;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hello world!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
System.out.println( "Hello World!" );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package org.apache.maven.its.mng3057;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for simple App.
|
||||||
|
*/
|
||||||
|
public class AppTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the test case
|
||||||
|
*
|
||||||
|
* @param testName name of the test case
|
||||||
|
*/
|
||||||
|
public AppTest( String testName )
|
||||||
|
{
|
||||||
|
super( testName );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the suite of tests being tested
|
||||||
|
*/
|
||||||
|
public static Test suite()
|
||||||
|
{
|
||||||
|
return new TestSuite( AppTest.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rigourous Test :-)
|
||||||
|
*/
|
||||||
|
public void testApp()
|
||||||
|
{
|
||||||
|
assertTrue( true );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<artifactId>mng-3057</artifactId>
|
||||||
|
<groupId>org.apache.maven.its.mng3057</groupId>
|
||||||
|
<version>${testVersion}</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>level2</artifactId>
|
||||||
|
<version>${testVersion}</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>level3</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.apache.maven.its.mng3057</groupId>
|
||||||
|
<artifactId>mng-3057</artifactId>
|
||||||
|
<version>${testVersion}</version>
|
||||||
|
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>Integration Test Project for MNG-3057</name>
|
||||||
|
<description>
|
||||||
|
This project verifies that MNG-3057 is fixed. It is controlled by a JUnit test called org.apache.maven.integrationtests.MNG3057Test
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<url>http://jira.codehaus.org/browse/MNG-3057</url>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>level2</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
Loading…
Reference in New Issue