View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.project.inheritance.t01;
20  
21  import org.apache.maven.project.MavenProject;
22  import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
23  
24  /**
25   * A test which demonstrates maven's recursive inheritance where
26   * we are testing to make sure that elements stated in a model are
27   * not clobbered by the same elements elsewhere in the lineage.
28   *
29   * @author Jason van Zyl
30   */
31  public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase {
32      // ----------------------------------------------------------------------
33      //
34      // p4 inherits from p3
35      // p3 inherits from p2
36      // p2 inherits from p1
37      // p1 inherits from p0
38      // p0 inherits from super model
39      //
40      // or we can show it graphically as:
41      //
42      // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
43      //
44      // ----------------------------------------------------------------------
45  
46      public void testProjectInheritance() throws Exception {
47          // ----------------------------------------------------------------------
48          // Check p0 value for org name
49          // ----------------------------------------------------------------------
50  
51          MavenProject p0 = getProject(projectFile("maven.t01", "p0"));
52  
53          assertEquals("p0-org", p0.getOrganization().getName());
54  
55          // ----------------------------------------------------------------------
56          // Check p1 value for org name
57          // ----------------------------------------------------------------------
58  
59          MavenProject p1 = getProject(projectFile("maven.t01", "p1"));
60  
61          assertEquals("p1-org", p1.getOrganization().getName());
62  
63          // ----------------------------------------------------------------------
64          // Check p2 value for org name
65          // ----------------------------------------------------------------------
66  
67          MavenProject p2 = getProject(projectFile("maven.t01", "p2"));
68  
69          assertEquals("p2-org", p2.getOrganization().getName());
70  
71          // ----------------------------------------------------------------------
72          // Check p2 value for org name
73          // ----------------------------------------------------------------------
74  
75          MavenProject p3 = getProject(projectFile("maven.t01", "p3"));
76  
77          assertEquals("p3-org", p3.getOrganization().getName());
78  
79          // ----------------------------------------------------------------------
80          // Check p4 value for org name
81          // ----------------------------------------------------------------------
82  
83          MavenProject p4 = getProject(projectFile("maven.t01", "p4"));
84  
85          assertEquals("p4-org", p4.getOrganization().getName());
86      }
87  }