1 package org.apache.maven.project.inheritance.t00; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.apache.maven.project.MavenProject; 23 import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; 24 25 /** 26 * A test which demonstrates maven's recursive inheritance where 27 * a distinct value is taken from each parent contributing to the 28 * the final model of the project being assembled. There is no 29 * overriding going on amongst the models being used in this test: 30 * each model in the lineage is providing a value that is not present 31 * anywhere else in the lineage. We are just making sure that values 32 * down in the lineage are bubbling up where they should. 33 * 34 * @author Jason van Zyl 35 */ 36 public class ProjectInheritanceTest 37 extends AbstractProjectInheritanceTestCase 38 { 39 // ---------------------------------------------------------------------- 40 // 41 // p4 inherits from p3 42 // p3 inherits from p2 43 // p2 inherits from p1 44 // p1 inherits from p0 45 // p0 inherits from super model 46 // 47 // or we can show it graphically as: 48 // 49 // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model 50 // 51 // ---------------------------------------------------------------------- 52 53 public void testProjectInheritance() 54 throws Exception 55 { 56 MavenProject p4 = getProject( projectFile( "p4" ) ); 57 58 assertEquals( "p4", p4.getName() ); 59 60 // ---------------------------------------------------------------------- 61 // Value inherited from p3 62 // ---------------------------------------------------------------------- 63 64 assertEquals( "2000", p4.getInceptionYear() ); 65 66 // ---------------------------------------------------------------------- 67 // Value taken from p2 68 // ---------------------------------------------------------------------- 69 70 assertEquals( "mailing-list", p4.getMailingLists().get( 0 ).getName() ); 71 72 // ---------------------------------------------------------------------- 73 // Value taken from p1 74 // ---------------------------------------------------------------------- 75 76 assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() ); 77 78 // ---------------------------------------------------------------------- 79 // Value taken from p4 80 // ---------------------------------------------------------------------- 81 82 assertEquals( "Codehaus", p4.getOrganization().getName() ); 83 84 // ---------------------------------------------------------------------- 85 // Value taken from super model 86 // ---------------------------------------------------------------------- 87 88 assertEquals( "4.0.0", p4.getModelVersion() ); 89 90 assertEquals( "4.0.0", p4.getModelVersion() ); 91 } 92 }