View Javadoc

1   package org.apache.maven.it;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.it.Verifier;
23  import org.apache.maven.it.util.ResourceExtractor;
24  
25  import java.io.File;
26  import java.util.Properties;
27  
28  /**
29   * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4102">MNG-4102</a>.
30   * 
31   * @author Benjamin Bentmann
32   * @version $Id: MavenITmng4102InheritedPropertyInterpolationTest.java 981712 2010-08-03 00:36:19Z bentmann $
33   */
34  public class MavenITmng4102InheritedPropertyInterpolationTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      public MavenITmng4102InheritedPropertyInterpolationTest()
39      {
40          super( ALL_MAVEN_VERSIONS );
41      }
42  
43      /**
44       * Verify that the effective value of an inherited property reflects the values of any nested property
45       * as defined by the child. This boils down to the order of inheritance and (parent) interpolation.
46       * This variation of the test has no profiles.
47       */
48      public void testitNoProfiles()
49          throws Exception
50      {
51          testit( "no-profile" );
52      }
53  
54      /**
55       * Verify that the effective value of an inherited property reflects the values of any nested property
56       * as defined by the child. This boils down to the order of inheritance and (parent) interpolation.
57       * This variation of the test has active profiles in parent and child (which should make no difference
58       * to the result).
59       */
60      public void testitActiveProfiles()
61          throws Exception
62      {
63          testit( "active-profile" );
64      }
65  
66      private void testit( String project )
67          throws Exception
68      {
69          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4102/" + project );
70  
71          Verifier verifier = newVerifier( new File( testDir, "sub" ).getAbsolutePath() );
72          verifier.setAutoclean( false );
73          verifier.deleteDirectory( "target" );
74          verifier.executeGoal( "validate" );
75          verifier.verifyErrorFreeLog();
76          verifier.resetStreams();
77  
78          Properties props = verifier.loadProperties( "target/pom.properties" );
79          assertEquals( "CHILD", props.getProperty( "project.properties.overridden" ) );
80          assertEquals( "CHILD", props.getProperty( "project.properties.interpolated" ) );
81      }
82  
83  }