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