001    package org.apache.maven.project.inheritance.t01;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *  http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import org.apache.maven.project.MavenProject;
023    import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
024    
025    /**
026     * A test which demonstrates maven's recursive inheritance where
027     * we are testing to make sure that elements stated in a model are
028     * not clobbered by the same elements elsewhere in the lineage.
029     *
030     * @author Jason van Zyl
031     */
032    public class ProjectInheritanceTest
033        extends AbstractProjectInheritanceTestCase
034    {
035        // ----------------------------------------------------------------------
036        //
037        // p4 inherits from p3
038        // p3 inherits from p2
039        // p2 inherits from p1
040        // p1 inherits from p0
041        // p0 inhertis from super model
042        //
043        // or we can show it graphically as:
044        //
045        // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
046        //
047        // ----------------------------------------------------------------------
048    
049        public void testProjectInheritance()
050            throws Exception
051        {
052            // ----------------------------------------------------------------------
053            // Check p0 value for org name
054            // ----------------------------------------------------------------------
055    
056            MavenProject p0 = getProject( projectFile( "maven.t01", "p0" ) );
057    
058            assertEquals( "p0-org", p0.getOrganization().getName() );
059    
060            // ----------------------------------------------------------------------
061            // Check p1 value for org name
062            // ----------------------------------------------------------------------
063    
064            MavenProject p1 = getProject( projectFile( "maven.t01", "p1" ) );
065    
066            assertEquals( "p1-org", p1.getOrganization().getName() );
067    
068            // ----------------------------------------------------------------------
069            // Check p2 value for org name
070            // ----------------------------------------------------------------------
071    
072            MavenProject p2 = getProject( projectFile( "maven.t01", "p2" ) );
073    
074            assertEquals( "p2-org", p2.getOrganization().getName() );
075    
076            // ----------------------------------------------------------------------
077            // Check p2 value for org name
078            // ----------------------------------------------------------------------
079    
080            MavenProject p3 = getProject( projectFile( "maven.t01", "p3" ) );
081    
082            assertEquals( "p3-org", p3.getOrganization().getName() );
083    
084            // ----------------------------------------------------------------------
085            // Check p4 value for org name
086            // ----------------------------------------------------------------------
087    
088            MavenProject p4 = getProject( projectFile( "maven.t01", "p4" ) );
089    
090            assertEquals( "p4-org", p4.getOrganization().getName() );
091        }
092    }