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