001    package org.apache.maven.project.inheritance.t00;
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.model.MailingList;
023    import org.apache.maven.project.MavenProject;
024    import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
025    
026    /**
027     * A test which demonstrates maven's recursive inheritance where
028     * a distinct value is taken from each parent contributing to the
029     * the final model of the project being assembled. There is no
030     * overriding going on amongst the models being used in this test:
031     * each model in the lineage is providing a value that is not present
032     * anywhere else in the lineage. We are just making sure that values
033     * down in the lineage are bubbling up where they should.
034     *
035     * @author Jason van Zyl
036     */
037    public class ProjectInheritanceTest
038        extends AbstractProjectInheritanceTestCase
039    {
040        // ----------------------------------------------------------------------
041        //
042        // p4 inherits from p3
043        // p3 inherits from p2
044        // p2 inherits from p1
045        // p1 inherits from p0
046        // p0 inhertis from super model
047        //
048        // or we can show it graphically as:
049        //
050        // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
051        //
052        // ----------------------------------------------------------------------
053    
054        public void testProjectInheritance()
055            throws Exception
056        {
057            MavenProject p4 = getProject( projectFile( "p4" ) );
058    
059            assertEquals( "p4", p4.getName() );
060    
061            // ----------------------------------------------------------------------
062            // Value inherited from p3
063            // ----------------------------------------------------------------------
064    
065            assertEquals( "2000", p4.getInceptionYear() );
066    
067            // ----------------------------------------------------------------------
068            // Value taken from p2
069            // ----------------------------------------------------------------------
070    
071            assertEquals( "mailing-list", ( (MailingList) p4.getMailingLists().get( 0 ) ).getName() );
072    
073            // ----------------------------------------------------------------------
074            // Value taken from p1
075            // ----------------------------------------------------------------------
076    
077            assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() );
078    
079            // ----------------------------------------------------------------------
080            // Value taken from p4
081            // ----------------------------------------------------------------------
082    
083            assertEquals( "Codehaus", p4.getOrganization().getName() );
084    
085            // ----------------------------------------------------------------------
086            // Value taken from super model
087            // ----------------------------------------------------------------------
088    
089            assertEquals( "4.0.0", p4.getModelVersion() );
090    
091            assertEquals( "4.0.0", p4.getModelVersion() );
092        }
093    }