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-2591">MNG-2591</a>.
30   * 
31   * @author Benjamin Bentmann
32   * @version $Id: MavenITmng2591MergeInheritedPluginConfigTest.java 981712 2010-08-03 00:36:19Z bentmann $
33   */
34  public class MavenITmng2591MergeInheritedPluginConfigTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      public MavenITmng2591MergeInheritedPluginConfigTest()
39      {
40          super( "(2.0.7,)" );
41      }
42  
43      /**
44       * Test aggregation of list configuration items for build plugins when using 'combine.children=append' attribute.
45       * This variation of the test does not employ profiles.
46       */
47      public void testitNoProfile()
48          throws Exception
49      {
50          testit( "no-profile" );
51      }
52  
53      /**
54       * Test aggregation of list configuration items for build plugins when using 'combine.children=append' attribute.
55       * This variation of the test employs active profiles which however are empty and should not change the result.
56       */
57      public void testitWithProfile()
58          throws Exception
59      {
60          testit( "with-profile" );
61      }
62  
63      private void testit( String project )
64          throws Exception
65      {
66          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2591/" + project );
67          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
68          verifier.setAutoclean( false );
69          verifier.deleteDirectory( "subproject/target" );
70          verifier.executeGoal( "validate" );
71          verifier.verifyErrorFreeLog();
72          verifier.resetStreams();
73  
74          Properties props = verifier.loadProperties( "subproject/target/config.properties" );
75  
76          assertEquals( "8", props.getProperty( "stringParams" ) );
77          assertEquals( "PARENT-1", props.getProperty( "stringParams.0" ) );
78          assertEquals( "PARENT-3", props.getProperty( "stringParams.1" ) );
79          assertEquals( "PARENT-2", props.getProperty( "stringParams.2" ) );
80          assertEquals( "PARENT-4", props.getProperty( "stringParams.3" ) );
81          assertEquals( "CHILD-1", props.getProperty( "stringParams.4" ) );
82          assertEquals( "CHILD-3", props.getProperty( "stringParams.5" ) );
83          assertEquals( "CHILD-2", props.getProperty( "stringParams.6" ) );
84          assertEquals( "CHILD-4", props.getProperty( "stringParams.7" ) );
85  
86          assertEquals( "8", props.getProperty( "listParam" ) );
87          assertEquals( "PARENT-1", props.getProperty( "listParam.0" ) );
88          assertEquals( "PARENT-3", props.getProperty( "listParam.1" ) );
89          assertEquals( "PARENT-2", props.getProperty( "listParam.2" ) );
90          assertEquals( "PARENT-4", props.getProperty( "listParam.3" ) );
91          assertEquals( "CHILD-1", props.getProperty( "listParam.4" ) );
92          assertEquals( "CHILD-3", props.getProperty( "listParam.5" ) );
93          assertEquals( "CHILD-2", props.getProperty( "listParam.6" ) );
94          assertEquals( "CHILD-4", props.getProperty( "listParam.7" ) );
95      }
96  
97  }