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 java.io.File;
23  
24  import org.apache.maven.it.util.ResourceExtractor;
25  import org.apache.maven.shared.utils.io.FileUtils;
26  
27  public class MavenITmng6127PluginExecutionConfigurationInterferenceTest
28      extends AbstractMavenIntegrationTestCase
29  {
30  
31      public MavenITmng6127PluginExecutionConfigurationInterferenceTest()
32      {
33          super( "[3.5.1,)" );
34      }
35  
36      public void testCustomMojoExecutionConfigurator()
37          throws Exception
38      {
39          File testDir =
40              ResourceExtractor.simpleExtractResources( getClass(),
41                                                        "/mng-6127-plugin-execution-configuration-interference" );
42          File pluginDir = new File( testDir, "plugin" );
43          File projectDir = new File( testDir, "project" );
44          File modAprojectDir = new File( projectDir, "mod-a" );
45          File modBprojectDir = new File( projectDir, "mod-b" );
46          File modCprojectDir = new File( projectDir, "mod-c" );
47  
48          Verifier verifier;
49  
50          // install the test plugin
51          verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
52          verifier.executeGoal( "install" );
53          verifier.resetStreams();
54          verifier.verifyErrorFreeLog();
55  
56          File modAconfigurationFile = new File( modAprojectDir, "configuration.txt" );
57          File modBconfigurationFile = new File( modBprojectDir, "configuration.txt" );
58          File modCconfigurationFile = new File( modCprojectDir, "configuration.txt" );
59          modAconfigurationFile.delete();
60          modBconfigurationFile.delete();
61          modCconfigurationFile.delete();
62  
63          // build the test project
64          verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
65          verifier.executeGoal( "verify" );
66          verifier.resetStreams();
67          verifier.verifyErrorFreeLog();
68  
69          verifier.assertFilePresent( modAconfigurationFile.getCanonicalPath() );
70          String modAactual = FileUtils.fileRead( modAconfigurationFile );
71          assertEquals( "name=mod-a, secondName=second from components.xml", modAactual );
72  
73          verifier.assertFilePresent( modBconfigurationFile.getCanonicalPath() );
74          String modBactual = FileUtils.fileRead( modBconfigurationFile );
75          assertEquals( "name=mod-b, secondName=second from components.xml", modBactual );
76  
77          verifier.assertFilePresent( modCconfigurationFile.getCanonicalPath() );
78          String modCactual = FileUtils.fileRead( modCconfigurationFile );
79          assertEquals( "secondName=second from components.xml", modCactual );
80      }
81  }