From 3e8d1f934ccc2ac55f1e34da462d5184f58ef310 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Thu, 27 Jul 2006 01:00:03 +0000 Subject: [PATCH] [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 --- .../DefaultModelInheritanceAssemblerTest.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java index 7ee0e26e0d..f8e11214f4 100644 --- a/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java @@ -18,6 +18,8 @@ package org.apache.maven.project.inheritance; import junit.framework.TestCase; 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.DistributionManagement; import org.apache.maven.model.Model; @@ -47,6 +49,85 @@ public class DefaultModelInheritanceAssemblerTest extends TestCase { 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() {