mirror of https://github.com/apache/maven.git
[MNG-2314] Added unit tests to verify that this issue cannot be reproduced.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@425924 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5d50ceac1f
commit
3e8d1f934c
|
@ -18,6 +18,8 @@ package org.apache.maven.project.inheritance;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
|
import org.apache.maven.model.Dependency;
|
||||||
|
import org.apache.maven.model.DependencyManagement;
|
||||||
import org.apache.maven.model.DeploymentRepository;
|
import org.apache.maven.model.DeploymentRepository;
|
||||||
import org.apache.maven.model.DistributionManagement;
|
import org.apache.maven.model.DistributionManagement;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
|
@ -48,6 +50,85 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
{
|
{
|
||||||
private ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
|
private ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
|
||||||
|
|
||||||
|
public void testShouldMergeSuccessiveDependencyManagementSectionsOverThreeLevels()
|
||||||
|
{
|
||||||
|
Model top = makeBaseModel( "top" );
|
||||||
|
|
||||||
|
DependencyManagement topMgmt = new DependencyManagement();
|
||||||
|
|
||||||
|
topMgmt.addDependency( makeDep( "top-dep" ) );
|
||||||
|
|
||||||
|
top.setDependencyManagement( topMgmt );
|
||||||
|
|
||||||
|
Model mid = makeBaseModel( "mid" );
|
||||||
|
|
||||||
|
DependencyManagement midMgmt = new DependencyManagement();
|
||||||
|
|
||||||
|
midMgmt.addDependency( makeDep( "mid-dep" ) );
|
||||||
|
|
||||||
|
mid.setDependencyManagement( midMgmt );
|
||||||
|
|
||||||
|
Model bottom = makeBaseModel( "bottom" );
|
||||||
|
|
||||||
|
DependencyManagement bottomMgmt = new DependencyManagement();
|
||||||
|
|
||||||
|
bottomMgmt.addDependency( makeDep( "bottom-dep" ) );
|
||||||
|
|
||||||
|
bottom.setDependencyManagement( bottomMgmt );
|
||||||
|
|
||||||
|
assembler.assembleModelInheritance( mid, top );
|
||||||
|
|
||||||
|
assembler.assembleModelInheritance( bottom, mid );
|
||||||
|
|
||||||
|
DependencyManagement result = bottom.getDependencyManagement();
|
||||||
|
|
||||||
|
List resultDeps = result.getDependencies();
|
||||||
|
|
||||||
|
assertEquals( 3, resultDeps.size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testShouldMergeDependencyManagementSectionsFromTopTwoLevelsToBottomLevel()
|
||||||
|
{
|
||||||
|
Model top = makeBaseModel( "top" );
|
||||||
|
|
||||||
|
DependencyManagement topMgmt = new DependencyManagement();
|
||||||
|
|
||||||
|
topMgmt.addDependency( makeDep( "top-dep" ) );
|
||||||
|
|
||||||
|
top.setDependencyManagement( topMgmt );
|
||||||
|
|
||||||
|
Model mid = makeBaseModel( "mid" );
|
||||||
|
|
||||||
|
DependencyManagement midMgmt = new DependencyManagement();
|
||||||
|
|
||||||
|
midMgmt.addDependency( makeDep( "mid-dep" ) );
|
||||||
|
|
||||||
|
mid.setDependencyManagement( midMgmt );
|
||||||
|
|
||||||
|
Model bottom = makeBaseModel( "bottom" );
|
||||||
|
|
||||||
|
assembler.assembleModelInheritance( mid, top );
|
||||||
|
|
||||||
|
assembler.assembleModelInheritance( bottom, mid );
|
||||||
|
|
||||||
|
DependencyManagement result = bottom.getDependencyManagement();
|
||||||
|
|
||||||
|
List resultDeps = result.getDependencies();
|
||||||
|
|
||||||
|
assertEquals( 2, resultDeps.size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dependency makeDep( String artifactId )
|
||||||
|
{
|
||||||
|
Dependency dep = new Dependency();
|
||||||
|
|
||||||
|
dep.setGroupId( "maven" );
|
||||||
|
dep.setArtifactId( artifactId );
|
||||||
|
dep.setVersion( "1.0" );
|
||||||
|
|
||||||
|
return dep;
|
||||||
|
}
|
||||||
|
|
||||||
public void testShouldAppendChildPathAdjustmentWithNoChildPartAndNoParentPart()
|
public void testShouldAppendChildPathAdjustmentWithNoChildPartAndNoParentPart()
|
||||||
{
|
{
|
||||||
String parentPath = "";
|
String parentPath = "";
|
||||||
|
|
Loading…
Reference in New Issue