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.model.MailingList;
23  import org.apache.maven.project.MavenProject;
24  import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
25  
26  /**
27   * A test which demonstrates maven's recursive inheritance where
28   * a distinct value is taken from each parent contributing to the
29   * the final model of the project being assembled. There is no
30   * overriding going on amongst the models being used in this test:
31   * each model in the lineage is providing a value that is not present
32   * anywhere else in the lineage. We are just making sure that values
33   * down in the lineage are bubbling up where they should.
34   *
35   * @author Jason van Zyl
36   * @version $Id: ProjectInheritanceTest.java 632468 2008-02-29 22:36:19Z jvanzyl $
37   */
38  public class ProjectInheritanceTest
39      extends AbstractProjectInheritanceTestCase
40  {
41      // ----------------------------------------------------------------------
42      //
43      // p4 inherits from p3
44      // p3 inherits from p2
45      // p2 inherits from p1
46      // p1 inherits from p0
47      // p0 inhertis from super model
48      //
49      // or we can show it graphically as:
50      //
51      // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
52      //
53      // ----------------------------------------------------------------------
54  
55      public void testProjectInheritance()
56          throws Exception
57      {
58          MavenProject p4 = getProject( projectFile( "p4" ) );
59  
60          assertEquals( "p4", p4.getName() );
61  
62          // ----------------------------------------------------------------------
63          // Value inherited from p3
64          // ----------------------------------------------------------------------
65  
66          assertEquals( "2000", p4.getInceptionYear() );
67  
68          // ----------------------------------------------------------------------
69          // Value taken from p2
70          // ----------------------------------------------------------------------
71  
72          assertEquals( "mailing-list", ( (MailingList) p4.getMailingLists().get( 0 ) ).getName() );
73  
74          // ----------------------------------------------------------------------
75          // Value taken from p1
76          // ----------------------------------------------------------------------
77  
78          assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() );
79  
80          // ----------------------------------------------------------------------
81          // Value taken from p4
82          // ----------------------------------------------------------------------
83  
84          assertEquals( "Codehaus", p4.getOrganization().getName() );
85  
86          // ----------------------------------------------------------------------
87          // Value taken from super model
88          // ----------------------------------------------------------------------
89  
90          assertEquals( "4.0.0", p4.getModelVersion() );
91  
92          assertEquals( "4.0.0", p4.getModelVersion() );
93      }
94  }