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-469">MNG-469</a>.
30   * 
31   * @author Benjamin Bentmann
32   * @version $Id: MavenITmng0469ReportConfigTest.java 982028 2010-08-03 20:35:51Z bentmann $
33   */
34  public class MavenITmng0469ReportConfigTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      public MavenITmng0469ReportConfigTest()
39      {
40          super( "[2.0.0,)" );
41      }
42  
43      /**
44       * Test that <reporting> configuration also affects build plugins unless <build> configuration is also given.
45       */
46      public void testitReportConfigOverridesBuildDefaults()
47          throws Exception
48      {
49          requiresMavenVersion( "[2.0.0,3.0-alpha-1)" );
50  
51          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0469/test0" );
52  
53          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
54          verifier.deleteDirectory( "target" );
55          verifier.setAutoclean( false );
56          verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-configuration:2.1-SNAPSHOT:config" );
57          verifier.verifyErrorFreeLog();
58          verifier.resetStreams();
59  
60          Properties props = verifier.loadProperties( "target/config.properties" );
61          assertEquals( "not-the-default-value", props.getProperty( "defaultParam" ) );
62      }
63  
64      /**
65       * Test that <build> configuration dominates <reporting> configuration for build goals.
66       */
67      public void testitBuildConfigDominantDuringBuild()
68          throws Exception
69      {
70          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0469/test1" );
71  
72          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
73          verifier.deleteDirectory( "target" );
74          verifier.setAutoclean( false );
75          verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-configuration:2.1-SNAPSHOT:config" );
76          verifier.assertFilePresent( "target/build.txt" );
77          verifier.assertFileNotPresent( "target/reporting.txt" );
78          verifier.verifyErrorFreeLog();
79          verifier.resetStreams();
80      }
81  
82      /**
83       * Test that <build> configuration does not affect report goals.
84       */
85      public void testitBuildConfigIrrelevantForReports()
86          throws Exception
87      {
88          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0469/test2" );
89  
90          Verifier verifier = newVerifier( testDir.getAbsolutePath(), "remote" );
91          verifier.deleteDirectory( "target" );
92          verifier.setAutoclean( false );
93          if ( matchesVersionRange( "(,3.0-alpha-1)" ) )
94          {
95              verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-site:2.1-SNAPSHOT:generate" );
96              verifier.assertFilePresent( "target/site/info.properties" );
97          }
98          else
99          {
100             verifier.executeGoal( "validate" );
101             Properties props = verifier.loadProperties( "target/config.properties" );
102             assertEquals( "maven-it-plugin-site", props.getProperty( "project.reporting.plugins.0.artifactId" ) );
103             assertFalse( "fail.properties".equals( props.getProperty( "project.reporting.plugins.0.configuration.children.infoFile.0.value" ) ) );
104         }
105         verifier.verifyErrorFreeLog();
106         verifier.resetStreams();
107     }
108 
109 }