View Javadoc

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   */
37  public class ProjectInheritanceTest
38      extends AbstractProjectInheritanceTestCase
39  {
40      // ----------------------------------------------------------------------
41      //
42      // p4 inherits from p3
43      // p3 inherits from p2
44      // p2 inherits from p1
45      // p1 inherits from p0
46      // p0 inhertis from super model
47      //
48      // or we can show it graphically as:
49      //
50      // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
51      //
52      // ----------------------------------------------------------------------
53  
54      public void testProjectInheritance()
55          throws Exception
56      {
57          MavenProject p4 = getProject( projectFile( "p4" ) );
58  
59          assertEquals( "p4", p4.getName() );
60  
61          // ----------------------------------------------------------------------
62          // Value inherited from p3
63          // ----------------------------------------------------------------------
64  
65          assertEquals( "2000", p4.getInceptionYear() );
66  
67          // ----------------------------------------------------------------------
68          // Value taken from p2
69          // ----------------------------------------------------------------------
70  
71          assertEquals( "mailing-list", p4.getMailingLists().get( 0 ).getName() );
72  
73          // ----------------------------------------------------------------------
74          // Value taken from p1
75          // ----------------------------------------------------------------------
76  
77          assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() );
78  
79          // ----------------------------------------------------------------------
80          // Value taken from p4
81          // ----------------------------------------------------------------------
82  
83          assertEquals( "Codehaus", p4.getOrganization().getName() );
84  
85          // ----------------------------------------------------------------------
86          // Value taken from super model
87          // ----------------------------------------------------------------------
88  
89          assertEquals( "4.0.0", p4.getModelVersion() );
90  
91          assertEquals( "4.0.0", p4.getModelVersion() );
92      }
93  }