KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > project > inheritance > t00 > ProjectInheritanceTest


1 package org.apache.maven.project.inheritance.t00;
2
3 /*
4  * Copyright 2001-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * 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, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.maven.model.MailingList;
20 import org.apache.maven.project.MavenProject;
21 import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
22
23 /**
24  * A test which demonstrates maven's recursive inheritance where
25  * a distinct value is taken from each parent contributing to the
26  * the final model of the project being assembled. There is no
27  * overriding going on amongst the models being used in this test:
28  * each model in the lineage is providing a value that is not present
29  * anywhere else in the lineage. We are just making sure that values
30  * down in the lineage are bubbling up where they should.
31  *
32  * @author <a HREF="mailto:jason@maven.org">Jason van Zyl</a>
33  * @version $Id: ProjectInheritanceTest.java 240178 2005-08-26 07:31:18Z brett $
34  */

35 public class ProjectInheritanceTest
36     extends AbstractProjectInheritanceTestCase
37 {
38     // ----------------------------------------------------------------------
39
//
40
// p4 inherits from p3
41
// p3 inherits from p2
42
// p2 inherits from p1
43
// p1 inherits from p0
44
// p0 inhertis from super model
45
//
46
// or we can show it graphically as:
47
//
48
// p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
49
//
50
// ----------------------------------------------------------------------
51

52     public void testProjectInheritance()
53         throws Exception JavaDoc
54     {
55         MavenProject p4 = getProject( projectFile( "p4" ) );
56
57         assertEquals( "p4", p4.getName() );
58
59         // ----------------------------------------------------------------------
60
// Value inherited from p3
61
// ----------------------------------------------------------------------
62

63         assertEquals( "2000", p4.getInceptionYear() );
64
65         // ----------------------------------------------------------------------
66
// Value taken from p2
67
// ----------------------------------------------------------------------
68

69         assertEquals( "mailing-list", ( (MailingList) p4.getMailingLists().get( 0 ) ).getName() );
70
71         // ----------------------------------------------------------------------
72
// Value taken from p1
73
// ----------------------------------------------------------------------
74

75         assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() );
76
77         // ----------------------------------------------------------------------
78
// Value taken from p4
79
// ----------------------------------------------------------------------
80

81         assertEquals( "Codehaus", p4.getOrganization().getName() );
82
83         // ----------------------------------------------------------------------
84
// Value taken from super model
85
// ----------------------------------------------------------------------
86

87         assertEquals( "4.0.0", p4.getModelVersion() );
88
89         assertEquals( "4.0.0", p4.getModelVersion() );
90     }
91 }
92
Popular Tags